Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
sqs-producer
Advanced tools
The sqs-producer npm package is a simple library for sending messages to an AWS SQS (Simple Queue Service) queue. It provides a straightforward API for creating and sending messages, making it easier to integrate SQS into your Node.js applications.
Create a Producer
This feature allows you to create a producer instance that is configured to send messages to a specific SQS queue. You need to provide the queue URL and the AWS region.
const { Producer } = require('sqs-producer');
const producer = Producer.create({
queueUrl: 'https://sqs.us-east-1.amazonaws.com/account-id/queue-name',
region: 'us-east-1'
});
Send a Single Message
This feature allows you to send a single message to the SQS queue. You need to provide a message ID and the message body.
producer.send({
id: 'id1',
body: 'Hello SQS!'
}, (err) => {
if (err) console.error(err);
else console.log('Message sent successfully');
});
Send Multiple Messages
This feature allows you to send multiple messages in a single batch to the SQS queue. You need to provide an array of messages, each with a unique ID and message body.
producer.send([{
id: 'id1',
body: 'Hello SQS!'
}, {
id: 'id2',
body: 'Hello again!'
}], (err) => {
if (err) console.error(err);
else console.log('Messages sent successfully');
});
Send Messages with Delay
This feature allows you to send a message to the SQS queue with a delay. You need to provide the message ID, message body, and the delay in seconds.
producer.send({
id: 'id1',
body: 'Hello SQS!',
delaySeconds: 10
}, (err) => {
if (err) console.error(err);
else console.log('Message sent successfully with delay');
});
The aws-sdk package is the official AWS SDK for JavaScript. It provides comprehensive support for all AWS services, including SQS. While it is more feature-rich and supports a wider range of AWS services, it is also more complex to use compared to sqs-producer.
The sqs-consumer package is a library for consuming messages from an AWS SQS queue. It is designed to work in conjunction with sqs-producer, providing a simple API for receiving and processing messages. While sqs-producer focuses on sending messages, sqs-consumer focuses on receiving them.
The node-sqs package is another library for interacting with AWS SQS. It provides a simple API for sending and receiving messages, similar to sqs-producer. However, it is less popular and less actively maintained compared to sqs-producer.
Enqueues messages onto a given SQS queue
npm install BBC/sqs-producer --save
var Producer = require('sqs-producer');
var producer = Producer.create({
queueUrl: 'https://sqs.eu-west-1.amazonaws.com/account-id/queue-name',
region: 'eu-west-1'
});
producer.send(['msg1', 'msg2'], function(err) {
if (err) console.log(err);
});
npm test
For coverage report, run the command:
npm run coverage
To check for problems using JSLint
npm run lint
FAQs
Enqueues messages onto a given SQS queue
The npm package sqs-producer receives a total of 123,537 weekly downloads. As such, sqs-producer popularity was classified as popular.
We found that sqs-producer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.