A microservice for sending email.
- nodejs - typescript
- nodemailer npm package
- mailtrap
- update the config file
.env.example
to use actual value. - rename
/env.example
to.env
. - Install all the dependencies.
$ npm install
- To start the program.
$ npm start
-
Upon successfully start the program, you should see below messages in the terminal
-
If good, then use the snippet below for testing. It should return response message
Success
.
curl --location --request POST 'localhost:6011/v1/test/my/register/verify' \
--header 'Content-Type: application/json' \
--header 'Cookie: _auth_verification=%7B%22nonce%22%3A%22mdtZwdfYO9DCCPngN5xdPjTSXGZB3Ux4Z3Wi-9YBa6E%22%2C%22state%22%3A%22eyJyZXR1cm5UbyI6Ii9wcm9maWxlIn0%22%7D.a8UpEEWhgu3uAogRf_H4V3l54fotQ0KeIcDAmxFjxlo; skipSilentLogin=true' \
--data-raw '{
"to": "panda@email.com",
"subject": "This is email content",
"userRole": "ADMIN",
"type": "VERIFY_OTP"
}'
- To run the test, use command
npm run test
.
Architecture diagram
Due to time constraint, there are few more features not implemented properly, such as email template, role based authorization as well as the structure.