An open API service indexing awesome lists of open source software.

https://github.com/ileriayo/dockerised-usermanager

Deploy NodeJS and MogoDB to Docker Containers
https://github.com/ileriayo/dockerised-usermanager

docker docker-compose mongodb nodejs

Last synced: 3 months ago
JSON representation

Deploy NodeJS and MogoDB to Docker Containers

Awesome Lists containing this project

README

          

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

# Dockerised User Manager

This repository contains a simple demo API built with NodeJS.
The API is used to manage users in a MongoDB database.
Both the NodeJS API and MongoDB database are deployed to Docker

### Development
This application was developed using [ExpressJS](http://expressjs.com/). MongoDB was used for persisting data with [Mongoose](https://mongoosejs.com/) as [ORM](https://en.wikipedia.org/wiki/Object-relational_mapping).

### Setup
* Ensure that you have `docker`, `docker compose`, `node`, and `mongoDB` installed and running properly on your PC.
* Open `Docker Quickstart Terminal` to start docker machine.
* First make a note of the ip that docker is configured to use. You can also use the command `docker-machine ip` to check for the ip.
* Clone the repository by entering the following command in the terminal.
`git clone https://github.com/Ileriayo/Dockerised-Usermanager.git`
* Navigate to the project folder using `cd Dockerised-Usermanager` in the terminal.
* Run the script in the directory with the command `start Script.sh` .
* From your browser, navigate to `http://:3000/users` .

### 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:
```x-form-url-encoded
name: John Doe
email: john.doe@gmail.com
password: johndoe
```

###### HTTP Response

- HTTP Status: `201: created`
- JSON data
```json
{
"_id": "59071791b0lkscm2325794",
"name": "John Doe",
"email": "john.doe@gmail.com",
"password": "johndoe",
"__v": 0
}
```

###### GET HTTP Response
- `GET` /users

```json
[
{
"_id": "59071791b0lkscm2325794",
"name": "John Doe",
"email": "john.doe@gmail.com",
"password": "johndoe",
"__v": 0
}
]
```

###### GET HTTP Response
- `GET` /users/:id

```json
{
"_id": "59071791b0lkscm2325794",
"name": "John Doe",
"email": "john.doe@gmail.com",
"password": "johndoe",
"__v": 0
}
```

###### DELETE HTTP Response
- `DELETE` /users/:id

```json
User John Doe was deleted
```

###### POST HTTP Request
- `PUT` /users/:id
- INPUT:
```x-form-url-encoded
name: Jane Doe
email: jane.doe@gmail.com
password: janedoe
```

###### HTTP Response

- HTTP Status: `200: OK`
- JSON data
```json
{
"_id": "59071791b0lkscm2325794",
"name": "Jane Doe",
"email": "jane.doe@gmail.com",
"password": "janedoe",
"__v": 0
}
```

### Author(s)
**Ileriayo Adebiyi [Docker]** - Software Developer

**Olajide Bolaji 'Nuel [NodeJS API]** - Software Developer at Andela