Skip to content

Commit

Permalink
feat!: transitioning to ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasgriffintn committed Mar 12, 2024
1 parent 392e921 commit babec51
Show file tree
Hide file tree
Showing 25 changed files with 749 additions and 773 deletions.
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",
};
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ Visit [https://bbc.github.io/sqs-consumer/](https://bbc.github.io/sqs-consumer/)
## Usage
```js
import { Consumer } from 'sqs-consumer';
import { Consumer } from "sqs-consumer";
const app = Consumer.create({
queueUrl: 'https://sqs.eu-west-1.amazonaws.com/account-id/queue-name',
queueUrl: "https://sqs.eu-west-1.amazonaws.com/account-id/queue-name",
handleMessage: async (message) => {
// do some work with `message`
}
},
});
app.on('error', (err) => {
app.on("error", (err) => {
console.error(err.message);
});
app.on('processing_error', (err) => {
app.on("processing_error", (err) => {
console.error(err.message);
});
Expand Down Expand Up @@ -75,32 +75,32 @@ 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 { Consumer } from 'sqs-consumer';
import { SQSClient } from '@aws-sdk/client-sqs';
import { Consumer } from "sqs-consumer";
import { SQSClient } from "@aws-sdk/client-sqs";
const app = Consumer.create({
queueUrl: 'https://sqs.eu-west-1.amazonaws.com/account-id/queue-name',
queueUrl: "https://sqs.eu-west-1.amazonaws.com/account-id/queue-name",
handleMessage: async (message) => {
// ...
},
sqs: new SQSClient({
region: 'my-region',
region: "my-region",
credentials: {
accessKeyId: 'yourAccessKey',
secretAccessKey: 'yourSecret'
}
})
accessKeyId: "yourAccessKey",
secretAccessKey: "yourSecret",
},
}),
});
app.on('error', (err) => {
app.on("error", (err) => {
console.error(err.message);
});
app.on('processing_error', (err) => {
app.on("processing_error", (err) => {
console.error(err.message);
});
app.on('timeout_error', (err) => {
app.on("timeout_error", (err) => {
console.error(err.message);
});
Expand Down
111 changes: 47 additions & 64 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "sqs-consumer",
"version": "9.1.0",
"description": "Build SQS-based Node applications without the boilerplate",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"engines": {
Expand All @@ -15,7 +16,7 @@
"test:unit": "mocha --recursive --full-trace --exit",
"pretest:integration:init": "npm run build",
"test:integration:init": "sh ./test/scripts/initIntTests.sh",
"test:integration": "npm run test:integration:init && cucumber-js --config ./test/config/cucumber.js",
"test:integration": "npm run test:integration:init && cucumber-js --config ./test/config/cucumber.mjs",
"test": "npm run test:unit && npm run test:integration",
"coverage": "c8 mocha && c8 report --reporter=html && c8 report --reporter=json-summary",
"lcov": "c8 mocha && c8 report --reporter=lcov",
Expand Down Expand Up @@ -140,13 +141,13 @@
"@types/node": "^20.11.25",
"@types/sinon": "^17.0.3",
"c8": "^9.1.0",
"chai": "^4.3.10",
"chai": "5.1.0",
"conventional-changelog-conventionalcommits": "^7.0.2",
"eslint": "^8.57.0",
"eslint-config-iplayer": "^9.2.0",
"eslint-config-prettier": "^9.1.0",
"mocha": "^10.3.0",
"p-event": "^4.2.0",
"p-event": "6.0.1",
"prettier": "^3.2.5",
"semantic-release": "^23.0.2",
"sinon": "^17.0.1",
Expand All @@ -163,8 +164,13 @@
"@aws-sdk/client-sqs": "^3.529.1"
},
"mocha": {
"extensions": [
"ts"
],
"spec": "test/tests/**/**/*.test.ts",
"require": "ts-node/register"
"node-option": [
"loader=ts-node/esm"
]
},
"c8": {
"include": [
Expand All @@ -173,9 +179,6 @@
"extension": [
".ts"
],
"require": [
"ts-node/register"
],
"sourceMap": true,
"instrument": true
},
Expand Down
2 changes: 1 addition & 1 deletion src/bind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @param value the value of the property
*/
function isMethod(propertyName: string, value: any): boolean {
return propertyName !== 'constructor' && typeof value === 'function';
return propertyName !== "constructor" && typeof value === "function";
}

/**
Expand Down
Loading

0 comments on commit babec51

Please sign in to comment.