aws-lambda-helper
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "aws-lambda-helper", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Collection of helper methods for lambda", | ||
"main": "index.js", | ||
"main": "src/index.js", | ||
"scripts": { | ||
@@ -18,11 +18,13 @@ "nocov": "node ./node_modules/.bin/mocha --compilers js:babel-register test/*/*.js", | ||
}, | ||
"license": "GPL-2.0", | ||
"homepage": "https://github.com/tcdl/aws-lambda-helper", | ||
"devDependencies": { | ||
"eslint": "^1.10.3", | ||
"eslint-config-semistandard": "^5.0.0", | ||
"babel-cli": "^6.4.5", | ||
"babel-istanbul": "^0.6.0", | ||
"babel-plugin-add-module-exports": "^0.1.2", | ||
"babel-plugin-transform-runtime": "^6.4.3", | ||
"babel-preset-es2015": "^6.3.13", | ||
"babel-plugin-transform-runtime": "^6.4.3", | ||
"babel-register": "^6.4.3", | ||
"eslint": "^1.10.3", | ||
"eslint-config-semistandard": "^5.0.0", | ||
"mocha": "^2.4.5" | ||
@@ -29,0 +31,0 @@ }, |
# aws-lambda-helper | ||
Collection of helper methods for lambda | ||
## Installation | ||
`$ npm install aws-lambda-helper --save` | ||
## Usage | ||
`const helper = require('aws-lambda-helper');` | ||
### getEnvironment | ||
Function to get environment from context object | ||
Example: | ||
``` | ||
const context = { | ||
invokedFunctionArn: 'arn:123:abs:prod' | ||
}; | ||
helper.getEnvironment(context, function (err, env) { | ||
console.log(env); | ||
//print 'prod' | ||
}); | ||
``` | ||
### validateWithSchema | ||
Function to validate input data with defined schema | ||
``` | ||
import payloadSchema from '../schemas/validationSchema'; | ||
const data = { | ||
a: 1, | ||
b: 'Hello World' | ||
}; | ||
helper.validateWithSchema(data, payloadSchema, function (err, valid) { | ||
console.log(valid); | ||
//print 'true' | ||
}); | ||
``` |
@@ -25,9 +25,7 @@ 'use strict'; | ||
var validation = _tv2.default.validateResult(event, payloadSchema, true); | ||
if (!validation.valid) return cb(validation.error); | ||
if (!validation.valid) return cb(validation.error, false); | ||
cb(null, true); | ||
} | ||
exports.default = { | ||
getEnvironment: getEnvironment, | ||
validateWithSchema: validateWithSchema | ||
}; | ||
exports.default = { getEnvironment: getEnvironment, validateWithSchema: validateWithSchema }; | ||
module.exports = exports['default']; |
'use strict'; | ||
import assert from 'assert'; | ||
import helper from '../../lib/index'; | ||
import helper from '../../lib'; | ||
import payloadSchema from '../fixtures/validationSchema'; | ||
@@ -21,3 +21,3 @@ | ||
assert.equal(err.message, 'Missing required property: param4'); | ||
assert.equal(data, undefined); | ||
assert.equal(data, false); | ||
done(); | ||
@@ -24,0 +24,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
44505
12
47
9
3
70
125
1