Last active
March 12, 2020 08:05
-
-
Save Mcdavid95/6780e42c08e4b12ac055e5bedb2de24f to your computer and use it in GitHub Desktop.
SES RabbitMQ Tutorial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//const express = require('express'); | |
// import publicMessage from Email service | |
const { publishMessage } = require('./emailWorker') | |
// ......................... | |
// ...app.get | |
/** | |
* @post sensend email | |
*/ | |
app.post('/email', (req, res) => { | |
const { body: { email } } = req; | |
const emailOptions = { | |
mail: [email], | |
subject: 'Email confirmed', | |
template: ` | |
<body> | |
<p>Hi,</p> | |
<p>Thanks for your submission, your email address has been recorder successfully</p> | |
</body> | |
` | |
} | |
// call rabbitmq service to app mail to queue | |
publishMessage(emailOptions); | |
return res.status(202).send({ | |
message: 'Email sent successfully' | |
}) | |
}) | |
// app.listen |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment