This repository contains a simple demo API built with NodeJS. The API is used to manage users in a MongoDB database.
This application was developed using ExpressJS. MongoDB was used for persisting data with Mongoose as ORM.
node
installed on your PC.git clone https://github.com/BolajiOlajide/UserManager
in the terminal.cd UserManager
on your terminal (or command prompt)npm install
..env
file in your root directory as described in .env.sample
file. Variables such as DB_URL (which must be a mongoDB URL) and PORT are defined in the .env file and it is essential you create this file before running the application.PORT=3000
DB_URL='mongodb://username:password@db_host:27017/databaseName'
npm start
.To ensure that your installation is successful you'll need to run tests.
The command: npm test
makes this possible. It isn't functional right now, but once it's done you'll be notified via the README.
The API only has one endpoint which is the /users
endpoint for saving users to the database. The endpoint works with the HTTP verbs: POST
, GET
, PUT
, DELETE
.
POST
/usersname: John Doe
email: [email protected]
password: johndoe
201: created
{
"_id": "59071791b0lkscm2325794",
"name": "John Doe",
"email": "[email protected]",
"password": "johndoe",
"__v": 0
}
GET
/users[
{
"_id": "59071791b0lkscm2325794",
"name": "John Doe",
"email": "[email protected]",
"password": "johndoe",
"__v": 0
}
]
GET
/users/:id{
"_id": "59071791b0lkscm2325794",
"name": "John Doe",
"email": "[email protected]",
"password": "johndoe",
"__v": 0
}
DELETE
/users/:idUser John Doe was deleted
PUT
/users/:idname: Jane Doe
email: [email protected]
password: janedoe
200: OK
{
"_id": "59071791b0lkscm2325794",
"name": "Jane Doe",
"email": "[email protected]",
"password": "janedoe",
"__v": 0
}
Olajide Bolaji 'Nuel - Software Developer at Andela