This project provides a Node.js-based service for processing orders and sending notifications based on order value.
order and manager).git clone <REPO_URL>
cd <PROJECT_FOLDER>
npm install
Call the main function with parameters:
const params = { from: "FROM_EMAIL", to: "TO_EMAIL", subject: "Test Subject", content: "Email content here" };
main(params)
.then(response => console.log(response))
.catch(error => console.error(error));
Replace <SENDGRID_API_KEY>, <FROM_EMAIL>, and <TO_EMAIL> in the code with actual values.
Export required environment variables and invoke the service using cURL:
export TYPE='Content-Type: application/json'
export AUTH='Authorization: Basic '`bx wsk property get --auth | awk '{printf("%s", $3)}' | base64 `
export NAMESPACE=<OW_NAMESPACE>
export API_ENDPOINT=<API_ENDPOINT>
curl -k -s -X POST -d '{"from": "FROM_EMAIL_ID", "to": "TO_EMAIL_ID","subject":"OpenWhisk Alert","content":"Hello from Serverless"}' -H "$TYPE" -H "$AUTH" https://$API_ENDPOINT/api/v1/namespaces/$NAMESPACE/actions/sendMail?blocking=true
Below is the package.json configuration for the project:
{
"name": "sendgrid",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"sendgrid": "file:",
"uuid": "3.0.1"
},
"author": "",
"license": "ISC"
}
This project is licensed under the MIT License.