Pre-Interview Assignment
Building a RESTful API with Node.js
Date: 04/17/2024
Over View
• Objective: Build a RESTful API using Node.js that allows users to perform CRUD (Create, Read, Update,
Delete) operations on a resource, such as "users", "todos", or "posts".
• Deadline: Please, email the assignment code/GitHub url before the first interview.
4/17/2024 SAYA SKYCRAFT 2/4
Problem
❑ Requirements: ❑ Validation:
• Setup and Configuration: • Implement validation for input data (e.g., required fields,
data type validation).
• Initialize a new Node.js project.
• Return appropriate error responses for invalid requests.
• Use Express.js as the web server framework.
❑ Error Handling:
• Set up a MongoDB database to store the data. You can use
an ORM like Mongoose or the native MongoDB driver. • Implement centralized error handling to handle
unexpected errors gracefully.
❑ API Endpoints:
• Return meaningful error messages in the API responses.
• Implement CRUD operations for the chosen resource. For
example: ❑ Testing:
• GET /users - Retrieve all users. • Write unit tests to ensure the API endpoints behave as
expected.
• POST /users - Create a new user.
• Use a testing framework like Mocha or Jest.
• GET /users/:id - Retrieve a specific user by ID.
• Include test cases for success and error scenarios.
• PUT /users/:id - Update a specific user by ID.
• DELETE /users/:id - Delete a specific user by ID.
4/17/2024 SAYA SKYCRAFT 3/4
Problem
❑ Documentation:
• Document the API endpoints using tools like Swagger or Postman.
• Provide clear instructions on how to use the API.
❑ Security:
• Implement basic security measures such as input sanitization and
preventing common vulnerabilities like SQL injection and XSS attacks.
❑ Bonus:
• Implement authentication and authorization using JWT (JSON Web
Tokens).
• Add pagination, sorting, and filtering options for retrieving resources.
• Dockerize the application for easier deployment.
❑ Submission:
• On Github.com Provide the source code of the project along with any
necessary instructions for running the application.
• Optionally, include a README file explaining the project structure, how
to install dependencies, and how to run the application and tests.
4/17/2024 SAYA SKYCRAFT 4/4