aws-lambda-helper
Collection of helper methods for lambda
Installation
$ npm install aws-lambda-helper --save
Usage
var helper = require('aws-lambda-helper');
getEnvironment
Function to get environment from context object
Example:
var context = {
invokedFunctionArn: 'arn:123:abs:prod'
};
var env = helper.getEnvironment(context);
In case of incorrect context or misconfigured function ARN it will return null
.
validateWithSchema
Function to validate input data with defined schema
import payloadSchema from '../schemas/validationSchema';
var data = {
a: 1,
b: 'Hello World'
};
var result = helper.validateWithSchema(data, payloadSchema);
In case of validation error it will throw an error, so for safest coding practices use try/catch
statements.
try {
helper.validateWithSchema(data, payloadSchema);
} catch (error) {
}