@aasaanjobs/notifications-js-sdk 中文文档教程
Javascript Aasaanjobs Notifications SDK
所有需要触发通知的微服务都应该导入这个库
Installation
npm install @aasaanjobs/notifications-js-sdk
Configuration
你需要在你的项目中设置以下环境变量
SQS_ACCESS_KEY
: The AWS SQS access keySQS_SECRET_KEY
: The AWS S3 access keyHUB_SQS_QUEUE_URL
: Notification Hub SQS Queue Name
Usage
Send an Email
let emailHub = new Email({
sendTo: 'sohel.tarir@aasaanjobs.com',
templateUrl: 'https://s3-ap-southeast-1.amazonaws.com/aasaan-notifications/notifications-prod/empty-html-email.html',
handlebars: {
html_data: '<html>Hello World</html>'
},
subject: 'Testing my new library.'
},
{
accessKey: process.env.SQS_ACCESS_KEY,
secretKey: process.env.SQS_SECRET_KEY,
queueUrl: process.env.HUB_SQS_QUEUE_URL
});
emailHub.send();
Send a SMS
let hub = new SMS({
sendTo: '8698009017',
templateUrl: 'https://s3-ap-southeast-1.amazonaws.com/aasaan-notifications/notifications-prod/empty-html-email.html',
handlebars: {
html_data: 'Some Testing SMS'
},
logOnly: true
}, {
accessKey: process.env.SQS_ACCESS_KEY,
secretKey: process.env.SQS_SECRET_KEY,
queueUrl: process.env.HUB_SQS_QUEUE_URL
});
hub.send();
Javascript Aasaanjobs Notifications SDK
All microservices which need to trigger notifications should import this library
Installation
npm install @aasaanjobs/notifications-js-sdk
Configuration
You need to set the following environment variables in your project
SQS_ACCESS_KEY
: The AWS SQS access keySQS_SECRET_KEY
: The AWS S3 access keyHUB_SQS_QUEUE_URL
: Notification Hub SQS Queue Name
Usage
Send an Email
let emailHub = new Email({
sendTo: 'sohel.tarir@aasaanjobs.com',
templateUrl: 'https://s3-ap-southeast-1.amazonaws.com/aasaan-notifications/notifications-prod/empty-html-email.html',
handlebars: {
html_data: '<html>Hello World</html>'
},
subject: 'Testing my new library.'
},
{
accessKey: process.env.SQS_ACCESS_KEY,
secretKey: process.env.SQS_SECRET_KEY,
queueUrl: process.env.HUB_SQS_QUEUE_URL
});
emailHub.send();
Send a SMS
let hub = new SMS({
sendTo: '8698009017',
templateUrl: 'https://s3-ap-southeast-1.amazonaws.com/aasaan-notifications/notifications-prod/empty-html-email.html',
handlebars: {
html_data: 'Some Testing SMS'
},
logOnly: true
}, {
accessKey: process.env.SQS_ACCESS_KEY,
secretKey: process.env.SQS_SECRET_KEY,
queueUrl: process.env.HUB_SQS_QUEUE_URL
});
hub.send();