npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@fgiova/fastify-sqs-sns-publisher

v2.0.0

Published

A fastify plugin for publishing messages to SQS and SNS

Downloads

7

Readme

fastify SQS/SNS publisher plugin

NPM version CI workflow TypeScript

Description

This plugin for fastify 4.x allows you to publish messages to AWS SQS queues and SNS topics, using a simple interface.

Warning To use this plugin, you must have correctly configured your AWS credentials.

Install

npm i @fgiova/fastify-sqs-sns-publisher

Usage

const fastify = require("fastify")()
const fastifySqsSnsPublisher = require("@fgiova/fastify-sqs-sns-publisher");
app.register(fastifySqsSnsPublisher, {
    sqs: {
        region: "eu-central-1",
    },
    sns: {
        region: "eu-central-1",
    },
});

// publish simple message to SQS
app.messageToSQS({message:"test-sqs"}, "arn:aws:sqs:eu-central-1:000000000000:test-queue");

// publish batch message to SQS (not limited to 10 messages)
app.messagesBatchToSQS([{message:"test-sqs-1"}, {message:"test-sqs-2"}], "arn:aws:sqs:eu-central-1:000000000000:test-queue");

// publish delayed message to SQS (delay in seconds)
app.delayedMessageToSQS({message:"test-sqs"}, "test-queue", 10);

// publish batch delayed message to SQS (delay in seconds and not limited to 10 messages)
app.delayedBatchToSQS([{message:"test-sqs-1"}, {message:"test-sqs-2"}], "arn:aws:sqs:eu-central-1:000000000000:test-queue", 10);

// publish simple message to SNS
app.messageToSNS({message:"test-sns"}, "arn:aws:sns:eu-central-1:000000000000:test-topic");

// publish batch message to SNS (not limited to 10 messages)
app.messagesBatchToSNS([{message:"test-sns-1"}, {message:"test-sns-2"}], "arn:aws:sns:eu-central-1:000000000000:test-topic");

You can also send messages with attributes using the message creation class PublisherMessage:

const fastify = require("fastify")()
const fastifySqsSnsPublisher = require("@fgiova/fastify-sqs-sns-publisher");
const {PublisherMessage} = require("@fgiova/fastify-sqs-sns-publisher");
app.register(fastifySqsSnsPublisher, {
    sqs: {
        region: "eu-central-1",
    },
    sns: {
        region: "eu-central-1",
    },
});

// publish simple message to SQS
app.messageToSQS(new PublisherMessage({message:"test-sqs"}, {attr1: "value1"}), "arn:aws:sqs:eu-central-1:000000000000:test-queue");

// publish batch message to SQS (not limited to 10 messages)
app.messagesBatchToSQS([new PublisherMessage({message:"test-sqs-1"}, {attr1: "value1"}), new PublisherMessage({message:"test-sqs-2"}, {attr1: "value1"})], "arn:aws:sqs:eu-central-1:000000000000:test-queue");

// publish delayed message to SQS (delay in seconds)
app.messageToSQS(new PublisherMessage({message:"test-sqs"}, {attr1: "value1"}, 10),"arn:aws:sqs:eu-central-1:000000000000:test-queue");

// publish batch delayed message to SQS (delay in seconds and not limited to 10 messages)
app.messagesBatchToSQS([new PublisherMessage({message:"test-sqs-1"}, {attr1: "value1"}, 5), new PublisherMessage({message:"test-sqs-2"}, {attr1: "value1"}, 10)], "arn:aws:sqs:eu-central-1:000000000000:test-queue");

// publish simple message to SNS
app.messageToSNS(new PublisherMessage({message:"test-sns"}, {attr1: "value1"}), "arn:aws:sns:eu-central-1:000000000000:test-topic");

// publish batch message to SNS (not limited to 10 messages)
app.messagesBatchToSNS([new PublisherMessage({message:"test-sns-1"}, {attr1: "value1"}), new PublisherMessage({message:"test-sns-2"}, {attr1: "value1"})], "arn:aws:sns:eu-central-1:000000000000:test-topic");

The PublisherMessage support the following attributes:

| Attribute type | Message Type | |----------------|--------------| | string | SQS or SNS | | number | SQS or SNS | | string[] | SNS |

Options

| Option | Type | Description | |---------------|--------|--------------------------------------------------------------------------------------------| | sqs | object | SQS configuration | | sqs.region | string | AWS Region (mandatory) | | sqs.endpoint | string | The SQS endpoint to use. | | sns | object | SNS configuration | | sns.region | string | AWS Region (mandatory) | | sns.endpoint | string | The SNS endpoint to use. | | undiciOptions | object | Undici Pool configuration options | | signer | object | Signer instance configuration or Signer options |

License

Licensed under MIT.

Acknowledgements

This project is kindly sponsored by: isendu Srl www.isendu.com