-
Notifications
You must be signed in to change notification settings - Fork 1
CRUD API Instruction
Use 'Java and Spring' or 'NodeJS and NestJS' to build the following CRUD API
- NodeJS - NestJS Setup: https://docs.nestjs.com/first-steps
- Spring Setup: https://spring.io/quickstart
- Everything can just be stored in memory (If the CRUD API is shutdown, tasks will be lost, this is ok)
The Todo App CRUD API is a set of endpoints that allow users to perform CRUD (Create, Read, Update, Delete) operations on todo items in the Todo App.
The API includes the following endpoints:
-
GET /todos: Retrieves a list of all todo items. -
GET /todos/{id}: Retrieves a specific todo item by its ID. -
POST /todos: Creates a new todo item. -
PUT /todos/{id}: Updates an existing todo item. -
DELETE /todos/{id}: Deletes a todo item.
Each endpoint accepts and returns JSON data.
Sample CURL requests with responses for the Todo App CRUD API:
-
Retrieve a list of all todo items:
curl -X GET /todos
Response:
[ { "id": 1, "title": "Buy groceries", "completed": false }, { "id": 2, "title": "Finish report", "completed": true }, ... ] -
Retrieve a specific todo item by its ID:
curl -X GET /todos/{id}Response:
{ "id": 1, "title": "Buy groceries", "completed": false } -
Create a new todo item:
curl -X POST /todos \\ -H "Content-Type: application/json" \\ -d '{"title": "Walk the dog", "completed": false}'
Response:
{ "id": 3, "title": "Walk the dog", "completed": false } -
Update an existing todo item:
curl -X PUT /todos/{id} \\ -H "Content-Type: application/json" \\ -d '{"title": "Buy groceries", "completed": true}'Response:
{ "id": 1, "title": "Buy groceries", "completed": true } -
Delete a todo item:
curl -X DELETE /todos/{id}Response:
{ "message": "Todo item deleted successfully" }
A Todo Item (DataModel)
The data model consists of the following fields:
-
id(integer): Represents the unique identifier of a todo item. -
title(string): Represents the title or description of a todo item. -
completed(boolean): Represents the completion status of a todo item. It istrueif the todo item has been completed, andfalseotherwise.
This data model is used to store information about a specific todo item in the Todo App. It includes an ID for identification, a title for describing the task, and a completion status to indicate whether the task has been completed or not.