UNPKG

@studyportals/sp-r2d2

Version:

A framework that contains various components used when developing projects that will be deployed via AWS λ.

38 lines 1.63 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.SNSAdapter = void 0; const client_sns_1 = require("@aws-sdk/client-sns"); class SNSAdapter { get client() { if (!this._client) { this._client = new client_sns_1.SNSClient(); } return this._client; } sendDataMessage(topicArn, data) { return __awaiter(this, void 0, void 0, function* () { const command = new client_sns_1.PublishCommand({ Message: JSON.stringify(data), TopicArn: topicArn, }); try { yield this.client.send(command); } catch (err) { console.error(`An error occurred when attempting to publish message to ${topicArn}: `, err); throw err; } }); } } exports.SNSAdapter = SNSAdapter; //# sourceMappingURL=sns-adapter.class.js.map