@agiledigital/serverless-sns-sqs-lambda
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -132,8 +132,11 @@ "use strict"; | ||
validateConfig(funcName, stage, config) { | ||
if (!config.topicArn) { | ||
if (!config.topicArn || !config.name) { | ||
throw new Error(`Error: | ||
When creating an snsSqs handler, you must define the topicArn. | ||
In function [${funcName}] the topicArn was [${config.topicArn}]. | ||
When creating an snsSqs handler, you must define the name and topicArn. | ||
In function [${funcName}]: | ||
- name was [${config.name}] | ||
- topicArn was [${config.topicArn}]. | ||
e.g. | ||
Usage | ||
----- | ||
@@ -145,3 +148,3 @@ functions: | ||
- snsSqs: | ||
name: Event # optional - default is last part of arn | ||
name: Event # required | ||
topicArn: !Ref TopicArn # required | ||
@@ -161,3 +164,3 @@ maxRetryCount: 2 # optional - default is 5 | ||
...config, | ||
name: config.name || config.topicArn.replace(/.*:/, ""), | ||
name: config.name, | ||
funcName: funcNamePascalCase, | ||
@@ -164,0 +167,0 @@ prefix: |
@@ -49,2 +49,22 @@ "use strict"; | ||
})); | ||
it("should fail if name is not passed", () => { | ||
expect.assertions(1); | ||
expect(() => { | ||
serverlessSnsSqsLambda.validateConfig("func-name", "stage", { | ||
topicArn: "topicArn", | ||
name: undefined | ||
}); | ||
}).toThrow(/name was \[undefined\]/); | ||
}); | ||
it("should fail if topicArn is not passed", () => { | ||
expect.assertions(1); | ||
expect(() => { | ||
serverlessSnsSqsLambda.validateConfig("func-name", "stage", { | ||
topicArn: undefined, | ||
name: "name" | ||
}); | ||
}).toThrow(/topicArn was \[undefined\]/); | ||
}); | ||
}); |
{ | ||
"name": "@agiledigital/serverless-sns-sqs-lambda", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "serverless plugin to make serverless-sns-sqs-lambda events", | ||
@@ -5,0 +5,0 @@ "main": "lib/serverless-sns-sqs-lambda.js", |
@@ -42,3 +42,3 @@ # Serverless Sns Sqs Lambda | ||
- snsSqs: | ||
name: TestEvent # Optional - choose a name for the event queue | ||
name: TestEvent # Required - choose a name prefix for the event queue | ||
topicArn: !Ref Topic # Required - SNS topic to subscribe to | ||
@@ -45,0 +45,0 @@ batchSize: 2 # Optional - default value is 10 |
Sorry, the diff of this file is not supported yet
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
46670
357