This is just a POC for Typescript first trial, so it is not deployed. This API is supposed to simulate a to do app server, that allows different end users to insert tasks, check or uncheck them as done, delete them and check either all tasks or someone's tasks.
This project was developed using Node.js along with express and Typescript and PostgreSQL for database
This app requires Node.js and PostgreSQL to work properly (besides the packages and libs installed and listed in the package.json file)
In order to set up the app to run it locally, follow these steps:
- Clone the repository
- Install all dependencies
npm i
- Create a .env file and fill information based in the .env.example file (you can use localhost for the POSTGRES_HOST)
- Create a database in Postgres connection
- Populate the database by running the commands within dump.sql file
In order to run it locally, run:
npm run dev
GET /tasks/
HTTP/1.1 200 OK
Status: 200 OK
data: [
{
"id": 1,
"name": "wash dishes",
"description": "wash all dishes",
"deadline": "20/11/2022",
"responsible_id": 1,
"responsible": "Gabriel",
"done": false
},
{
"id": 2,
"name": "Play cards",
"description": "play cards with friends",
"deadline": "tomorrow",
"responsible_id": 3,
"responsible": "Lucas",
"done": false
}
]
GET /tasks/:responsibleId
HTTP/1.1 200 OK
Status: 200 OK
data: [
{
"id": 1,
"name": "wash dishes",
"description": "wash all dishes",
"deadline": "20/11/2022",
"responsible_id": 1,
"responsible": "Gabriel",
"done": false
},
{
"id": 2,
"name": "Play cards",
"description": "play cards with friends",
"deadline": "tomorrow",
"responsible_id": 1,
"responsible": "Gabriel",
"done": false
}
]
POST /tasks/
Body:
{
"name": "Play cards",
"description": "play cards with friends",
"deadline": "2022/11/20"
}
Header (the Authentication header will be the username+123, can be gabriel, lucas or pedro):
{
"Authentication": "Bearer gabriel123"
}
HTTP/1.1 201 CREATED
Status: 201 CREATED
data: "Task inserted with id 4"
PATCH /tasks/:taskId
Header (the Authentication header will be the username+123, can be gabriel, lucas or pedro):
{
"Authentication": "Bearer gabriel123"
}
HTTP/1.1 202 ACCEPTED
Status: 202 ACCEPTED
DELETE /tasks/:taskId
Header (the Authentication header will be the username+123, can be gabriel, lucas or pedro):
{
"Authentication": "Bearer gabriel123"
}
HTTP/1.1 204 NO CONTENT
Status: 204 NO CONTENT