Applications with node and express.
This application is for save projects and tasks in a array.
-
POST /projects
: The route receiveid
andtitle
and a body with this format:{ id: "1", title: 'Novo projeto', tasks: [] }
; -
GET /projects
: show all the projects; -
PUT /projects/:id
: change only the title from project withid
that there is in the params; -
DELETE /projects/:id
: delete a project withid
that there is in the params; -
POST /projects/:id/tasks
: receive atitle
and save one new task in the array from tasks. The project is withid
in the params;
If i call the route POST /projects
passing { id: 1, title: 'New project' }
and the route POST /projects/1/tasks
with { title: 'New Task' }
, my array stay:
[
{
id: "1",
title: 'New Project',
tasks: ['New Task']
}
]
-
Local middleware for find the project passed in the params. If not exists the api return error, if not return the respost ;
-
Global middleware called in all the requests (
console.log
) count de number of requests;