Skip to content

Create an express HTTP server in Node.js which will handle the logic of a todo list app. #2 #2

@shash369

Description

@shash369

You need to create an express HTTP server in Node.js which will handle the logic of a todo list app.
Don't use any database, just store all the data in an array to store the todo list data (in-memory)
Each todo has a title and a description. The title is a string and the description is a string.
Each todo should also get an unique autogenerated id every time it is created
The expected API endpoints are defined below,

1.GET /todos - Retrieve all todo items
Description: Returns a list of all todo items.
Response: 200 OK with an array of todo items in JSON format.
Example: GET http://localhost:3000/todos

2.GET /todos/:id - Retrieve a specific todo item by ID
Description: Returns a specific todo item identified by its ID.
Response: 200 OK with the todo item in JSON format if found, or 404 Not Found if not found.
Example: GET http://localhost:3000/todos/123

  1. POST /todos - Create a new todo item
    Description: Creates a new todo item.
    Request Body: JSON object representing the todo item.
    Response: 201 Created with the ID of the created todo item in JSON format. eg: {id: 1}
    Example: POST http://localhost:3000/todos
    Request Body: { "title": "Buy groceries", "completed": false, description: "I should buy groceries" }

  2. PUT /todos/:id - Update an existing todo item by ID
    Description: Updates an existing todo item identified by its ID.
    Request Body: JSON object representing the updated todo item.
    Response: 200 OK if the todo item was found and updated, or 404 Not Found if not found.
    Example: PUT http://localhost:3000/todos/123
    Request Body: { "title": "Buy groceries", "completed": true }

  3. DELETE /todos/:id - Delete a todo item by ID
    Description: Deletes a todo item identified by its ID.
    Response: 200 OK if the todo item was found and deleted, or 404 Not Found if not found.
    Example: DELETE http://localhost:3000/todos/123

  • For any other route not defined in the server return 404

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions