reference: https://github.com/inversify/inversify-express-example
This repo contains infrustructure to ExpressJS server app with Redis, MongoDB and Inversify for IOC. All are chained with docker compose
Middleware | Reason |
---|---|
body-parser | We need to access the body of a request |
helmet | Adds some protection to the application and removes things like the X-Powered-By header from a request |
winston | Used for logging |
Run the folowing commands:
git clone https://github.com/shlomimo123/Microservices-Infrastructure.git
There is 2 options to use and run this example, The first one is with docker-compose tool and the second is on docker swarm
for docker-compose use this commands:
docker build -t moonshot_web:lastversion .
docker-compose -f "docker-compose.yml" down
docker-compose -f "docker-compose.yml" up -d --build
for docker swarm use this commands:
docker swarm init
docker build -t moonshot_web:lastversion .
docker stack rm prod
docker stack deploy --compose-file=docker-compose-swarm.yml prod
We have to http methods
HTTP | How to use example |
---|---|
POST |
URL http://localhost:8001/Message Body {"firstName":"vvvvvv"} Headerscrossfw-referer:website.com |
GET |
URL http://localhost:8001/Message?domain=website.com&from=2019-05-13T07:16:37.449Z&&until=2019-05-15T07:16:37.449Z&skip=0&limit=0 |
GET |
URL http://localhost:8001/Message/servermonitor |
There is 2 option to scale
if you are using docker-compose for running then use this command:
docker-compose scale web=3
if you are using docker swarm then use:
docker service scale prod_web=3
git clone https://github.com/shlomimo123/Microservices-Infrastructure.git
npm install
Docker-compose down
Docker-compose build
docker-compose up -d mongo
docker-compose up -d redis
ts-node bootstrap
** please notice that now there is no haproxy as reversed proxy, and your server port is 3000
Enjoy ;)