Comparing version 2.0.3 to 2.0.4
@@ -0,1 +1,2 @@ | ||
import { HTTPOptions } from "aws-sdk"; | ||
export declare type Callback = (x: any) => any; | ||
@@ -43,2 +44,3 @@ export declare type getPayload = (msg: any, topic: string) => { | ||
endPoint?: string; | ||
httpOptions?: HTTPOptions; | ||
}; | ||
@@ -45,0 +47,0 @@ export declare type RedisConfiguration = { |
@@ -32,2 +32,3 @@ "use strict"; | ||
parameters.endpoint = config.endpoint; | ||
parameters.httpOptions = config.httpOptions; | ||
} | ||
@@ -34,0 +35,0 @@ else if (parameters.engine === 'redis') { |
@@ -11,4 +11,5 @@ import * as AWS from 'aws-sdk'; | ||
}>; | ||
listQueuesAsync: (...args: any[]) => Promise<import("aws-sdk/lib/request").PromiseResult<AWS.SQS.ListQueuesResult, AWS.AWSError>>; | ||
}; | ||
}; | ||
export default _default; |
@@ -9,16 +9,8 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const AWS = __importStar(require("aws-sdk")); | ||
const https_1 = __importDefault(require("https")); | ||
const sqs = (config) => { | ||
if (process.env.NODE_ENV === 'development') { | ||
if (config.httpOptions) { | ||
AWS.config.update({ | ||
httpOptions: { | ||
agent: new https_1.default.Agent({ | ||
rejectUnauthorized: false, | ||
}), | ||
}, | ||
httpOptions: config.httpOptions | ||
}); | ||
@@ -38,2 +30,3 @@ } | ||
const deleteMessage = instance.deleteMessage.bind(instance); | ||
const listQueues = instance.listQueues.bind(instance); | ||
const dummy = { | ||
@@ -45,2 +38,3 @@ createQueueAsync: (...args) => createQueue(...args).promise(), | ||
deleteMessageAsync: (...args) => deleteMessage(...args).promise(), | ||
listQueuesAsync: (...args) => listQueues(...args).promise() | ||
}; | ||
@@ -47,0 +41,0 @@ return Object.assign(instance, dummy); |
@@ -9,3 +9,3 @@ import { Configuration, Logger, IProducer, IRegistry, sqsUrls } from '../common'; | ||
constructor(config: Configuration, registry: IRegistry, logger?: Logger); | ||
initialize(topic?: string): any; | ||
initialize(topic?: string): Promise<any>; | ||
getPayload(msg: any, topic: string): any; | ||
@@ -12,0 +12,0 @@ send(topic: string, payload: any): Promise<void>; |
@@ -17,3 +17,12 @@ "use strict"; | ||
} | ||
initialize(topic) { | ||
async initialize(topic) { | ||
if (!topic) { | ||
throw new Error("Topic cannot be empty"); | ||
} | ||
const { QueueUrls } = await this.producer.listQueuesAsync(); | ||
const queue = ((QueueUrls !== null && QueueUrls !== void 0 ? QueueUrls : [])).find(queueUrl => queueUrl.includes(topic)); | ||
if (queue) { | ||
this.sqsUrls[topic] = queue; | ||
return queue; | ||
} | ||
const params = { | ||
@@ -27,5 +36,5 @@ QueueName: topic, | ||
}; | ||
return this.producer | ||
.createQueueAsync(params) | ||
.then(data => data && data.QueueUrl); | ||
const { data: { QueueUrl } } = await this.producer.createQueueAsync(params); | ||
this.sqsUrls[topic] = QueueUrl; | ||
return QueueUrl; | ||
} | ||
@@ -58,5 +67,3 @@ getPayload(msg, topic) { | ||
try { | ||
if (!this.sqsUrls[topic]) { | ||
this.sqsUrls[topic] = await this.initialize(topic); | ||
} | ||
await this.initialize(topic); | ||
} | ||
@@ -63,0 +70,0 @@ catch (ex) { |
{ | ||
"name": "steveo", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "A Task Pub/Sub Background processing library", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
1376
1
0
66739
49