Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
shash369 opened this issue Apr 26, 2024 · 0 comments
Labels

Comments

@shash369
Copy link
Member

shash369 commented Apr 26, 2024

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
  
3. 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" }
  
4. 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 }
  
5. 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
@shash369 shash369 changed the title task 1 task 2 Apr 28, 2024
@shash369 shash369 changed the title task 2 Create an express HTTP server in Node.js which will handle the logic of a todo list app. Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants