Powered by Courier
This template demonstrates how to make a simple HTTP API Endpoint with Node.js running on AWS Lambda and API Gateway using the Serverless Framework to send notifications.
- Sign up for Courier account.
- Install and configure one of the many supported providers:
- Grab your Courier API Key from settings.
- Set the API Key value in the
COURIER_AUTH_TOKEN
environment variable.- In this example app it's done by storing it in AWS SSM Parameter Store
CORS is enabled by default to allow requests from any origin, so that you can test the application by making requests from any client-side app. You should limit the allowed origins to your own domain when using this on production.
$ serverless deploy
After deploying, you should see output similar to:
Deploying aws-node-notifications to stage dev (us-east-1)
✔ Service deployed to stack aws-node-notifications-dev (152s)
endpoint: POST
- https://xxxxxxxxxx.execute-api.us-east-1.amazonaws.com/
functions:
notify: aws-node-notifications-dev-notify (1.9 kB)
After successful deployment, you can call the created application via HTTP:
curl --request POST \
--url https://xxxxxxx.execute-api.us-east-1.amazonaws.com/ \
--data '
{
"message": {
"to": {
"email": "[email protected]",
},
"content": {
"title": "Hello",
"body": "World"
}
}
}
'
See the Courier Send API docs for the supported request body formats.
You can invoke your function locally by using the following command:
serverless invoke local --function notify