Task Description You will design a simple Node.js web server/application, having a set of REST endpoints, and using MongoDB to store the details. Dummy data APIs for your use are available at JSON Placeholder (https://jsonplaceholder.typicode.com/). Quickstarts and References are linked below
- MongoDB
- REST API
- Typescript ● Create a Node.js server using default node packages & typescript ● All request & response bodies should be properly typed ● Create three separate DB collections called users, posts, comments & store the data in the appropriate DB collection.
● ts-node can be used to run the server Rest Endpoints HTTP verb URL Description GET /load Loads 10 users into DB, user data should be fetched from JSON Placeholder along with users' posts, comments & store the details in appropriate collection, should always return empty response - with code 200 on success, else an appropriate error code.
DELETE /users Delete all users in the DB
DELETE /users/:userId Delete user with userId from DB
GET /users/:userId Get the specific user with userId from DB and return user data including users post & comment for posts in JSON format. See the user data format below.
PUT /users Put a new user into the DB, and the data is sent to the server as the request body of this API, which should return an appropriate error code if the resource already exists; See the data format below.
Certain details (like the response for some endpoints) are deliberately left empty for you to design according to best REST practices. Few things for you to think about ● Error code and response if a particular resource doesn't exist when using GET/DELETE ● Error code if POST body has a different userId field that the one it tries to update. Should it even have a userId in the POST body? ● link header in response of POST/PUT ● Schema for users/posts/comment