aws-core-utils
Advanced tools
Comparing version 5.0.15 to 5.0.16
@@ -61,2 +61,3 @@ 'use strict'; | ||
* | ||
* @param {Object|StandardContext} context - the context to configure as a standard context | ||
* @param {StandardSettings} settings - optional settings to use to configure a standard context | ||
@@ -77,3 +78,3 @@ * @param {StandardOptions} options - optional options to use to configure a standard context | ||
*/ | ||
function generateHandlerFunction(settings, options, fn, logRequestResponseAtLogLevel, allowedHttpStatusCodes, invalidRequestMsg, failureMsg, successMsg) { | ||
function generateHandlerFunction(context, settings, options, fn, logRequestResponseAtLogLevel, allowedHttpStatusCodes, invalidRequestMsg, failureMsg, successMsg) { | ||
/** | ||
@@ -86,3 +87,2 @@ * An API-Gateway exposed Lambda handler function. | ||
function handler(event, awsContext, callback) { | ||
const context = {}; | ||
try { | ||
@@ -89,0 +89,0 @@ // Configure the context as a standard context |
{ | ||
"name": "aws-core-utils", | ||
"version": "5.0.15", | ||
"version": "5.0.16", | ||
"description": "Core utilities for working with Amazon Web Services (AWS), including ARNs, regions, stages, Lambdas, AWS errors, stream events, Kinesis, DynamoDB.DocumentClients, etc.", | ||
@@ -5,0 +5,0 @@ "author": "Byron du Preez", |
@@ -1,2 +0,2 @@ | ||
# aws-core-utils v5.0.15 | ||
# aws-core-utils v5.0.16 | ||
@@ -54,3 +54,3 @@ Core utilities for working with Amazon Web Services (AWS), including ARNs, regions, stages, Lambdas, AWS errors, stream events, Kinesis, DynamoDB.DocumentClients, etc. | ||
const BadRequest = appErrors.BadRequest; | ||
const context = {}; // or your own pre-configured context | ||
const standardOptions = require('my-options.json'); // or whatever options you want to use to configure stage handling, logging, custom settings, ... | ||
@@ -61,6 +61,6 @@ const standardSettings = undefined; // or whatever settings object you want to use to configure stage handling, logging, custom settings, ... | ||
// Simplest approach - generate your API Gateway exposed Lambda's handler function | ||
module.exports.handler = apiLambdas.generateHandlerFunction(standardSettings, standardOptions, exampleFunction); | ||
module.exports.handler = apiLambdas.generateHandlerFunction(context, standardSettings, standardOptions, exampleFunction); | ||
// OR ... using all optional arguments to change the allowed HTTP status codes and customise logging in the handler function | ||
module.exports.handler = apiLambdas.generateHandlerFunction(standardSettings, standardOptions, exampleFunction, 'info', | ||
module.exports.handler = apiLambdas.generateHandlerFunction(context, standardSettings, standardOptions, exampleFunction, 'info', | ||
[400, 404, 500], 'Invalid request ...', 'Failed to ...', 'Finished ...'); | ||
@@ -393,2 +393,5 @@ | ||
### 5.0.16 | ||
- Added missing `context` as first argument to `generateHandlerFunction` function of `api-lambdas.js` module | ||
### 5.0.15 | ||
@@ -395,0 +398,0 @@ - Fixed missing require `core-functions/promises` issue in `api-lambdas.js` module |
@@ -84,3 +84,4 @@ 'use strict'; | ||
// Create a sample AWS Lambda handler function | ||
const handler = apiLambdas.generateHandlerFunction(undefined, require('./sample-standard-options.json'), | ||
const context = {}; | ||
const handler = apiLambdas.generateHandlerFunction(context, undefined, require('./sample-standard-options.json'), | ||
fn, logging.INFO); //, undefined, 'Invalid do something request', 'Failed to do something useful', 'Did something useful'); | ||
@@ -133,3 +134,4 @@ | ||
// Create a sample AWS Lambda handler function | ||
const handler = apiLambdas.generateHandlerFunction(undefined, require('./sample-standard-options.json'), | ||
const context = {}; | ||
const handler = apiLambdas.generateHandlerFunction(context, undefined, require('./sample-standard-options.json'), | ||
fn, logging.DEBUG, undefined, 'Invalid do something request', 'Failed to do something useful', 'Did something useful'); | ||
@@ -191,3 +193,4 @@ | ||
// Create a sample AWS Lambda handler function | ||
const handler = apiLambdas.generateHandlerFunction(undefined, require('./sample-standard-options.json'), | ||
const context = {}; | ||
const handler = apiLambdas.generateHandlerFunction(context, undefined, require('./sample-standard-options.json'), | ||
fn, logging.TRACE, undefined, 'Invalid do something request', 'Failed to do something useful', 'Did something useful'); | ||
@@ -194,0 +197,0 @@ |
{ | ||
"name": "aws-core-utils-tests", | ||
"description": "Unit tests for aws-core-utils modules", | ||
"version": "5.0.15", | ||
"version": "5.0.16", | ||
"author": "Byron du Preez", | ||
@@ -6,0 +6,0 @@ "license": "Apache-2.0", |
364037
5313
625