https://github.com/mar-alv/ignite-todo-list-api
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
https://github.com/mar-alv/ignite-todo-list-api
api back-end backend httpie javascript js node nodejs stream streaming
Last synced: 7 months ago
JSON representation
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
- Host: GitHub
- URL: https://github.com/mar-alv/ignite-todo-list-api
- Owner: mar-alv
- License: mit
- Created: 2024-06-30T21:33:47.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-14T16:08:32.000Z (10 months ago)
- Last Synced: 2025-01-11T16:36:06.888Z (9 months ago)
- Topics: api, back-end, backend, httpie, javascript, js, node, nodejs, stream, streaming
- Language: JavaScript
- Homepage:
- Size: 338 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Ignite ToDo List API

[](https://opensource.org/licenses/MIT)[π§π· PortuguΓͺs](./docs/README-pt.md)
## π Summary
- [β About](#about)
- [π Instructions](#instructions)
- [π₯ Install](#install)
- [π Run Locally](#locally)
- [β‘ Endpoints](#endpoints)
- [π Structure](#structure)
- [π§° Technologies](#technologies)
- [πΈ Screenshots and π₯ Recordings](#screenshots-prints)
- [π€ Author](#author)
- [π License](#license)### β About
This is my implementation of the challenge project "ToDo List API" from the first Node.js module of [Ignite](https://www.rocketseat.com.br/ignite), an intermediate and advanced course in various programming languages and technologies offered by [Rocketseat](https://www.rocketseat.com.br/).### π Instructions
#### π₯ Install
Paste the 1ΒΊ command into a terminal open within a folder of your preference to clone the project
```sh
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
```sh
npm i
```
```sh
npm install
```#### π Run Locally
Paste the command into a terminal, the server will be accessable through the port 3001
```sh
npm run dev
```### β‘ Endpoints
In order to make requests to the server with π₯§ HTTPie directly from the terminal, you would have to follow its CLI [installation guide](https://httpie.io/docs/cli/main-features)
#### Create a task
Creates a new task with the given title and description
```sh
curl -X POST http://localhost:3001/tasks -h "Content-Type: application/json" -d '{"title":"Task title", "description":"Task description"}'
```With π₯§ HTTPie
```sh
http POST http://localhost:3001/tasks < httpie/create.json
```
Responses
```
# When successfully creating a new taskHTTP/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
```sh
curl -X GET 'http://localhost:3001/tasks' -h "Content-Type: application/json"
```
```sh
curl -X GET 'http://localhost:3001/tasks?search=title' -h "Content-Type: application/json"
```With π₯§ HTTPie
```sh
http GET http://localhost:3001/tasks
```
```sh
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
```sh
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
```sh
http PUT http://localhost:3001/tasks/e13c1414-476f-4c7d-b8ca-44a4279bd538 < httpie/update.json
```Responses
```
# When successfully updating a taskHTTP/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
```sh
curl -X DELETE http://localhost:3001/tasks/e13c1414-476f-4c7d-b8ca-44a4279bd538 -h "Content-Type: application/json"
```With π₯§ HTTPie
```sh
http DELETE http://localhost:3001/tasks/e13c1414-476f-4c7d-b8ca-44a4279bd538
```Responses
```
# When successfully deleting a taskHTTP/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
```sh
curl -X PATCH http://localhost:3001/tasks/e13c1414-476f-4c7d-b8ca-44a4279bd538/complete -h "Content-Type: application/json"
```With π₯§ HTTPie
```sh
http PATCH http://localhost:3001/tasks/e13c1414-476f-4c7d-b8ca-44a4279bd538/complete
```Responses
```
# When successfully closing/reopening a taskHTTP/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 serverResponse
```
HTTP/1.1 404 Not Found
Connection: keep-alive
Content-type: application/json"Route not found"
```### π Structure
```
β docs/
β βββ ...
β httpie/
β βββ ...
β src/
β βββ middlewares/
β β βββ ...
β βββ utils/
β β βββ ...
β βββ ...
```### π§° Technologies
#### Build Tools
[](https://nodejs.org/)#### Testing
[](https://httpie.io/)### π€ Author
### π License
Licensed under [MIT](./LICENSE)