Microservices demo
There is an exposed api (POST /email) to send an email. Under the hood, two different private microservices respond to email requests, each using a different email service for extra reliability.
POST /email
{
"to": [ "[email protected]" ],
"cc": "[email protected]",
"bcc": "[email protected]",
"subject": "hello world!!",
"from": "[email protected]",
"text": "What a wonderful world"
}
Run the following commands:
git clone https://github.com/MichaelMcKavanagh/emailer.git
cd emailer
npm install
Make sure you have the following environment variables set:
MAILGUN_API_KEY
MAILGUN_DOMAIN
SENDINBLUE_V2_API_KEY
For a single instance of each service you can just do:
docker-compose up
However, you can optionally scale up multiple email service instances. Example below:
docker-compose up --scale email-mailgun-service=3 --scale email-sendinblue-service=3
Other useful commands:
docker-compose down
docker-compose build
Run unit tests:
npm test
Run integration tests (These will only pass if the app is running locally, ie docker-compose up):
npm run test:integration
Unified logging files (error.log and combined.log) are available within the logger service, but currently you'll have to exec into the service to see them.
Currently the way to deploy the app is just to have docker-compose up running on the server with the appropriate environment variables set, and have port 80 publically exposed.
Michael McKavanagh [email protected]