├── index.js ├── .gitignore ├── lib ├── utils.js ├── context.js └── invoke.js ├── package.json ├── LICENSE ├── bin └── local-node-lambda └── README.md /index.js: -------------------------------------------------------------------------------- 1 | var invoke = require('./lib/invoke.js'); 2 | 3 | function localNodeLambda () {}; 4 | 5 | localNodeLambda.invoke = invoke; 6 | 7 | module.exports = localNodeLambda; 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # node-waf configuration 20 | .lock-wscript 21 | 22 | # Compiled binary addons (http://nodejs.org/api/addons.html) 23 | build/Release 24 | 25 | # Dependency directory 26 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 27 | node_modules 28 | -------------------------------------------------------------------------------- /lib/utils.js: -------------------------------------------------------------------------------- 1 | /* 2 | * utility functions 3 | */ 4 | 5 | module.exports = Utils; 6 | function Utils () {} 7 | 8 | Utils.hexChars = "0123456789abcdef".split(''); 9 | Utils.generateRandomHex = function (length) { 10 | var hexVal = ''; 11 | for (var i=0; i, , , , function (err, message) { 27 | if (err) { 28 | console.log(err); 29 | } else { 30 | console.log(message); 31 | } 32 | process.exit(); 33 | }); 34 | ``` 35 | 36 | ```bash 37 | # Run from command line 38 | local-node-lambda 39 | ``` 40 | 41 | Command Line Help 42 | ---------- 43 | #### Parameters 44 | * -p, --path [Lambda file name] Specify Lambda function file name. Default is "./index" 45 | * -e, --eventPath [Event data file name] Specify event data file name. Default is "{}" 46 | * -h, --handler [Lambda handler name] Lambda handler name. Default is "handler". 47 | * -t, --timeout [Timeout seconds] Seconds until the Lambda function times out. Default is 3 seconds. 48 | 49 | #### Event data 50 | From the regular node execution you can pass in a JSON object as the event object, while from the command line you can pass in a js file that exports a JSON object. 51 | 52 | ```js 53 | # Command line sample event 54 | module.exports = { 55 | hello: "world" 56 | }; 57 | ``` 58 | 59 | Inspiration 60 | ---------- 61 | * https://github.com/ashiina/lambda-local 62 | * https://github.com/RebelMail/node-lambda 63 | 64 | 65 | License 66 | ---------- 67 | This library is released under the MIT license. 68 | 69 | --------------------------------------------------------------------------------