Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shuvro/movies-node-docker-mongodb-microservices
https://github.com/shuvro/movies-node-docker-mongodb-microservices
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/shuvro/movies-node-docker-mongodb-microservices
- Owner: shuvro
- Created: 2022-03-15T15:41:25.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-03-15T18:06:04.000Z (over 2 years ago)
- Last Synced: 2023-03-01T20:16:23.818Z (over 1 year ago)
- Language: JavaScript
- Size: 2.88 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# movies-node-docker-mongodb-microservices
## Prerequisites
You need to have `docker` and `docker-compose` installed on your computer to run the service
## Run locally
1. Clone this repository
1. Run from root dir```
docker-compose up -d
```## Services at PORTS
- auth service will start on port `3000`
- movie service will start on port `3001`
- mongodb will start on port `27018`To stop the service run
```
docker-compose down
```## ENV variables
All the environment variables are set from .env file under following locations
- auth-service/.env
- movie-service/.env
- .env## Users
The auth service defines two user accounts that you should use
1. `Basic` user
```
username: 'basic-thomas'
password: 'sR-_pcoow-27-6PAwCD8'
```1. `Premium` user
```
username: 'premium-jim'
password: 'GBLtTyq3E_UNjFnpo9m6'
```## Token payload
Decoding the auth token will give you access to basic information about the
user, including its role.```
{
"userId": 123,
"name": "Basic Thomas",
"role": "basic",
"iat": 1606221838,
"exp": 1606223638,
"iss": "https://www.netguru.com/",
"sub": "123"
}
```## Example request
To authorize user call the auth service using for example `curl`. We assume
that the auth service is running of the default port `3000`.Request
```
curl --location --request POST '0.0.0.0:3000/auth' \
--header 'Content-Type: application/json' \
--data-raw '{
"username": "basic-thomas",
"password": "sR-_pcoow-27-6PAwCD8"
}'
```Response
```
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjEyMywibmFtZSI6IkJhc2ljIFRob21hcyIsInJvbGUiOiJiYXNpYyIsImlhdCI6MTYwNjIyMTgzOCwiZXhwIjoxNjA2MjIzNjM4LCJpc3MiOiJodHRwczovL3d3dy5uZXRndXJ1LmNvbS8iLCJzdWIiOiIxMjMifQ.KjZ3zZM1lZa1SB8U-W65oQApSiC70ePdkQ7LbAhpUQg"
}
```## Movie Service
Base URL: `http://localhost:3001/`
# POST
endpoint: `http://localhost:3001/movies`
method: `POST`payload:
```
{
"title": "a beautiful mind"
}
```headers:
```
Authorization: Bearer
```# GET
endpoint: `http://localhost:3001/movies`
method: `GET`headers:
```
Authorization: Bearer
```