(options, type)
| 52 | } |
| 53 | |
| 54 | function setDefaults(options, type) { |
| 55 | var defaultOptions = { |
| 56 | dynamo: { |
| 57 | awsRegion: "eu-west-1", |
| 58 | eventSourceARN: "arn:aws:dynamodb:us-west-2:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", |
| 59 | events: [{type: "INSERT", number: 1}] |
| 60 | }, |
| 61 | sns: { |
| 62 | message: "default test message" |
| 63 | }, |
| 64 | "api-gateway": { |
| 65 | path: "default/path", |
| 66 | method: "GET", |
| 67 | headers: { |
| 68 | "default-header": 'default' |
| 69 | }, |
| 70 | queryStringParameters: { |
| 71 | query: "default" |
| 72 | }, |
| 73 | pathParameters: { |
| 74 | uuid: '1234' |
| 75 | }, |
| 76 | stageVariables: { |
| 77 | ENV: "test" |
| 78 | }, |
| 79 | body: "default body" |
| 80 | } |
| 81 | }; |
| 82 | |
| 83 | if (typeof options !== "object") { |
| 84 | return defaultOptions[type]; |
| 85 | } |
| 86 | return Object.keys(defaultOptions[type]).reduce(function(options, curr) { |
| 87 | options[curr] = options[curr] ? options[curr] : defaultOptions[type][curr] |
| 88 | return options; |
| 89 | }, options); |
| 90 | } |
| 91 | |
| 92 | function createSNSEvent (options) { |
| 93 | var options = setDefaults(options, "sns"); |
no outgoing calls
no test coverage detected