Skip to content

Instantly share code, notes, and snippets.

@cagataygurturk
Created February 18, 2016 13:06
Show Gist options
  • Save cagataygurturk/c6e94d439f1b2964193c to your computer and use it in GitHub Desktop.
Save cagataygurturk/c6e94d439f1b2964193c to your computer and use it in GitHub Desktop.
Lambda debug locally
/**
* Used to debug locally node.js files
*
* Usage:
*
* node debug.js function_to_run.js event_file.json
*
* Make sure that you have dotenv in package json for environment support.
*/
require('dotenv').config();
var functionToDebug = require(process.argv[2]);
if (process.argv[3]) {
event = require(process.argv[3]);
}
var callback = function (err, message) {
if (err) {
console.log("ERROR: " + JSON.stringify(err));
return;
}
console.log("SUCCESS: " + JSON.stringify(message));
};
functionToDebug.respond(event, callback);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment