This is a Node.js API implemented with Typescript to allow users to perform CRUD (Create, Read, Update, and Delete) operations on a user resource.
- Nodejs
- Mongodb
- NPM
- Clone the repository: git clone https://github.com/wilfredcloud/node-user-crud-api.git
- Install dependencies: npm install
- Create a .env file and add the following variables:
MONGO_DB_URL=<your-mongodb-uri>
AUTH_SECRET=<enter-secret>
PORT=5000
- Start the server: npm start
- The API will be available at http://localhost:5000
The following endpoints are available:
Creates a new user. Requires a JSON body with the following fields:
- email (string): the name of the user
- name (string): the email address of the user
- password (string): the password of the user
Request body
{
"email": "[email protected]",
"name": "winner",
"password": "123"
}
Returns a list of all users.
Response Data
[
{
"_id": "643c92b03c58bff91f88f440",
"name": "Peter",
"email": "[email protected]",
"__v": 0
},
{
"_id": "643c93c93c58bff91f88f44b",
"name": "winner",
"email": "[email protected]",
"__v": 0
}
]
Updates a user with the specified ID. It Requires a JSON body with the name field.
- name (string): the updated name of the user Request body
{
"name": "Victory"
}
Deletes a user with the specified ID.
License
This project is licensed under the MIT License.