@nestjstools/messaging-amazon-sqs-extension
Version:
Extension to handle messages and dispatch them over Amazon SQS
38 lines • 1.52 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AmazonSqsChannelConfig = void 0;
const messaging_1 = require("@nestjstools/messaging");
class AmazonSqsChannelConfig extends messaging_1.ChannelConfig {
credentials;
queueUrl;
queueName;
endpoint;
region;
maxNumberOfMessages;
visibilityTimeout;
waitTimeSeconds;
autoCreate;
deadLetterQueue;
constructor({ name, credentials, queueUrl, maxNumberOfMessages, visibilityTimeout, waitTimeSeconds, region, autoCreate, deadLetterQueue, enableConsumer, avoidErrorsForNotExistedHandlers, middlewares, normalizer, }) {
super(name, avoidErrorsForNotExistedHandlers, middlewares, enableConsumer, normalizer);
let url;
try {
url = new URL(queueUrl);
}
catch (e) {
throw new Error(`Invalid queue url (${queueUrl})`);
}
this.credentials = credentials;
this.queueUrl = queueUrl;
this.queueName = url.pathname.split('/').pop();
this.endpoint = `${url.protocol}//${url.host}`;
this.region = region;
this.maxNumberOfMessages = maxNumberOfMessages ?? 1;
this.visibilityTimeout = visibilityTimeout ?? 20;
this.waitTimeSeconds = waitTimeSeconds ?? 10;
this.autoCreate = autoCreate ?? false;
this.deadLetterQueue = deadLetterQueue ?? false;
}
}
exports.AmazonSqsChannelConfig = AmazonSqsChannelConfig;
//# sourceMappingURL=amazon-sqs.channel-config.js.map