@fgiova/mini-sns-client
v1.2.0
Published
[![NPM version](https://img.shields.io/npm/v/@fgiova/mini-sns-client.svg?style=flat)](https://www.npmjs.com/package/@fgiova/mini-sns-client) ![CI workflow](https://github.com/fgiova/mini-sns-client/actions/workflows/node.js.yml/badge.svg) [![TypeScript](h
Downloads
9
Readme
mini sns client using undici
Description
This module allows minimal set of SNS service functions using "undici" as http agent. The @fgiova/aws-signature module is used for signing requests to optimize performance.
Are supported:
- publish messages
Installation
npm install @fgiova/mini-sns-client
Usage
import {MiniSNSClient} from '@fgiova/mini-sns-client'
import console = require("console");
const client = new MiniSNSClient("eu-central-1");
await client.publishMessage({
TopicArn: "arn:aws:sns:eu-central-1:000000000000:test",
Message: "Hello World!",
MessageAttributes: {
"my-attribute": {
DataType: "String",
StringValue: "my-value"
}
}
});
await client.publishMessageBatch({
TopicArn: "arn:aws:sns:eu-central-1:000000000000:test",
PublishBatchRequestEntries: [
{
Id: "31afb534-e25e-5812-a92f-e8ff0921f9dd",
Message: "Hello World!",
MessageAttributes: {
"my-attribute": {
DataType: "String",
StringValue: "my-value"
}
}
},
{
Id: "85565b18-6ad4-5ba5-89b2-06d381ab1a6a",
Message: "Hello World! Again",
}
]
});
API
MiniSNSClient(region: string, endpoint?: string, undiciOptions?: Pool.Options, signer?: Signer | SignerOptions)
MiniSNSClient.publishMessage(message: PublishMessage): Promise<PublishMessageResult>
MiniSNSClient.publishMessageBatch(message: PublishBatchMessage): Promise<PublishMessageBatchResult>
MiniSNSClient.destroy(signer: boolean): Promise<boolean> // signer destroyer default true
All types are defined in schemas.ts and are derived from the AWS SNS API The main difference is that batch operations are not limited to 10 items, but accept any number of items and provide for running the batches needed to exhaust the total number of items.
License
Licensed under MIT.