This toy api has four endpoints for performing CRUD operations on a user resource. A user has the following shape:
{
// The first name of the user
firstName: string;
// The last name of the user
lastName: string;
// The job the user has
jobTitle: string;
// The user's height in cm
height: number;
}
npm run start
Will start the server on localhost:7000
. You can then send
http requests to it by using GET http://localhost:7000/users
, etc.
GET /users
- returns the list of users saved in the database
POST /user
- Creates a new user and adds it to the database
- expects the following to be in the request body:
{ firstName: string; lastName: string; jobTitle: string; age: number; }
PATCH /user/:userId
- Edits the user with id
userId
. It will update the user to have the attributes you send in the request body. - expects the following to be in the request body:
{ firstName: string; lastName: string; jobTitle: string; age: number; }
- Edits the user with id
DELETE /user/:userId
- Deletes a user with id
userId
from the database
- Deletes a user with id