sqs-consumer 6.0.0-alpha.1 → 6.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sqs-consumer",
3
- "version": "6.0.0-alpha.1",
3
+ "version": "6.0.0-alpha.2",
4
4
  "description": "Build SQS-based Node applications without the boilerplate",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,2 +0,0 @@
1
- # All changes should be reviewed by codeowners
2
- * @bbc/ibl @bbc/detl-engineers
@@ -1,74 +0,0 @@
1
- # Contributor Covenant Code of Conduct (CoC)
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
-
7
- We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
-
9
- ## Our Standards
10
-
11
- Examples of behaviour that contributes to a positive environment for our community include:
12
-
13
- - Respect different opinions, perspectives, and experiences
14
- - Giving and appreciating constructive feedback
15
- - Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
16
- - Focusing on what is best for us as individuals and the overall community
17
- - Demonstrating kindness toward other people
18
-
19
- Examples of unacceptable behaviour include:
20
-
21
- - The use of sexualised language or imagery, and sexual attention or advances of any kind
22
- - Trolling, insulting or derogatory comments, and personal or political attacks
23
- - Public or private harassment
24
- - Publishing others’ private information, such as a physical or email address, without their explicit permission
25
- - Other conduct which could reasonably be considered inappropriate in a professional setting
26
-
27
- ## Enforcement Responsibilities
28
-
29
- Project maintainers are responsible for clarifying and enforcing our standards of acceptable behaviour and will take appropriate and fair corrective action in response to any behaviour that they deem inappropriate, threatening, offensive, or harmful.
30
-
31
- Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
32
-
33
- ## Scope
34
-
35
- This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
36
-
37
- ## Enforcement
38
-
39
- Instances of abusive, harassing, or otherwise unacceptable behaviour may be reported to the community leaders responsible for enforcement. All complaints will be reviewed and investigated promptly and fairly.
40
-
41
- [Project maintainers](https://github.com/bbc/sqs-consumber/blob/main/.github/CODEOWNERS) are obligated to respect the privacy and security of the reporter of any incident.
42
-
43
- ## Enforcement Guidelines
44
-
45
- ### 1. Correction
46
-
47
- Community Impact: Use of inappropriate language or other behaviour deemed unprofessional or unwelcome in the community.
48
-
49
- Consequence: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behaviour was inappropriate. A public apology may be requested.
50
-
51
- ### 2. Warning
52
-
53
- Community Impact: A violation through a single incident or series of actions.
54
-
55
- Consequence: A warning with consequences for continued behaviour. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
56
-
57
- ### 3. Temporary Ban
58
-
59
- Community Impact: A serious violation of community standards, including sustained inappropriate behaviour.
60
-
61
- Consequence: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
62
-
63
- ### 4. Permanent Ban
64
-
65
- Community Impact: Demonstrating a pattern of violation of community standards, including sustained inappropriate behaviour, harassment of an individual, or aggression toward or disparagement of classes of individuals.
66
-
67
- Consequence: A permanent ban from any sort of public interaction within the community.
68
-
69
- ## Attribution
70
-
71
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at [https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][version]
72
-
73
- [homepage]: https://contributor-covenant.org
74
- [version]: https://www.contributor-covenant.org/version/2/0/code_of_conduct/
@@ -1,41 +0,0 @@
1
- # Contributing
2
-
3
- Thank you for your interest in contributing to the sqs-consumer.
4
-
5
- - If you're unsure if a feature would make a good addition, you can always [create an issue](https://github.com/bbc/sqs-consumer/issues/new) first. Raising an issue before creating a pull request is recommended.
6
- - We aim for 100% test coverage. Please write tests for any new functionality or changes.
7
- - Any API changes should be fully documented.
8
- - Make sure your code meets our linting standards. Run `npm run lint` to check your code.
9
- - Maintain the existing coding style. There are some settings in `.jsbeautifyrc` to help.
10
- - Be mindful of others when making suggestions and/or code reviewing.
11
-
12
- ## Reporting Issues
13
-
14
- Before opening a new issue, first check that there is not already an [open issue or Pull Request](https://github.com/bbc/sqs-consumer/issues?utf8=%E2%9C%93&q=is%3Aopen) that addresses it.
15
-
16
- If there is, make relevant comments and add your reaction. Use a reaction in place of a "+1" comment:
17
-
18
- - 👍 - upvote
19
- - 👎 - downvote
20
-
21
- If you cannot find an existing issue that describes your bug or feature, create a new issue using the guidelines below.
22
-
23
- 1. Pick an appropriate template for the type of issue [from here](https://github.com/bbc/sqs-consumer/issues/choose)
24
- 2. Provide as much detail as possible
25
- 3. Follow your issue in the issue tracking workflow
26
-
27
- ## Contributing Code
28
-
29
- If you do not have push access to the repository, please [fork it](https://help.github.com/en/articles/fork-a-repo). You should then work on your own `main` branch.
30
-
31
- Otherwise, you may clone this repository and create a working branch with a _kebab-case_ name reflecting what you are working on (e.g. `fix-the-thing`).
32
-
33
- Follow the setup instructions in the [README](../README.md).
34
-
35
- Ensure all your code is thoroughly tested and that this testing is detailed in the pull request.
36
-
37
- ## Pull Request Process
38
-
39
- 1. Make sure you have opened an issue and it was approved by a project maintainer before working on a PR
40
- 2. Read and complete all relevant sections of the PR template
41
- 3. Wait for the PR get approved
@@ -1,27 +0,0 @@
1
- ---
2
- name: Bug report
3
- about: Create a report to help us improve
4
- title: ''
5
- labels: bug
6
- assignees: ''
7
- ---
8
-
9
- **Describe the bug**
10
- A clear and concise description of what the bug is.
11
-
12
- **To Reproduce**
13
- Steps to reproduce the behaviour:
14
-
15
- 1. Go to '...'
16
- 2. Select '....'
17
- 3. Scroll down to '....'
18
- 4. See error
19
-
20
- **Expected behaviour**
21
- A clear and concise description of what you expected to happen.
22
-
23
- **screenshots**
24
- If applicable, add screenshots to help explain your problem.
25
-
26
- **Additional context**
27
- Add any other context about the problem here, such as specific device information.
@@ -1,19 +0,0 @@
1
- ---
2
- name: Feature request
3
- about: Suggest an idea for this project
4
- title: ''
5
- labels: feature-request
6
- assignees: ''
7
- ---
8
-
9
- **The problem**
10
- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
11
-
12
- **Suggested solution**
13
- A clear and concise description of what you want to happen.
14
-
15
- **Alternatives considered**
16
- A clear and concise description of any alternative solutions or features you've considered.
17
-
18
- **Additional context**
19
- Add any other context or screenshots about the feature request here.
@@ -1,16 +0,0 @@
1
- ---
2
- name: Technical question
3
- about: Want to ask a technical question about the project
4
- title: ''
5
- labels: question
6
- assignees: ''
7
- ---
8
-
9
- **Question**
10
- A clear technical question could be asked here.
11
-
12
- **screenshots**
13
- If applicable, add screenshots to help explain your question.
14
-
15
- **Additional context**
16
- Add any other context about the question here, such as specific device information, technology choice etc.
@@ -1,9 +0,0 @@
1
- # Security Policy
2
-
3
- ## Reporting a Vulnerability
4
-
5
- Our full security policy and vulnerability reporting procedure is documented on [this external website](https://www.bbc.com/backstage/security-disclosure-policy/#reportingavulnerability).
6
-
7
- Please note that this is a general BBC process. Communication will not be direct with the team responsible for this repo.
8
-
9
- If you would like to, you can also open an issue in this repo regarding your disclosure, but please never share any details of the vulnerability in the GitHub issue.
@@ -1,29 +0,0 @@
1
- Resolves #NUMBER
2
-
3
- **Description:**
4
- _A very high-level summary of easily-reproducible changes that can be understood by non-devs._
5
-
6
- **Type of change:**
7
-
8
- - [ ] Bug fix (non-breaking change which fixes an issue)
9
- - [ ] New feature (non-breaking change which adds functionality)
10
- - [ ] Breaking change (fix or feature that would cause existing functionality to change)
11
-
12
- **Why is this change required?:**
13
- _A simple explanation of what the problem is and how this PR solves it_
14
-
15
- **Code changes:**
16
-
17
- - _A bullet point list of key code changes that have been made._
18
- - _When describing code changes, try to communicate **how** and **why** you implemented something a specific way, not just **what** has changed._
19
-
20
- ---
21
-
22
- **Checklist:**
23
-
24
- - [ ] My code follows the code style of this project.
25
- - [ ] My change requires a change to the documentation.
26
- - [ ] I have updated the documentation accordingly.
27
- - [ ] I have read the **CONTRIBUTING** document.
28
- - [ ] I have added tests to cover my changes.
29
- - [ ] All new and existing tests passed.
@@ -1,35 +0,0 @@
1
- name: Report Coverage
2
- on:
3
- pull_request:
4
- branches:
5
- - 'main'
6
- push:
7
- branches:
8
- - main
9
- permissions:
10
- contents: read
11
-
12
- jobs:
13
- build:
14
- runs-on: ubuntu-latest
15
- strategy:
16
- matrix:
17
- node-version: [14.x]
18
-
19
- steps:
20
- - uses: actions/checkout@v3
21
-
22
- - name: Use Node.js ${{ matrix.node-version }}
23
- uses: actions/setup-node@v3
24
- with:
25
- node-version: ${{ matrix.node-version }}
26
-
27
- - name: Install Node Modules
28
- run: npm ci
29
-
30
- - name: Report Coverage
31
- uses: paambaati/codeclimate-action@v3.2.0
32
- env:
33
- CC_TEST_REPORTER_ID: 2d851f8f3a9348ac4f43262305037f80a730c2660fda50af8ae4d445fd89333b
34
- with:
35
- coverageCommand: npm run lcov
@@ -1,20 +0,0 @@
1
- name: 'Close stale issues and PRs'
2
- on:
3
- schedule:
4
- - cron: '30 1 * * *'
5
-
6
- jobs:
7
- stale:
8
- runs-on: ubuntu-latest
9
- steps:
10
- - uses: actions/stale@v6
11
- with:
12
- stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.'
13
- stale-pr-message: 'This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.'
14
- close-issue-message: 'This issue was closed because it has been stalled for 5 days with no activity.'
15
- close-pr-message: 'This PR was closed because it has been stalled for 10 days with no activity.'
16
- days-before-issue-stale: 30
17
- days-before-pr-stale: 45
18
- days-before-issue-close: 5
19
- days-before-pr-close: 10
20
- operations-per-run: 90
@@ -1,34 +0,0 @@
1
- name: Run Tests
2
- on:
3
- pull_request:
4
- branches:
5
- - 'main'
6
- push:
7
- branches:
8
- - main
9
- permissions:
10
- contents: read
11
-
12
- jobs:
13
- build:
14
- runs-on: ubuntu-latest
15
- strategy:
16
- matrix:
17
- node-version: [14.x, 16.x, 18.x]
18
-
19
- steps:
20
- - uses: actions/checkout@v3
21
-
22
- - name: Use Node.js ${{ matrix.node-version }}
23
- uses: actions/setup-node@v3
24
- with:
25
- node-version: ${{ matrix.node-version }}
26
-
27
- - name: Install Node Modules
28
- run: npm ci
29
-
30
- - name: NPM Audit
31
- run: npx audit-ci
32
-
33
- - name: Run Tests and Linting
34
- run: npm run test
@@ -1,4 +0,0 @@
1
- declare const express: any;
2
- declare const consumer: any;
3
- declare const producer: any;
4
- declare const expressApp: any;
@@ -1,97 +0,0 @@
1
- const express = require('express');
2
- const { consumer } = require('./utils/consumer');
3
- const { producer } = require('./utils/producer');
4
- const expressApp = express();
5
- expressApp.get('/', (_, res) => {
6
- res.send('Hello! Send me a request to one of my other endpoints to test SQS Consumer!');
7
- });
8
- expressApp.get('/queue-size', async (_, res) => {
9
- // get the current size of the queue
10
- const size = await producer.queueSize();
11
- res.send({
12
- message: 'Queue size retrieved!',
13
- data: size
14
- });
15
- });
16
- expressApp.post('/sample', async (_, res) => {
17
- // send messages to the queue
18
- const messages = await producer.send(['msg1', 'msg2']);
19
- res.send({
20
- message: 'Sample messages sent successfully!',
21
- data: messages
22
- });
23
- });
24
- expressApp.post('/sample-with-id', async (_, res) => {
25
- // send a message to the queue with a specific ID (by default the body is used as the ID)
26
- const messages = await producer.send([
27
- {
28
- id: 'id1',
29
- body: 'Hello world'
30
- }
31
- ]);
32
- res.send({
33
- message: 'Sample messages sent successfully!',
34
- data: messages
35
- });
36
- });
37
- expressApp.post('/sample-with-attributes', async (_, res) => {
38
- // send a message to the queue with
39
- // - messageAttributes
40
- const messages = await producer.send([
41
- {
42
- id: 'id1',
43
- body: 'Hello world with two string attributes: attr1 and attr2',
44
- messageAttributes: {
45
- attr1: { DataType: 'String', StringValue: 'stringValue' },
46
- attr2: { DataType: 'String', StringValue: 'stringValue2' },
47
- }
48
- }
49
- ]);
50
- res.send({
51
- message: 'Sample messages sent successfully!',
52
- data: messages
53
- });
54
- });
55
- expressApp.post('/sample-with-delay', async (_, res) => {
56
- // send a message to the queue with
57
- // - delaySeconds (must be an number contained within 0 and 900)
58
- const messages = await producer.send([
59
- {
60
- id: 'id1',
61
- body: 'Hello world delayed by 5 seconds',
62
- delaySeconds: 5
63
- }
64
- ]);
65
- res.send({
66
- message: 'Sample messages sent successfully!',
67
- data: messages
68
- });
69
- });
70
- expressApp.post('/sample-with-fido', async (_, res) => {
71
- // send a message to a FIFO queue
72
- //
73
- // note that AWS FIFO queues require two additional params:
74
- // - groupId (string)
75
- // - deduplicationId (string)
76
- //
77
- // deduplicationId can be excluded if content-based deduplication is enabled
78
- //
79
- // http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queue-recommendations.html
80
- const messages = await producer.send({
81
- id: 'testId',
82
- body: 'Hello world from our FIFO queue!',
83
- groupId: 'group1234',
84
- deduplicationId: 'abcdef123456' // typically a hash of the message body
85
- });
86
- res.send({
87
- message: 'Sample messages sent successfully!',
88
- data: messages
89
- });
90
- });
91
- expressApp.listen(3026, () => {
92
- // eslint-disable-next-line no-console
93
- console.log('STARTING SQS CONSUMER');
94
- consumer.start();
95
- // eslint-disable-next-line no-console
96
- console.log('EXPRESS APP LISTENING ON: http://localhost:3026');
97
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,63 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const { Consumer } = require('../../../dist/index');
4
- const { QUEUE_URL, sqs } = require('./sqs');
5
- const consumer = Consumer.create({
6
- queueUrl: QUEUE_URL,
7
- sqs,
8
- handleMessage: async (message) => {
9
- // eslint-disable-next-line no-console
10
- console.log('RECEIVED SQS MESSAGE:');
11
- // eslint-disable-next-line no-console
12
- console.log(message);
13
- }
14
- });
15
- consumer.on('error', (err) => {
16
- // eslint-disable-next-line no-console
17
- console.log('RECEIVED SQS ERROR:');
18
- // eslint-disable-next-line no-console
19
- console.error(err.message);
20
- });
21
- consumer.on('processing_error', (err) => {
22
- // eslint-disable-next-line no-console
23
- console.log('RECEIVED SQS PROCESSING ERROR:');
24
- // eslint-disable-next-line no-console
25
- console.error(err.message);
26
- });
27
- consumer.on('timeout_error', (err) => {
28
- // eslint-disable-next-line no-console
29
- console.log('RECEIVED SQS TIMEOUT ERROR:');
30
- // eslint-disable-next-line no-console
31
- console.error(err.message);
32
- });
33
- consumer.on('timeout_error', (err) => {
34
- // eslint-disable-next-line no-console
35
- console.log('RECEIVED SQS TIMEOUT ERROR:');
36
- // eslint-disable-next-line no-console
37
- console.error(err.message);
38
- });
39
- consumer.on('message_received', (message) => {
40
- // eslint-disable-next-line no-console
41
- console.log('RECEIVED SQS MESSAGE:');
42
- // eslint-disable-next-line no-console
43
- console.error(message);
44
- });
45
- consumer.on('message_processed', (message) => {
46
- // eslint-disable-next-line no-console
47
- console.log('RECEIVED SQS MESSAGE PROCESSED:');
48
- // eslint-disable-next-line no-console
49
- console.error(message);
50
- });
51
- consumer.on('response_processed', () => {
52
- // eslint-disable-next-line no-console
53
- console.log('RECEIVED SQS RESPONSE PROCESSED:');
54
- });
55
- consumer.on('stopped', () => {
56
- // eslint-disable-next-line no-console
57
- console.log('RECEIVED SQS STOPPED:');
58
- });
59
- consumer.on('empty', () => {
60
- // eslint-disable-next-line no-console
61
- console.log('RECEIVED SQS EMPTY:');
62
- });
63
- exports.consumer = consumer;
@@ -1 +0,0 @@
1
- export {};
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const { Producer } = require('sqs-producer');
4
- const { QUEUE_URL, sqsConfig, sqs } = require('./sqs');
5
- const producer = Producer.create({
6
- queueUrl: QUEUE_URL,
7
- region: sqsConfig.region,
8
- sqs
9
- });
10
- exports.producer = producer;
@@ -1 +0,0 @@
1
- export {};
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const { Endpoint, SQS } = require('aws-sdk');
4
- const sqsConfig = {
5
- region: 'eu-west-1',
6
- };
7
- if (process.env.SQS_ENDPOINT) {
8
- sqsConfig.endpoint = new Endpoint(process.env.SQS_ENDPOINT);
9
- }
10
- else if (process.env.NODE_ENV === 'development') {
11
- sqsConfig.endpoint = new Endpoint('http://localhost:4566');
12
- }
13
- if (process.env.SQS_ACCESS_KEY_ID) {
14
- sqsConfig.accessKeyId = process.env.SQS_ACCESS_KEY_ID;
15
- }
16
- else if (process.env.NODE_ENV === 'development') {
17
- sqsConfig.accessKeyId = 'na';
18
- }
19
- if (process.env.SQS_SECRET_ACCESS_KEY) {
20
- sqsConfig.secretAccessKey = process.env.SQS_SECRET_ACCESS_KEY;
21
- }
22
- else if (process.env.NODE_ENV === 'development') {
23
- sqsConfig.secretAccessKey = 'na';
24
- }
25
- exports.sqs =
26
- !sqsConfig.endpoint && process.env.NODE_ENV === 'development'
27
- ? null
28
- : new SQS(sqsConfig);
29
- exports.QUEUE_NAME = process.env.SQS_QUEUE_NAME || 'sqs-consumer-data';
30
- exports.QUEUE_URL =
31
- process.env.SQS_QUEUE_URL ||
32
- 'http://localhost:4566/000000000000/sqs-consumer-data';
33
- exports.sqsConfig = sqsConfig;