-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from ashiina/develop
1.1.0 release
- Loading branch information
Showing
14 changed files
with
543 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{ | ||
"passfail" : false, | ||
"maxerr" : 50, | ||
"browser" : true, | ||
"browserify" : false, | ||
"couch" : false, | ||
"devel" : true, | ||
"dojo" : false, | ||
"jasmine" : false, | ||
"jquery" : false, | ||
"mocha" : true, | ||
"mootools" : false, | ||
"node" : true, | ||
"nonstandard" : false, | ||
"phantom" : false, | ||
"prototypejs" : false, | ||
"qunit" : false, | ||
"rhino" : false, | ||
"shelljs" : false, | ||
"typed" : false, | ||
"worker" : false, | ||
"wsh" : false, | ||
"yui" : false, | ||
"debug" : false, | ||
"devel" : false, | ||
"bitwise" : true, | ||
"camelcase" : true, | ||
"curly" : true, | ||
"eqeqeq" : true, | ||
"forin" : false, | ||
"freeze" : true, | ||
"immed" : true, | ||
"indent" : 2, | ||
"latedef" : true, | ||
"laxbreak" : false, | ||
"loopfunc" : false, | ||
"maxparams" : 5, | ||
"maxdepth" : 5, | ||
"maxstatements" : 100, | ||
"maxcomplexity" : false, | ||
"maxlen" : 100, | ||
"newcap" : true, | ||
"noarg" : true, | ||
"noempty" : true, | ||
"nonbsp" : true, | ||
"nonew" : true, | ||
"plusplus" : false, | ||
"quotmark" : true, | ||
"strict" : true, | ||
"undef" : true, | ||
"unused" : "strict", | ||
"asi" : false, | ||
"boss" : false, | ||
"eqnull" : false, | ||
"esversion" : 6, | ||
"moz" : false, | ||
"evil" : false, | ||
"expr" : false, | ||
"funcscope" : false, | ||
"globalstrict" : false, | ||
"iterator" : false, | ||
"lastsemic" : false, | ||
"laxbreak" : false, | ||
"laxcomma" : false, | ||
"loopfunc" : false, | ||
"multistr" : false, | ||
"noyield" : false, | ||
"notypeof" : false, | ||
"proto" : false, | ||
"scripturl" : false, | ||
"shadow" : false, | ||
"sub" : true, | ||
"supernew" : false, | ||
"validthis" : false, | ||
"globals" : {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
language: node_js | ||
node_js: | ||
- "1.8" | ||
- "2.5" | ||
- "3.3" | ||
- "4.4" | ||
sudo: false | ||
#cache: | ||
# directories: | ||
# - node_modules | ||
script: | ||
- "cd test && ../node_modules/mocha/bin/mocha" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,111 @@ | ||
Lambda-local | ||
============ | ||
# Lambda-local | ||
|
||
Lambda-local lets you test Amazon Lambda functions on your local machine with sample event data. | ||
The `context` of the Lambda function is already loaded so you do not have to worry about it. | ||
You can pass any `event` JSON object as you please. | ||
[![Build Status](https://travis-ci.org/ashiina/lambda-local.svg?branch=develop)](https://travis-ci.org/ashiina/lambda-local) | ||
|
||
Lambda-local lets you test Amazon Lambda functions on your local machine with sample event data. | ||
The `context` of the Lambda function is already loaded so you do not have to worry about it. | ||
You can pass any `event` JSON object as you please. | ||
|
||
## Install | ||
|
||
Install | ||
---- | ||
```bash | ||
npm install -g lambda-local | ||
``` | ||
|
||
## Usage | ||
|
||
### As a command line tool | ||
|
||
Usage | ||
----- | ||
You can use Lambda-local as a command line tool. | ||
|
||
```bash | ||
# Usage | ||
lambda-local -l index.js -h handler -e event-samples/s3-put.js | ||
lambda-local -l index.js -h handler -e event-samples/s3-put.js | ||
``` | ||
|
||
About | ||
----- | ||
### In another node.js script | ||
|
||
You can also use Lambda local directly in a script. For instance, it is interesting in a [mocha][1] test suite in combination with [istanbull][2] in order to get test coverage. | ||
|
||
```js | ||
const lambdaLocal = require('lambda-local'); | ||
|
||
var jsonPayload = { | ||
'key1': 'value1', | ||
'key2': 'value2', | ||
'key3': 'value3' | ||
} | ||
|
||
lambdaLocal.execute({ | ||
event: jsonPayload, | ||
lambdaPath: path.join(__dirname, 'path/to/index.js'), | ||
profilePath: '~/.aws/credentials', | ||
profileName: 'default', | ||
timeoutMs: 3000, | ||
callback: function(err, data) { | ||
if (err) { | ||
console.log(err); | ||
} else { | ||
console.log(data); | ||
} | ||
} | ||
}); | ||
``` | ||
|
||
## About | ||
|
||
### Command | ||
* -l, --lambdapath [lambda file name] Specify Lambda function file name. | ||
* -e, --eventpath [event data file name] Specify event data file name. | ||
* -h, --handler [lambda-function handler name (optional)] Lambda function handler name. Default is "handler". | ||
* -t, --timeout [timeout seconds (optional)] Seconds until lambda function timeout. Default is 3 seconds. | ||
* -c, --callbackforce (optional) Force the function to stop after having called context.done/succeed/fail. | ||
* -p, --profile [aws file path (optional)] Read the AWS profile to get the credidentials. | ||
* -l, --lambda-path <lambda index path> (required) Specify Lambda function file name. | ||
* -e, --event-path <event path> (required) Specify event data file name. | ||
* -h, --handler <handler name> (optional) Lambda function handler name. Default is "handler". | ||
* -t, --timeout <timeout> (optional) Seconds until lambda function timeout. Default is 3 seconds. | ||
* -n, --no-force-callback (optional) Force the function to stop after having called the handler function even if context.done/succeed/fail was not called. | ||
* -p, --profile <aws profile name> (optional) Read the AWS profile to get the credentials from file name. | ||
* -p, --profile-path <aws profile name> (optional) Read the specified AWS credentials file. | ||
|
||
### Event data | ||
Event sample data are placed in `event-samples` folder - feel free to use the files in here, or create your own event data. | ||
Event data are just JSON objects exported: | ||
Event sample data are placed in `event-samples` folder - feel free to use the files in here, or create your own event data. | ||
Event data are just JSON objects exported: | ||
|
||
```js | ||
# Sample event data | ||
// Sample event data | ||
module.exports = { | ||
foo: "bar" | ||
}; | ||
``` | ||
|
||
### Context | ||
The `context` object has been directly extracted from the source visible when running an actual Lambda function on AWS. | ||
They may change the internals of this object, and Lambda-local does not guarantee that this will always be up-to-date with the actual context object. | ||
The `context` object has been directly extracted from the source visible when running an actual Lambda function on AWS. | ||
They may change the internals of this object, and Lambda-local does not guarantee that this will always be up-to-date with the actual context object. | ||
|
||
### AWS-SDK | ||
Since the Amazon Lambda can load the AWS-SDK npm without installation, Lambda-local has also packaged AWS-SDK in its dependencies. | ||
If you want to use this, please use the "-p" option with the aws credentials file. More infos here: | ||
http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-config-files | ||
|
||
License | ||
---------- | ||
## API | ||
|
||
### LambdLocal | ||
|
||
#### `execute(options)` | ||
|
||
Executes a lambda given the `options` object where keys are: | ||
- `event` - requested event as a json object, | ||
- `lambdaPath` - requested path to the lambda function, | ||
- `profilePath` - optional path to your AWS credentials file | ||
- `profileName` - optional aws profile name | ||
- `lambdaHandler` - optional handler name, default to `handler` | ||
- `region` - optional AWS region, default to `us-east-1` | ||
- `callbackWaitsForEmptyEventLoop` - optional, default to `true` which forces the function to stop after having called the handler function even if context.done/succeed/fail was not called. | ||
- `timeoutMs` - optional timeout, default to 3000 ms | ||
- `mute` - optional, allows to mute console.log calls in the lambda function, default false | ||
- `callback` - optional lambda third parameter [callback][3] | ||
|
||
## License | ||
|
||
This library is released under the MIT license. | ||
|
||
[1]: https://mochajs.org/ | ||
[2]: http://gotwarlost.github.io/istanbul/ | ||
[3]: http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html | ||
|
Oops, something went wrong.