an api for the storage of projects and their tasks. applied all the main concepts of nodejs and express.
MIT License
A application to storage projects and their tasks using Express.
Apply all the main concepts of NodeJS and Express. How to use global/local middlewares, how to do a CRUD (Create, Read, Update, Delete) and learn the behavior of the requests and responses.
POST /projects
: This route receives the id and title in the body of the request. Creating a project like this format: { id: "1", title: 'NewProject', tasks: [] }
;
GET /projects
: This route list all the projects storaged
PUT /projects/:id
: This route update a project, receiving the id
as a route param and the title
in the request body.
DELETE /projects/:id
: This route delete a project, receiving the id
of the specific project as a route param.
POST /projects/:id/tasks
: This route add a task in the project. For this, the id
of the project is passed as a route param and the title
of the task is passed in the request body.
If i call the route POST /projects
passing { id: 1, title: 'AirHealth' }
e a rota POST /projects/1/tasks
com { title: 'Fix errors' }
, the array of projects should be like this:
[
{
id: "1",
title: "AirHealth",
tasks: ["Fix errors"]
}
];
projectsQuantity
: This's a global middleware responsable for (console.log
) the current count of storaged projects.
requestsQuantity
: This's a global middleware responsable for (console.log
) the current
count of requests made to the api.
verifyId
: This's a local middleware responsable for the verification if the id passed as a param has a project related to it. If not, will return a error with status 404 (Bad Request)
, but if the project exists, the middleware will permit the request to continue normally.
Crie um middleware global chamado em todas requisições que imprime (console.log
) uma contagem de quantas requisições foram feitas na aplicação até então;
MIT Licence. See the file LICENSE for more details.
Made with ♥ by Laura 👋 See my linkedin!