This is a RESTful API that allows you to manage your todo list. The API has endpoints for creating, updating, deleting and retrieving todos.
Requirements To run this application, you will need:
Node.js npm or yarn package manager Installation To install the dependencies, run the following command:
bash Copy code npm install Configuration You will need to set up a .env file in the root directory of the project with the port environment variable:
PORT: The port that the server should run on
bash Copy code PORT=5000 //localhost:5000/api/v1/todo Running the application To start the server, run the following command:
bash Copy code npm start This will start the server on the port specified in the .env file.
API Endpoints The following endpoints are available:
GET /get-single/:id: Get a list of all todos GET /get-all-todos: Get a single todo by ID POST /add-todo: Create a new todo PUT /update-todo/:id: Update a todo by ID DELETE /delete-todo/:id: Delete a todo by ID User Management System To extend the API to support a user management system where each user can access their own todo, you could add the following endpoints:
POST /users: Create a new user GET /users/:id/todos: Get a list of all todos for a specific user GET /users/:id/todos/:todoId: Get a single todo by ID for a specific user POST /users/:id/todos: Create a new todo for a specific user PUT /users/:id/todos/:todoId: Update a todo by ID for a specific user DELETE /users/:id/todos/:todoId: Delete a todo by ID for a specific user To implement this, you would need to add a userId field to the Todo schema and use it to filter todos based on the authenticated user's ID. You would also need to implement authentication and authorization to ensure that each user can only access their own todos.