An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

Ignite ToDo List API

![project-img](./.github/cover.jpg)

[![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](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 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
```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 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
```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 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
```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 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"
```

### πŸ“‚ Structure
```
β”‚ docs/
β”‚ └── ...
β”‚ httpie/
β”‚ └── ...
β”‚ src/
β”‚ β”œβ”€β”€ middlewares/
β”‚ β”‚ └── ...
β”‚ β”œβ”€β”€ utils/
β”‚ β”‚ └── ...
β”‚ └── ...
```

### 🧰 Technologies
#### Build Tools
[![Node.js](https://img.shields.io/badge/Node.js-339933?style=for-the-badge&logo=nodedotjs&logoColor=white)](https://nodejs.org/)

#### Testing
[![HTTPie](https://img.shields.io/badge/HTTPie-000?style=for-the-badge&logo=httpie&logoColor=white)](https://httpie.io/)

### πŸ‘€ Author


Marcelo Alvarez GitHub profile picture

Marcelo Alvarez


Front-end Developer

"Some AI generated funny quote here πŸ˜—"


LinkedIn


Portfolio


### πŸ“„ License
Licensed under [MIT](./LICENSE)