Skip to content

security-log/test-mongodb-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API test

Run Locally 💻

Configuration

You need a .env file. Use .env.dist as a template.

Dependencies

You need a MongoDB instance running.

  sudo systemctl start mongod

Check status.

  sudo systemctl status mongod

You must install npm packages from package.json.

  npm i

Run

Use start script from package.json.

  npm start

Usage/Examples 📔

These commands can be executed in the terminal, or you can use an alternative like Postman.

Add a user

curl -X POST http://localhost:3000/api/users \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Jhon",
    "lastName": "Doe",
    "color": "red",
    "email": "[email protected]",
    "dni": "143996799",
    "age": 27,
    "enabled": true
  }'

Get a list of users

curl -X GET http://localhost:3000/api/users

Disable a user

curl -X POST http://localhost:3000/api/users/<user_id>/disable \
  -H "Content-Type: application/json"

Retrieve information for a user

url -X GET http://localhost:3000/api/users/<user_id>

Modify user information

curl -X PUT http://localhost:3000/api/users/<user_id> \
  -H "Content-Type: application/json" \
  -d '{"email": "[email protected]"}'

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published