Skip to content

1st NodeJs challenge of Ignite, Rocketseat's programming course, an API to handle a To Do List, where you can list, filter, create, update and delete To Dos

License

Notifications You must be signed in to change notification settings

mar-alv/ignite-todo-list-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ignite ToDo List API

📚 Summary

This is my implementation of the challenge project "ToDo List API" from the first Node.js module of Ignite, an intermediate and advanced course in various programming languages and technologies offered by Rocketseat.

Paste the 1º command into a terminal open within a folder of your preference to clone the project

git clone https://github.com/mar-alv/ignite-todo-list-api.git

Then run one of the versions of the 2º command to install the dependencies

npm i
npm install

Paste the command into a terminal, the server will be accessable through the port 3001

npm run dev

In order to make requests to the server with 🥧 HTTPie directly from the terminal, you would have to follow its CLI installation guide

Create a task

Creates a new task with the given title and description

curl -X POST http://localhost:3001/tasks -h "Content-Type: application/json" -d '{"title":"Task title", "description":"Task description"}'

With 🥧 HTTPie

http POST http://localhost:3001/tasks < httpie/create.json

Responses

# When successfully creating a new task

HTTP/1.1 201 Created
Connection: keep-alive
Content-type: application/json

"Task created"

# When not providing a valid request body

HTTP/1.1 400 Bad Request
Content-type: application/json

"Title and description are obligatory"

List tasks

Lists all tasks created, you may optionally pass a value to filter for specific tasks, based on their title or description

curl -X GET 'http://localhost:3001/tasks' -h "Content-Type: application/json"
curl -X GET 'http://localhost:3001/tasks?search=title' -h "Content-Type: application/json"

With 🥧 HTTPie

http GET http://localhost:3001/tasks
http GET http://localhost:3001/tasks?search=title

Responses

# Having created a task
HTTP/1.1 200 OK
Connection: keep-alive
Content-type: application/json

[
  {
   "completedAt": null,
   "createdAt": "2024-06-30T22:47:22.258Z",
   "description": "task description",
   "id": "88e75cc5-605f-49e9-a295-89a027136ab0",
    "title": "task title",
    "updatedAt": "2024-06-30T22:47:22.258Z"
  }
]

# Not having created a task or none matching the given filter

HTTP/1.1 200 OK
Connection: keep-alive
Content-type: application/json

[]

Update a task

Updates the title and/or description of an existing task through its id, the updatedAt date is automatically updated

curl -X PUT http://localhost:3001/tasks/e13c1414-476f-4c7d-b8ca-44a4279bd538 -h "Content-Type: application/json" -d '{"title":"New task title", "description":"New task description"}'

With 🥧 HTTPie

http PUT http://localhost:3001/tasks/e13c1414-476f-4c7d-b8ca-44a4279bd538 < httpie/update.json

Responses

# When successfully updating a task

HTTP/1.1 204 No Content
Connection: keep-alive
Content-type: application/json

# When not providing a valid request body

HTTP/1.1 400 Bad Request
Connection: keep-alive
Content-type: application/json

"Title or description obligatory"

# When not finding the task by its id

HTTP/1.1 404 Not Found
Connection: keep-alive
Content-type: application/json

"Task not found"

Delete a task

Deletes an existing task through its id

curl -X DELETE http://localhost:3001/tasks/e13c1414-476f-4c7d-b8ca-44a4279bd538 -h "Content-Type: application/json"

With 🥧 HTTPie

http DELETE http://localhost:3001/tasks/e13c1414-476f-4c7d-b8ca-44a4279bd538

Responses

# When successfully deleting a task

HTTP/1.1 204 No Content
Connection: keep-alive
Content-type: application/json

# When not finding the task by its id

HTTP/1.1 404 Not Found
Connection: keep-alive
Content-type: application/json

"Task not found"

Close/Reopen a task

Closes or reopens an existing task through its id

curl -X PATCH http://localhost:3001/tasks/e13c1414-476f-4c7d-b8ca-44a4279bd538/complete -h "Content-Type: application/json"

With 🥧 HTTPie

http PATCH http://localhost:3001/tasks/e13c1414-476f-4c7d-b8ca-44a4279bd538/complete

Responses

# When successfully closing/reopening a task

HTTP/1.1 204 No Content
Connection: keep-alive
Content-type: application/json

# When not finding the task by its id

HTTP/1.1 404 Not Found
Connection: keep-alive
Content-type: application/json

"Task not found"

Non existing route

When trying to access a route that doesn't exists in the server

Response

HTTP/1.1 404 Not Found
Connection: keep-alive
Content-type: application/json

"Route not found"
│ docs/
│   └── ...
│ httpie/
│   └── ...
│ src/
│   ├── middlewares/
│   │     └── ...
│   ├── utils/
│   │     └── ...
│   └── ...

Build Tools

Node.js

Testing

HTTPie

Marcelo Alvarez GitHub profile picture
Marcelo Alvarez
Front-end Developer
"Some AI generated funny quote here 😗"
LinkedIn Portfolio

Licensed under MIT

About

1st NodeJs challenge of Ignite, Rocketseat's programming course, an API to handle a To Do List, where you can list, filter, create, update and delete To Dos

Topics

Resources

License

Stars

Watchers

Forks