Git Product home page Git Product logo

node-v2's Introduction

Welcome to Round 3 of your Backend with NestJs Interview

CodeBuddy Round 3 Interview

This round is to test your Logical thinking, coding skills, reading skills and NestJs basics.

This repo uses NestJs and Jest to create a backend server and perform e2e tests.

Please carefully read the instructions mentioned below.

DON'T CLONE THIS REPO and DON'T MAKE PULL REQUESTS TO THIS REPO. FORK this repo to your own GitHub account then clone it. Fork button is the top right corner of the page. The forked URL should look something like this: https://github.com/${YOUR_GITHUB_USERNAME}/node

A. Calculator

  1. Implement a post route http://localhost:3000/calc that takes a JSON input in the following format:
{
  "expression": "<expression>"
}

and returns a json in the following format by evaluating the expression.

{
  "result": "<result>"
}
  1. You cannot use evel or any other third party library to evaluate the expression.
  2. You cannot add or remove any files from the project.
  3. You can only work inside calc/calc.service.ts@calculateExpression method.
  4. In case the expression is invalid, return a json in the following format with 400 status code
{
  "statusCode": 400,
  "message": "Invalid expression provided",
  "error": "Bad Request"
}
  1. You need to implement +, -, *, / operations. Handling Operator precedence is optional.
  2. The repository contains 6 test cases. You need to make sure all of them pass. In case operator precedence is not handled run pnpm test:basic command to run only the basic test cases. Otherwise, run pnpm test:advanced to run all the test cases.
  3. Follow the test case files to understand the input and output format.
  • i. test/simpleCalc.e2e-spec.ts
  • ii. test/operatorPrecedenceNotHandled.e2e-spec.ts
  • iii. test/invalidExpression.e2e-spec.ts

B. NestJS middleware

  1. Implement a NestJS middleware that logs the request URL, method, time taken to execute the request and response status code.
  2. The middleware should be applied to all the routes.
  3. The log text example: GET /calc 200 1.2 ms

> Total allocated time for the these 2 task is 2.5hr. In case you need more than the allocated time, communicate with your recruiter.

node-v2's People

Contributors

goropencho avatar sumancbd avatar codebuddyinterview avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.