0% found this document useful (0 votes)
3 views5 pages

Nodejs Assignment

This document outlines a mandatory Node.js assignment with strict guidelines, including a single attempt for submission and no use of frameworks like Express.js. It consists of three problems: creating an API to calculate a user's age from their date of birth, returning a JSON response by reading a local file, and building an API for area and volume calculations based on query parameters. Students are required to upload their solutions to GitHub for code review and must avoid any form of plagiarism.

Uploaded by

mohit shekhar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views5 pages

Nodejs Assignment

This document outlines a mandatory Node.js assignment with strict guidelines, including a single attempt for submission and no use of frameworks like Express.js. It consists of three problems: creating an API to calculate a user's age from their date of birth, returning a JSON response by reading a local file, and building an API for area and volume calculations based on query parameters. Students are required to upload their solutions to GitHub for code review and must avoid any form of plagiarism.

Uploaded by

mohit shekhar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Nodejs Assignment

Guidelines:

i. This assignment is mandatory for everyone

​ o deadline extension in
ii. There will only be a single attempt for each exam and n
case of assignments

iii. Any case of unfair means or ​plagiarism would lead to debarring​ in final
placements without any further consideration.

iv. Do not use any framework like [Link]/[Link] for building the API endpoints in
this assignment

v. The assignment solutions should be uploaded on Github and links to Github


repositories should be shared with the coach for code review. Make sure to add
appropriate comments in code wherever possible.

Problem 1:

Build an API to calculate current age of user from date of birth


Request URL:- ​[Link]

Request Method:- GET

Response HTML:-

​ ​>Hello John</​p​>
<p
<p​ ​>You are currently 22 years old</​p​>

Objective:-
Build an API with the above parameters using [Link].

Learnings:

How to make an http-server and endpoints using core [Link] modules.

Problem 2:
Return a JSON response by reading a local file using [Link]

Request URL:- ​[Link]

Request Method:- GET


Response JSON:-

{
​ result"​: {
"
​"rootVegetables"​: [
​"turnips", ​
​"ginger", ​
​"beets"
],
​"leafyVegetables"​: [
​"broccoli", ​
​"spinach"​,
​"cabbage"
]
}
}

Objective:-
1. Create a file with `.json` extension in your project folder with below data:-

{
​"result"​: {
​"rootVegetables"​: [
​"turnips"​,
​"ginger"​,
​"beets"
],
​"leafyVegetables"​: [
​"broccoli"​,
​"spinach"​,
​"cabbage"
]
}
}

2. Next read that JSON file in your server route using [Link] file system module. More
details can be found here:-
[Link]

3. Return the data read from the JSON file in your route’s response.

Learnings

How to use [Link] file system module


Problem 3:

Build a area and volume calculation API for various objects based on query params
sent with the request

API URL:- ​[Link]

Query params types possible:-


object: circle, sphere

metric: 1. area(For circle)


2. volume or surfaceArea(For Sphere)

radius: Integer value

Objective:-
Build an API which can calculate area of a circle or volume/surface area of a sphere
based on inputs sent via query params.

For example:-
If the URL is `​[Link]
Then you need to calculate volume of a sphere with radius 5 units as shown below:-

Refer to the query params section stated in the problem to understand other
possible combinations.

Learnings

How to use functions with request routes in [Link]

You might also like