Simple scaffolding for applications that produce SQS messages
Installations
npm install sqs-producer
Score
55.1
Supply Chain
100
Quality
84.1
Maintenance
100
Vulnerability
99.6
License
Developer
Developer Guide
Module System
CommonJS
Min. Node Version
>=18.0.0
Typescript Support
Yes
Node Version
20.17.0
NPM Version
10.8.2
Statistics
207 Stars
226 Commits
51 Forks
36 Watching
17 Branches
93 Contributors
Updated on 31 Oct 2024
Languages
TypeScript (99.58%)
JavaScript (0.42%)
Total Downloads
Cumulative downloads
Total Downloads
15,996,964
Last day
-3.3%
28,008
Compared to previous day
Last week
4.1%
155,305
Compared to previous week
Last month
7.5%
655,857
Compared to previous month
Last year
35.3%
6,449,539
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Peer Dependencies
1
Dev Dependencies
26
sqs-producer
Enqueues messages onto a given SQS queue.
Installation
To install this package, enter the following command into your terminal (or the variant of whatever package manager you are using):
npm install sqs-producer
Node Version
We will only support Node versions that are actively or security supported by the Node team. If you are still using an Node 14, please use a version of this library before the v3.2.1 release, if you are using Node 16, please use a version before the v3.3.0 release.
Documentation
Visit https://bbc.github.io/sqs-producer/ for the full API documentation.
Usage
1import { Producer } from 'sqs-producer'; 2import { SQSClient } from '@aws-sdk/client-sqs'; 3 4// create simple producer 5const producer = Producer.create({ 6 queueUrl: 'https://sqs.eu-west-1.amazonaws.com/account-id/queue-name', 7 region: 'eu-west-1' 8}); 9 10// send messages to the queue 11await producer.send(['msg1', 'msg2']); 12 13// get the current size of the queue 14const size = await producer.queueSize(); 15console.log(`There are ${size} messages on the queue.`); 16 17// send a message to the queue with a specific ID (by default the body is used as the ID) 18await producer.send([ 19 { 20 id: 'id1', 21 body: 'Hello world' 22 } 23]); 24 25// send a message to the queue with 26// - delaySeconds (must be an number contained within 0 and 900) 27// - messageAttributes 28await producer.send([ 29 { 30 id: 'id1', 31 body: 'Hello world with two string attributes: attr1 and attr2', 32 messageAttributes: { 33 attr1: { DataType: 'String', StringValue: 'stringValue' }, 34 attr2: { DataType: 'Binary', BinaryValue: new Buffer('binaryValue') } 35 } 36 }, 37 { 38 id: 'id2', 39 body: 'Hello world delayed by 5 seconds', 40 delaySeconds: 5 41 } 42]); 43 44// send a message to a FIFO queue 45// 46// note that AWS FIFO queues require two additional params: 47// - groupId (string) 48// - deduplicationId (string) 49// 50// deduplicationId can be excluded if content-based deduplication is enabled 51// 52// https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queue-recommendations.html 53await producer.send({ 54 id: 'testId', 55 body: 'Hello world from our FIFO queue!', 56 groupId: 'group1234', 57 deduplicationId: 'abcdef123456' // typically a hash of the message body 58});
Credentials
By default the consumer will look for AWS credentials in the places specified by the AWS SDK. The simplest option is to export your credentials as environment variables:
1export AWS_SECRET_ACCESS_KEY=... 2export AWS_ACCESS_KEY_ID=...
If you need to specify your credentials manually, you can use a pre-configured instance of the SQS Client client.
1import { Producer } from 'sqs-producer'; 2import { SQSClient } from '@aws-sdk/client-sqs'; 3 4// create simple producer 5const producer = Producer.create({ 6 queueUrl: 'https://sqs.eu-west-1.amazonaws.com/account-id/queue-name', 7 region: 'eu-west-1', 8 sqs: new SQSClient({ 9 region: 'my-region', 10 credentials: { 11 accessKeyId: 'yourAccessKey', 12 secretAccessKey: 'yourSecret' 13 } 14 }) 15}); 16 17// send messages to the queue 18await producer.send(['msg1', 'msg2']);
Development
Test
1npm test
Coverage
For coverage report, run the command:
1npm run coverage
Lint
To check for problems using ESLint
1npm run lint
Contributing
We welcome and appreciate contributions for anyone who would like to take the time to fix a bug or implement a new feature.
But before you get started, please read the contributing guidelines and code of conduct.
License
SQS Producer is distributed under the Apache License, Version 2.0, see LICENSE for more information.
No vulnerabilities found.
Reason
no vulnerabilities detected
Reason
tokens are read-only in GitHub workflows
Reason
license file detected
Details
- Info: : LICENSE:1
Reason
no dangerous workflow patterns detected
Reason
all dependencies are pinned
Details
- Info: GitHub-owned GitHubActions are pinned
- Info: Third-party GitHubActions are pinned
- Info: Dockerfile dependencies are pinned
- Info: no insecure (not pinned by hash) dependency downloads found in Dockerfiles
- Info: no insecure (not pinned by hash) dependency downloads found in shell scripts
Reason
no binaries found in the repo
Reason
update tool detected
Details
- Info: Dependabot detected
Reason
GitHub code reviews found for 11 commits out of the last 30 -- score normalized to 3
Details
- Warn: no reviews found for commit: ad36540bbf973c3938995eafe897ea97dbc2b192
- Warn: no reviews found for commit: df353154276499a82c043df9204b9dbc2b638f4b
- Warn: no reviews found for commit: 33f627e63e8d8b777152520be5eee94a3328d48c
- Warn: no reviews found for commit: 44707d448f487d9bcf415c87391852b95c518dc6
- Warn: no reviews found for commit: 192abd63b8af07c5b0f06575b91870e9129093af
- Warn: no reviews found for commit: 6c02383ec3c9c5e53a39cac7c433aca096f94460
- Warn: no reviews found for commit: 181dbacf51084c9357f0d0f7f678e55ea88d0b38
- Warn: no reviews found for commit: a24ff4117d1a28099c8f5515ae7c0815ceb3a69a
- Warn: no reviews found for commit: 1d8b5e8b072fbfaf951bc7c1261f3b1db5156dc7
- Warn: no reviews found for commit: e8620d46ad28bd798cfbec574eb80bad60ffbdc2
- Warn: no reviews found for commit: de7d7ddded2114adf07d1f513e5b0d81ccfa4954
- Warn: no reviews found for commit: a8acbd5be330fec49213ec0dff742a639e0d47c6
- Warn: no reviews found for commit: 738908e52fe6d9421c4e9bb42c3200ccf005ae43
- Warn: no reviews found for commit: aadef8d34e54637ba28c2239690e2e8bf9e004e7
- Warn: no reviews found for commit: 28fcc5adb4309010755385e587cd71a55f72dfa8
- Warn: no reviews found for commit: 08fb072ac9335611c3db790a570a76a3c96157f5
- Warn: no reviews found for commit: 6d724c9adcd9287325c4e41647015bf85434f2c2
- Warn: no reviews found for commit: cb92988b124d3a04830fa03823229ef33cbb509d
- Warn: no reviews found for commit: 42672c121175db5297b28300f07bb38e1997addf
Reason
0 commit(s) out of 30 and 0 issue activity out of 28 found in the last 90 days -- score normalized to 0
Reason
no badge detected
Reason
security policy file not detected
Reason
project is not fuzzed
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
6
/10
Last Scanned on 2022-08-15
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to sqs-producer
@devplace/sqs-producer
Devplace SQS producer lib
@ssut/nestjs-sqs
[![Test](https://github.com/ssut/nestjs-sqs/workflows/Test/badge.svg)](https://github.com/ssut/nestjs-sqs/actions?query=workflow%3ATest) [![npm version](https://badge.fury.io/js/%40ssut%2Fnestjs-sqs.svg)](https://badge.fury.io/js/%40ssut%2Fnestjs-sqs)
sqs-producer-2
Enqueues messages onto a given SQS queue
@aws-sdk/client-sqs
AWS SDK for JavaScript Sqs Client for Node.js, Browser and React Native