@aasaanjobs/notifications-js-sdk 中文文档教程

发布于 6年前 浏览 20 项目主页 更新于 3年前

Javascript Aasaanjobs Notifications SDK npm version

所有需要触发通知的微服务都应该导入这个库

Installation

npm install @aasaanjobs/notifications-js-sdk

Configuration

你需要在你的项目中设置以下环境变量

  • SQS_ACCESS_KEY: The AWS SQS access key
  • SQS_SECRET_KEY: The AWS S3 access key
  • HUB_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 npm version

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 key
  • SQS_SECRET_KEY: The AWS S3 access key
  • HUB_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();
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文