[   About the Challenge   |   Solution Proposal   |   Challenges    ]
Create an application that stores your projects and tasks using the Express framework.
-
POST /projects
: This route should receiveid
andtitle
inside the body and record a new project into the projects array following this pattern:{ id: "1", title: 'New project', tasks: [] }
; -
GET /projects
: This route should list all projects and its tasks; -
PUT /projects/:id
: This route should update the projecttitle
based on itsid
; -
DELETE /projects/:id
: This route should delete the project based on itsid
; -
POST /projects/:id/tasks
: This route should receive atitle
and store a new task intotasks
array;
If you call the POST /projects
route passing { id: 1, title: 'New project' }
and then the route POST /projects/1/tasks
with { title: 'New task' }
, the result should be an array of projects like this:
[
{
id: "1",
title: "New project",
tasks: ["New task"]
}
];
-
Create a middleware that will be used in all routes that receive the project
id
into the URL parameters (akaroute params
) that verifies if the project exists. If it does not exist, an error must be returned; otherwise, the flow must continue (next); -
Create a global middleware that will be called on all requests and print a counter that contains the total requests so far;