Skip to content

Commit

Permalink
feat: updating to esm (#117)
Browse files Browse the repository at this point in the history
* feat: updating deps

* chore: uodating mocha update

* chore: wrong directory

* chore: uodating update types

* chore: updating to esm

* fix: eslint command
  • Loading branch information
nicholasgriffintn authored Jan 8, 2025
1 parent e461bf0 commit 0395a2e
Show file tree
Hide file tree
Showing 17 changed files with 3,029 additions and 3,044 deletions.
8 changes: 8 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@ coverage/
.nyc_output/
test
public
.nyc_output
scripts
.github
.prettierignore
.prettierrc.js
jsr.json
typdoc.json
eslint.config.js
8 changes: 5 additions & 3 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module.exports = {
/** @type {import("prettier").Config} */

export const config = {
singleQuote: true,
arrowParens: 'always',
trailingComma: 'none'
arrowParens: "always",
trailingComma: "none",
};
62 changes: 31 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ Visit [https://bbc.github.io/sqs-producer/](https://bbc.github.io/sqs-producer/)
## Usage

```js
import { Producer } from 'sqs-producer';
import { SQSClient } from '@aws-sdk/client-sqs';
import { Producer } from "sqs-producer";
import { SQSClient } from "@aws-sdk/client-sqs";

// create simple producer
const producer = Producer.create({
queueUrl: 'https://sqs.eu-west-1.amazonaws.com/account-id/queue-name',
region: 'eu-west-1'
queueUrl: "https://sqs.eu-west-1.amazonaws.com/account-id/queue-name",
region: "eu-west-1",
});

// send messages to the queue
await producer.send(['msg1', 'msg2']);
await producer.send(["msg1", "msg2"]);

// get the current size of the queue
const size = await producer.queueSize();
Expand All @@ -45,28 +45,28 @@ console.log(`There are ${size} messages on the queue.`);
// send a message to the queue with a specific ID (by default the body is used as the ID)
await producer.send([
{
id: 'id1',
body: 'Hello world'
}
id: "id1",
body: "Hello world",
},
]);

// send a message to the queue with
// - delaySeconds (must be an number contained within 0 and 900)
// - messageAttributes
await producer.send([
{
id: 'id1',
body: 'Hello world with two string attributes: attr1 and attr2',
id: "id1",
body: "Hello world with two string attributes: attr1 and attr2",
messageAttributes: {
attr1: { DataType: 'String', StringValue: 'stringValue' },
attr2: { DataType: 'Binary', BinaryValue: new Buffer('binaryValue') }
}
attr1: { DataType: "String", StringValue: "stringValue" },
attr2: { DataType: "Binary", BinaryValue: new Buffer("binaryValue") },
},
},
{
id: 'id2',
body: 'Hello world delayed by 5 seconds',
delaySeconds: 5
}
id: "id2",
body: "Hello world delayed by 5 seconds",
delaySeconds: 5,
},
]);

// send a message to a FIFO queue
Expand All @@ -79,10 +79,10 @@ await producer.send([
//
// https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queue-recommendations.html
await producer.send({
id: 'testId',
body: 'Hello world from our FIFO queue!',
groupId: 'group1234',
deduplicationId: 'abcdef123456' // typically a hash of the message body
id: "testId",
body: "Hello world from our FIFO queue!",
groupId: "group1234",
deduplicationId: "abcdef123456", // typically a hash of the message body
});
```

Expand All @@ -98,24 +98,24 @@ export AWS_ACCESS_KEY_ID=...
If you need to specify your credentials manually, you can use a pre-configured instance of the [SQS Client](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-sqs/classes/sqsclient.html) client.

```js
import { Producer } from 'sqs-producer';
import { SQSClient } from '@aws-sdk/client-sqs';
import { Producer } from "sqs-producer";
import { SQSClient } from "@aws-sdk/client-sqs";

// create simple producer
const producer = Producer.create({
queueUrl: 'https://sqs.eu-west-1.amazonaws.com/account-id/queue-name',
region: 'eu-west-1',
queueUrl: "https://sqs.eu-west-1.amazonaws.com/account-id/queue-name",
region: "eu-west-1",
sqs: new SQSClient({
region: 'my-region',
region: "my-region",
credentials: {
accessKeyId: 'yourAccessKey',
secretAccessKey: 'yourSecret'
}
})
accessKeyId: "yourAccessKey",
secretAccessKey: "yourSecret",
},
}),
});

// send messages to the queue
await producer.send(['msg1', 'msg2']);
await producer.send(["msg1", "msg2"]);
```

## Development
Expand Down
13 changes: 13 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import eslintConfigESLint from "eslint-config-eslint";

export default [
...eslintConfigESLint,
{
ignores: ["node_modules", "coverage", "bake-scripts", "dist"],
},
{
rules: {
"new-cap": "off",
},
},
];
Loading

0 comments on commit 0395a2e

Please sign in to comment.