RESTful API with Express.js

What it does

This project demonstrates a simple RESTful API built using Express.js. It provides CRUD (Create, Read, Update, Delete) operations for managing user data. Users can retrieve all users, fetch a user by ID, add a new user, update an existing user, and delete a user by ID. The API handles requests in JSON format and responds with appropriate status codes and messages.

How we built it

  1. Technology Stack:

    • Node.js as the runtime environment.
    • Express.js for building the server and handling routes.
    • express.json() middleware for parsing incoming request bodies in JSON format.
  2. Steps:

    • Initialized a Node.js project using npm init -y.
    • Installed dependencies: express .
    • Created endpoints to perform CRUD operations on an in-memory array of users.
    • Tested endpoints using Postman and curl to ensure correctness.

Challenges we ran into

  1. Error Handling:
    • Ensuring proper error messages and status codes were returned for invalid inputs or when a user was not found.
  2. Concurrency Issues:
    • Handling potential conflicts when updating or deleting users in a real-world scenario where multiple requests might occur simultaneously.
  3. Designing Flexible Endpoints:
    • Creating endpoints that could scale and adapt if the data structure or requirements changed.

Accomplishments that we're proud of

  1. Functionality:
    • Successfully implemented all CRUD operations with clear and consistent API behavior.
  2. Code Simplicity:
    • Maintained clean and readable code, making it beginner-friendly for others to learn from.
  3. Testing:
    • Verified all endpoints to ensure they work as expected, handling both valid and invalid cases effectively.

What we learned

  1. Express.js Basics:
    • Gained a deeper understanding of setting up a server and handling routes with Express.js.
  2. API Design Principles:
    • Learned how to design RESTful APIs with proper status codes, error handling, and clear documentation.
  3. Importance of Testing:
    • Understood the value of testing each endpoint thoroughly to ensure reliability and robustness.
Share this project:

Updates