JonathanItakpe / UserManager

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

License: MIT

User Manager

This repository contains a simple demo API built with NodeJS. The API is used to manage users in a MongoDB database.

Development

This application was developed using ExpressJS. MongoDB was used for persisting data with Mongoose as ORM.

Installation

  • Start up your terminal (or Command Prompt on Windows OS).
  • Clone the repository by entering the command git clone https://github.com/JonathanItakpe/UserManager in the terminal.
  • Navigate to the project folder using cd UserManager on your terminal (or command prompt).
  • Run cp app/.env-sample app/.env - Creates a .env file in the app folder and copies the content of .env-sample into it
  • Install Docker
  • Verify you have Docker Compose Installed (Windows and Mac users most likely do) by running docker-compose from your terminal. You should get a bunch of Information and Help text.
  • If you get an error message, you need to install Docker Compose
  • Build the docker image and start the containers by running docker-compose up from the UserManager folder on your terminal (or command prompt) -- PS: Could take a while
  • Test the app by hitting the endpoints below using the base url. 127.0.0.1:49863
  • To view the mongodb data -- use the host: 127.0.0.1 and port 27045 in your mongo client -- Robo3T or Mongodb Compass should do

API Documentation

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 HTTP Request
  • POST /users
  • INPUT:
name: John Doe
email: john.doe@gmail.com
password: johndoe
HTTP Response
  • HTTP Status: 201: created
  • JSON data
{
  "_id": "59071791b0lkscm2325794",
  "name": "John Doe",
  "email": "john.doe@gmail.com",
  "password": "johndoe",
  "__v": 0
}
GET HTTP Response
  • GET /users
[
    {
        "_id": "59071791b0lkscm2325794",
        "name": "John Doe",
        "email": "john.doe@gmail.com",
        "password": "johndoe",
        "__v": 0
    }
]
GET HTTP Response
  • GET /users/:id
{
    "_id": "59071791b0lkscm2325794",
    "name": "John Doe",
    "email": "john.doe@gmail.com",
    "password": "johndoe",
    "__v": 0
}
DELETE HTTP Response
  • DELETE /users/:id
User John Doe was deleted
POST HTTP Request
  • PUT /users/:id
  • INPUT:
name: Jane Doe
email: jane.doe@gmail.com
password: janedoe
HTTP Response
  • HTTP Status: 200: OK
  • JSON data
{
  "_id": "59071791b0lkscm2325794",
  "name": "Jane Doe",
  "email": "jane.doe@gmail.com",
  "password": "janedoe",
  "__v": 0
}

Author

Olajide Bolaji 'Nuel - Software Developer at Andela

About


Languages

Language:JavaScript 100.0%