You can run the example by following these steps:
-
- Install Dependencies
npm install
-
- Set Environment Variables
Create a
.env
file in the root directory of the project and add the following environment variables:
- Set Environment Variables
Create a
DB_URI=
PORT=5000
-
- Start the Server
npm run dev
-
Method: POST
-
URL:
http://localhost:5000/users
-
Body: (JSON)
{ "name": "John Doe", "email": "[email protected]", "age": 30 }
- Method: GET
- URL:
http://localhost:5000/users
- Method: GET
- URL:
http://localhost:5000/users/{id}
- Replace
{id}
with the actual user ID obtained from the create user response.
-
Method: PUT
-
URL:
http://localhost:5000/users/{id}
-
Body: (JSON)
{ "name": "Jane Doe", "email": "[email protected]", "age": 25 }
- Method: DELETE
- URL:
http://localhost:5000/users/{id}
- Replace
{id}
with the actual user ID obtained from the create user response.