Simple project for learning how to make REST APIs with express js using a mongodb database.
-
clone the repo
-
Set up
.env
file, all the necessary environment variables can be found in.env.example
-
Install the dependencies using the command:
$ npm install
-
Run the server locally:
$ npm run devStart
-
Home page
-
Method: GET
-
Endpoint: http://localhost:3000/
-
-
Create user
-
Method: POST
-
Endpoint: http://localhost:3000/users
-
Request Body format:
{ "name": "John Doe", // required "has_a_job": true, // optional "date_employed": "2022-02-15" // optional }
-
-
Get list of user
-
Method: GET
-
Endpoint: http://localhost:3000/users
-
-
Get User details
-
Method: GET
-
Endpoint: http://localhost:3000/users/:userId
-
-
Delete User
-
Method: DELETE
-
Endpoint: http://localhost:3000/users/:userId
-
-
Update User details
-
Method: PATCH
-
Request Body format:
{ "name": "John Doe", // optional "has_a_job": true, // optional "date_employed": "2022-02-15" // optional }
-
Endpoint: http://localhost:3000/users/:userId
-