Skip to content

Commit 525a3ed

Browse files
authored
V5 - drop old node versions and move to new AWS sdk (#129)
\
1 parent 2774421 commit 525a3ed

30 files changed

+2553
-1527
lines changed

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
strategy:
2323
matrix:
2424
os: [ubuntu-latest, macos-latest, windows-latest]
25-
node-version: [6.x, 8.x, 10.x, 12.x, 14.x, 16.x, 18.x]
25+
node-version: [16.x, 18.x, 19.x]
2626

2727
steps:
2828

@@ -87,7 +87,7 @@ jobs:
8787
strategy:
8888
matrix:
8989
os: [ubuntu-latest]
90-
node-version: [16.x]
90+
node-version: [18.x]
9191
needs: [test]
9292
if: github.event_name == 'release' && github.event.action == 'published'
9393
steps:

.mocharc.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require:
2+
- 'ts-node/register'
3+
- 'source-map-support/register'
4+
- 'src/test/setup.ts'
5+
recursive: true
6+
reporter: 'spec'
7+
exit: true
8+
spec:
9+
- 'src/test/**/*.ts'

.nycrc

-6
This file was deleted.

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
[![Test Coverage](https://api.codeclimate.com/v1/badges/177b18abdb55fdf90cf8/test_coverage)](https://codeclimate.com/github/PruvoNet/squiss-ts/test_coverage)
55
[![Maintainability](https://api.codeclimate.com/v1/badges/177b18abdb55fdf90cf8/maintainability)](https://codeclimate.com/github/PruvoNet/squiss-ts/maintainability)
66
[![Known Vulnerabilities](https://snyk.io/test/github/PruvoNet/squiss-ts/badge.svg?targetFile=package.json)](https://snyk.io/test/github/PruvoNet/squiss-ts?targetFile=package.json)
7-
[![dependencies Status](https://david-dm.org/PruvoNet/squiss-ts/status.svg)](https://david-dm.org/PruvoNet/squiss-ts)
8-
[![devDependencies Status](https://david-dm.org/PruvoNet/squiss-ts/dev-status.svg)](https://david-dm.org/PruvoNet/squiss-ts?type=dev)
97

108
<p align="center">
119
<a href="https://squiss-ts.pruvo.com"><img src="https://github.com/PruvoNet/squiss-ts/blob/docs/source/images/logo.png?raw=true" /></a>
1210
</p>
1311

1412
# Squiss-TS
15-
High-volume Amazon SQS Poller and single-queue client for Node.js 6 and up with full typescript support
13+
High-volume Amazon SQS Poller and single-queue client for Node.js 16 and up with full typescript support
1614
The library is production ready and is being stress used in a full blown production environment
1715

1816
## Main features
@@ -33,8 +31,10 @@ Please see full documentation <a href="https://squiss-ts.pruvo.com">here</a>
3331
import {Squiss, Message} from 'squiss-ts';
3432

3533
const awsConfig = {
36-
accessKeyId: '<accessKeyId>',
37-
secretAccessKey: '<secretAccessKey>',
34+
credentials: {
35+
accessKeyId: 'accessKeyId',
36+
secretAccessKey: 'secretAccessKey',
37+
},
3838
region: '<region>',
3939
};
4040

@@ -58,7 +58,7 @@ const messageToSend = {
5858
a: 1,
5959
b: 2,
6060
},
61-
}
61+
};
6262

6363
const propsToSend = {
6464
p1: 1,

e2e/docker-compose.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: '3'
2+
services:
3+
queue:
4+
image: softwaremill/elasticmq
5+
ports:
6+
- "9324:9324"
7+
- "9325:9325"
8+
9+
s3:
10+
image: scireum/s3-ninja
11+
ports:
12+
- "9000:9000"
13+
environment:
14+
root: elasticmq
15+
initialBuckets: test
16+

e2e/flow.ts

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import {Squiss, Message} from '../src';
2+
import {SQSClientConfig} from '@aws-sdk/client-sqs';
3+
import {S3} from '@aws-sdk/client-s3';
4+
5+
const awsConfig: SQSClientConfig = {
6+
region: 'elasticmq',
7+
endpoint: 'http://localhost:9324',
8+
credentials: {
9+
accessKeyId: 'dummy',
10+
secretAccessKey: 'dummy',
11+
},
12+
};
13+
14+
const s3 = new S3({
15+
endpoint: 'http://localhost:9000/s3',
16+
credentials: {
17+
accessKeyId: 'AKIAIOSFODNN7EXAMPLE',
18+
secretAccessKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',
19+
},
20+
})
21+
22+
const squiss = new Squiss({
23+
awsConfig,
24+
queueName: 'my-sqs-queue',
25+
bodyFormat: 'json',
26+
maxInFlight: 15,
27+
S3: s3,
28+
gzip: true,
29+
minGzipSize: 1,
30+
s3Fallback: true,
31+
s3Bucket: 'test',
32+
minS3Size: 1,
33+
correctQueueUrl: true,
34+
});
35+
36+
(async () => {
37+
await await s3.createBucket({
38+
Bucket: 'test',
39+
});
40+
await squiss.createQueue();
41+
squiss.on('message', async (message: Message) => {
42+
console.log(`${message.body.name} says: ${JSON.stringify(message.body.message)} and has attripute p1 with value ${message.attributes.p1}`);
43+
await message.del();
44+
});
45+
squiss.on('error', (error: Error) => {
46+
console.log(`squiss error`, error);
47+
});
48+
await squiss.start();
49+
50+
const messageToSend = {
51+
name: 'messageName',
52+
message: {
53+
a: 1,
54+
b: 2,
55+
},
56+
};
57+
58+
const propsToSend = {
59+
p1: 1,
60+
p2: 2,
61+
};
62+
63+
await squiss.sendMessage(messageToSend, 0, propsToSend);
64+
})();

package.json

+44-27
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
{
22
"name": "squiss-ts",
3-
"version": "4.4.1",
3+
"version": "5.0.0",
44
"description": "High-volume SQS poller",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
77
"engines": {
8-
"node": "^6 || ^8 || ^10 || ^12 || ^14 || ^16 || ^18"
8+
"node": "^16 || ^18|| ^19"
99
},
1010
"scripts": {
11-
"postinstall": " node -e \"const semver = require('semver');const relevant = semver.lt(process.version, '10.16.0');if (relevant == false) {process.exit(0);}try {require('iltorb'); process.exit(0);} catch (err){process.exit(1);}\" || yarn add --pure-lockfile --ignore-engines [email protected]",
12-
"clean": "rm -rf node_modules build coverage dist",
11+
"clean": "rm -rf .nyc_output coverage dist",
1312
"build": "yarn lint && yarn compile",
1413
"compile": "tsc",
1514
"test": "yarn lint && yarn mocha",
16-
"mocha": "_mocha --opts src/test/mocha.opts",
17-
"cover": "nyc --reporter=lcov --reporter=text-summary npm run mocha",
15+
"cover": "yarn clean && yarn nyc yarn mocha",
1816
"lint": "tslint -c tslint.json \"src/**/*.ts\" \"test/**/*.ts\"",
19-
"benchmark": "tsc --extendedDiagnostics --incremental false"
17+
"benchmark": "tsc --extendedDiagnostics --incremental false",
18+
"e2e:start": "docker compose -f e2e/docker-compose.yml up &",
19+
"e2e:stop": "docker compose -f e2e/docker-compose.yml down &"
2020
},
2121
"repository": {
2222
"type": "git",
@@ -48,34 +48,51 @@
4848
},
4949
"homepage": "https://github.com/PruvoNet/squiss-ts#readme",
5050
"dependencies": {
51-
"aws-sdk": "2.814.0",
51+
"@aws-sdk/client-s3": "^3.310.0",
52+
"@aws-sdk/client-sqs": "^3.310.0",
53+
"@aws-sdk/types": "^3.310.0",
5254
"linked-list": "^2.1.0",
53-
"semver": "6.3.0",
55+
"semver": "7.4.0",
5456
"ts-type-guards": "^0.7.0",
55-
"uuid": "^8.3.2"
57+
"uuid": "^9.0.0"
5658
},
5759
"devDependencies": {
58-
"@istanbuljs/nyc-config-typescript": "0.1.3",
59-
"@types/chai": "^4.2.12",
60-
"@types/chai-as-promised": "^7.1.3",
61-
"@types/iltorb": "^2.3.2",
62-
"@types/mocha": "^8.0.0",
63-
"@types/node": "^14.0.26",
60+
"@istanbuljs/nyc-config-typescript": "1.0.2",
61+
"@types/chai": "^4.3.4",
62+
"@types/chai-as-promised": "^7.1.5",
63+
"@types/mocha": "^10.0.1",
64+
"@types/node": "^14.18.42",
6465
"@types/proxyquire": "^1.3.28",
65-
"@types/semver": "7.3.1",
66-
"@types/uuid": "^8.0.0",
67-
"chai": "^4.2.0",
66+
"@types/semver": "^7.3.13",
67+
"@types/uuid": "^9.0.1",
68+
"chai": "^4.3.7",
6869
"chai-as-promised": "^7.1.1",
69-
"delay": "^4.4.0",
70+
"delay": "^5.0.0",
7071
"dirty-chai": "^2.0.1",
71-
"mocha": "6.2.2",
72-
"nyc": "14.1.1",
72+
"mocha": "^10.2.0",
73+
"nyc": "^15.1.0",
7374
"proxyquire": "^2.1.3",
74-
"sinon": "^7.5.0",
75-
"sinon-chai": "^3.5.0",
76-
"source-map-support": "^0.5.19",
77-
"ts-node": "^8.10.2",
75+
"sinon": "^15.0.3",
76+
"sinon-chai": "^3.7.0",
77+
"source-map-support": "^0.5.21",
78+
"ts-node": "^10.9.1",
7879
"tslint": "^6.1.3",
79-
"typescript": "4.6.4"
80+
"typescript": "^5.0.4"
81+
},
82+
"nyc": {
83+
"extends": "@istanbuljs/nyc-config-typescript",
84+
"check-coverage": true,
85+
"all": true,
86+
"exclude": [
87+
"src/test/**",
88+
"e2e**"
89+
],
90+
"reporter": [
91+
"html",
92+
"lcov",
93+
"text",
94+
"text-summary"
95+
],
96+
"report-dir": "coverage"
8097
}
8198
}

src/EventEmitterTypesHelper.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use strict';
2-
31
// https://github.com/bterlson/strict-event-emitter-types
42

53
declare const assignmentCompatibilityHack: unique symbol;

src/Message.ts

+7-11
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
'use strict';
2-
3-
import * as SQS from 'aws-sdk/clients/sqs'
4-
import * as S3 from 'aws-sdk/clients/s3'
5-
import {AWSError} from 'aws-sdk/lib/error'
1+
import {BatchResultErrorEntry, Message as SQSMessage, SQSServiceException} from '@aws-sdk/client-sqs'
2+
import {S3} from '@aws-sdk/client-s3'
63
import {BodyFormat, Squiss} from '.';
74
import {IMessageAttributes, parseMessageAttributes} from './attributeUtils';
85
import {EventEmitter} from 'events';
96
import {GZIP_MARKER, decompressMessage} from './gzipUtils';
107
import {deleteBlob, getBlob, IS3Upload, S3_MARKER} from './s3Utils';
11-
import {BatchResultErrorEntry} from 'aws-sdk/clients/sqs';
128
import {StrictEventEmitter} from './EventEmitterTypesHelper';
139

1410
const EMPTY_BODY = '{}';
1511

1612
export interface IMessageOpts {
17-
msg: SQS.Message;
13+
msg: SQSMessage;
1814
unwrapSns?: boolean;
1915
bodyFormat?: BodyFormat;
2016
squiss: Squiss;
@@ -38,8 +34,8 @@ interface IMessageEvents {
3834
keep: void;
3935
delError: BatchResultErrorEntry;
4036
deleted: string;
41-
autoExtendFail: AWSError;
42-
autoExtendError: AWSError;
37+
autoExtendFail: SQSServiceException;
38+
autoExtendError: SQSServiceException;
4339
s3Download: IS3Upload;
4440
s3Delete: IS3Upload;
4541
}
@@ -56,7 +52,7 @@ export class Message extends (EventEmitter as new() => MessageEmitter) {
5652
}
5753
}
5854

59-
public raw: SQS.Message;
55+
public raw: SQSMessage;
6056
public body?: string | any;
6157
public subject?: string;
6258
public topicArn?: string;
@@ -152,7 +148,7 @@ export class Message extends (EventEmitter as new() => MessageEmitter) {
152148
if (!this._handled) {
153149
this._handled = true;
154150
return this._squiss.releaseMessage(this)
155-
.catch((e) => {
151+
.catch(() => {
156152
this._handled = false;
157153
});
158154
}

0 commit comments

Comments
 (0)