prime-sdk 3.0.3 → 3.0.6

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": "prime-sdk",
3
- "version": "3.0.3",
3
+ "version": "3.0.6",
4
4
  "description": "swiss army knife",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -35,6 +35,7 @@
35
35
  "@nestjs/config": "^4.0.3",
36
36
  "@nestjs/core": "^11.1.17",
37
37
  "@nestjs/platform-express": "^11.1.17",
38
+ "@smithy/node-http-handler": "^3.3.1",
38
39
  "ioredis": "^5.4.1",
39
40
  "reflect-metadata": "^0.2.0",
40
41
  "rxjs": "^7.8.1"
@@ -1,5 +1,7 @@
1
1
  import { S3Client } from '@aws-sdk/client-s3';
2
+ import { NodeHttpHandler } from '@smithy/node-http-handler';
2
3
  import { DynamicModule } from '@nestjs/common';
4
+ import { Agent as HttpsAgent } from 'https';
3
5
  import {
4
6
  AwsCredentialIdentity,
5
7
  AwsCredentialIdentityProvider,
@@ -9,6 +11,7 @@ export type S3Setup = {
9
11
  region: string;
10
12
  endpoint?: string;
11
13
  credentials: AwsCredentialIdentityProvider | AwsCredentialIdentity;
14
+ keepAlive?: boolean;
12
15
  };
13
16
 
14
17
  const S3Provider = (params: S3Setup) => {
@@ -19,6 +22,9 @@ const S3Provider = (params: S3Setup) => {
19
22
  credentials: params.credentials,
20
23
  ...(params.endpoint && { endpoint: params.endpoint }),
21
24
  region: params.region,
25
+ requestHandler: new NodeHttpHandler({
26
+ httpsAgent: new HttpsAgent({ keepAlive: params.keepAlive ?? true }),
27
+ }),
22
28
  });
23
29
  },
24
30
  };
@@ -1,5 +1,7 @@
1
1
  import { SNSClient } from '@aws-sdk/client-sns';
2
+ import { NodeHttpHandler } from '@smithy/node-http-handler';
2
3
  import { DynamicModule } from '@nestjs/common';
4
+ import { Agent as HttpsAgent } from 'https';
3
5
  import {
4
6
  AwsCredentialIdentity,
5
7
  AwsCredentialIdentityProvider,
@@ -9,6 +11,7 @@ export type SNSSetup = {
9
11
  region: string;
10
12
  endpoint?: string;
11
13
  credentials: AwsCredentialIdentityProvider | AwsCredentialIdentity;
14
+ keepAlive?: boolean;
12
15
  };
13
16
 
14
17
  const SNSProvider = (params: SNSSetup) => {
@@ -19,6 +22,9 @@ const SNSProvider = (params: SNSSetup) => {
19
22
  credentials: params.credentials,
20
23
  ...(params.endpoint && { endpoint: params.endpoint }),
21
24
  region: params.region,
25
+ requestHandler: new NodeHttpHandler({
26
+ httpsAgent: new HttpsAgent({ keepAlive: params.keepAlive ?? true }),
27
+ }),
22
28
  });
23
29
  },
24
30
  };
@@ -1,5 +1,7 @@
1
1
  import { SQSClient } from '@aws-sdk/client-sqs';
2
+ import { NodeHttpHandler } from '@smithy/node-http-handler';
2
3
  import { DynamicModule } from '@nestjs/common';
4
+ import { Agent as HttpsAgent } from 'https';
3
5
  import {
4
6
  AwsCredentialIdentity,
5
7
  AwsCredentialIdentityProvider,
@@ -9,6 +11,7 @@ export type SqsSetup = {
9
11
  region: string;
10
12
  endpoint?: string;
11
13
  credentials: AwsCredentialIdentityProvider | AwsCredentialIdentity;
14
+ keepAlive?: boolean;
12
15
  };
13
16
 
14
17
  const SqsProvider = (params: SqsSetup) => {
@@ -19,6 +22,9 @@ const SqsProvider = (params: SqsSetup) => {
19
22
  credentials: params.credentials,
20
23
  region: params.region,
21
24
  ...(params.endpoint && { endpoint: params.endpoint }),
25
+ requestHandler: new NodeHttpHandler({
26
+ httpsAgent: new HttpsAgent({ keepAlive: params.keepAlive ?? true }),
27
+ }),
22
28
  });
23
29
  },
24
30
  };
@@ -70,8 +70,14 @@ export class Queue {
70
70
 
71
71
  try {
72
72
  const response = await this.receiveMessages(version);
73
+ const messages = response.Messages;
74
+
75
+ if (!messages) {
76
+ return;
77
+ }
78
+
73
79
  if (this.bulk === 1) {
74
- const message = response.Messages?.[0] || null;
80
+ const message = messages?.[0] || null;
75
81
 
76
82
  if (message) {
77
83
  await this.context.handleMessage(message);
@@ -82,10 +88,10 @@ export class Queue {
82
88
  return;
83
89
  }
84
90
 
85
- await this.context.handleMessage(response.Messages);
91
+ await this.context.handleMessage(messages);
86
92
 
87
93
  await Promise.all(
88
- response.Messages.map((message: Message) =>
94
+ messages.map((message: Message) =>
89
95
  this.deleteMessage(message.ReceiptHandle),
90
96
  ),
91
97
  );
Binary file