This simple email api service is build by using Serverless framework and will be deployed to AWS lambda service.
- Install NodeJs version v14.x
Clone the repository:
git clone https://github.com/kenttan0214/node-simple-email-api
Install dependencies:
cd node-simple-email-api
npm install
Putting together necessary configurations:
Refer to .env-cmdrc.example, update the fields accordingly
Setup local env config:
cp .env-cmdrc.example .env-cmdrc
Start local instance:
npm start
To run the email API
curl --location --request POST 'http://localhost:3000/test/email' \
--header 'Content-Type: application/json' \
--data-raw '{
"subject": "test email subject",
"content": "simple email content",
"recipients": ["foo@example.com"]
}'
npm test
npm run lint
npm run format
.
├── src
│ ├── __mock__ # Unit test mock fuctions & data
│ ├── handler # API Schema and Response layer
│ ├── helper # The actual execution and a layer to connect with API, data, model and util ...
│ └── type # Typescript type definitions
│ └── util # Generic util functions
│ └── middleware # Middy middleware
└── ...
- Use nodemailer test account as demo of the send email capability instead of using any of the email provider SMTP server such as Gmail.
- The email content is plant text just enough for demo the use case, actual case might need html formatting template
- Actual use case should consider use AWS SES this kind of service to ease the maintainability
- Unit test coverage is only collect from helper and handler for show case purpose
- No deployment setup as this will need to create an AWS account