This is a CRUD of a table of users. The API was wrtten in TypeScript and it used NodeJS and MongoDB, frameworks Express, Mongoose and jest. It does not have authentication.
After cloning this repository, install all dependences.
npm install
Make sure you have MongoDB Compass in your machine. Then create a new Schema called 'users'. Then use the command below to start the application.
npm run start
Use Postman or other app to access the api.
The command "npm run test" is going to show the unit tests of the API.
{
"name": "name", //string
"email": "[email protected]", //string
"age": 50 //number
}
POST http://localhost:3000/users
Content-Type: application/json
{
"name": "joao",
"email": "[email protected]",
"age": 50
}
{message: "user created Successfully"}
{
"name": "name", //string
"email": "[email protected]", //string
"age": 50 //number
}
PATCH http://localhost:3000/users/abc123
Content-Type: application/json
{
"name": "joao",
"email": "[email protected]",
"age": 50
}
{message: "user updated Successfully"}
POST http://localhost:3000/users/abc123
Content-Type: application/json
[
{
"_id": "610d1f18fc5c452184878d85",
"name": "joao",
"email": "[email protected]",
"age": "50",
"id": "abc123",
"__v": 0
}
]
GET http://localhost:3000/users
Content-Type: application/json
[
{
"_id": "610d1f18fc5c452184878d85",
"name": "joao",
"email": "[email protected]",
"age": "50",
"id": "abc123",
"__v": 0
},
{
"_id": "610d1f18fc5c452111516",
"name": "maria",
"email": "[email protected]",
"age": "50",
"id": "def456",
"__v": 0
}
]
DELETE http://localhost:3000/users/abc123
Content-Type: application/json
{message: "User deleted successfully"}