1.0.2 • Published 7 months ago
cloud-messaging-toolkit v1.0.2
SNS Messaging Toolkit
This wrapper provides a abstract function to publish a message to AWS SNS topic with very minimal configuration. All you have to do is - install this package and import the function publishToSNS() in your file and pass the required parameters. You can refer the example below to learn more about the configuration.
Table of Contents
Getting Started
These instructions will help you set up the project on your local machine for development and testing purposes.
Prerequisites
- Node.js (version 14 or later)
- AWS SD with BigQuery and BigQuery Storage API enabled
- AWS Account with SNS access (for deployment)
Installation
- Run command:
npm i sns-messaging-toolkit
Payload Format
The following is an example payload for big qeury. It contains the necessary product_id, bqConfig, awsConfig and data fields that must be included to insert data successfully into BigQuery.
const params = {
bqConfig: {
project_id: "pass-big-qeury-project-id",
dataset_id: "pass-big-qeury-dataset-id",
table_id: "pass-big-qeury-table-id",
},
payload: {
product_id: "your-product-id",
data: [
{
"anydata that you want to insert into BigQuery",
},
],
},
awsConfig: {
subject: "Write your subject ",
topicArn: "pass-your-sns-topic-arn:aws:",
messageGroupId: "pass-id",
region: "pass-your-aws-topic-region",
},
};
Test Cases
Run the test cases using below command:
npm run test
Use it in your project
const {publishToSNS} = require('sns-messaging-toolkit')
const params = {
bqConfig: {
project_id: "pass-big-qeury-project-id",
dataset_id: "pass-big-qeury-dataset-id",
table_id: "pass-big-qeury-table-id",
},
payload: {
product_id: "your-product-id",
data: [
{
"anydata that you want to insert into BigQuery",
},
],
},
awsConfig: {
subject: "Write your subject ",
topicArn: "pass-your-sns-topic-arn:aws:",
messageGroupId: "pass-id",
region: "pass-your-aws-topic-region",
},
}
publishToSNS(params);