lambda-local
Advanced tools
Comparing version 0.0.7 to 0.0.8
# ChangeLog | ||
## 0.0.8 (2016/4/9) | ||
* Added support for all propertiesin the Context object. | ||
Supporting everything in here: | ||
https://docs.aws.amazon.com/en_us/lambda/latest/dg/nodejs-prog-model-context.html | ||
* Wrote a mocha unit test for the Context object. | ||
## 0.0.7 (2016/2/21) | ||
* Minor bug fix: Now correctly outputs the error object when Context.done() has an error. | ||
## 0.0.6 (2015/11/13) | ||
@@ -4,0 +14,0 @@ * Added support for `fail` and `succeed` methods |
/* | ||
* Creating Lambda's context object | ||
* Lambda's Context object. | ||
* Refer to this documentation: | ||
* https://docs.aws.amazon.com/en_us/lambda/latest/dg/nodejs-prog-model-context.html | ||
*/ | ||
@@ -13,2 +15,8 @@ | ||
/* | ||
* Used to determine the getRemainingTimeInMillis() | ||
*/ | ||
var start_time; | ||
var timeout; | ||
function Context () {}; | ||
@@ -20,3 +28,17 @@ | ||
module.exports = Context; | ||
/* | ||
* Context object properties | ||
*/ | ||
Context.functionName = ''; | ||
Context.functionVersion = '1'; | ||
Context.invokedFunctionArn = 'a'; | ||
Context.memoryLimitInMB = 1; | ||
Context.awsRequestId = ''; | ||
Context.logGroupName = 'a'; | ||
Context.logStreamName = null; | ||
Context.identity = null; | ||
Context.clientContext = null; | ||
/* | ||
* create random invokeid. | ||
@@ -26,3 +48,3 @@ * Assuming that invokeid follows the format: | ||
*/ | ||
Context.invokeid = (function(){ | ||
Context.createInvokeId = (function(){ | ||
return [ | ||
@@ -38,2 +60,19 @@ utils.generateRandomHex(8), | ||
/* | ||
* Context initialization. | ||
* Called from lambda-local | ||
*/ | ||
Context._initialize = function(options){ | ||
/* set time */ | ||
start_time = new Date().getTime(); | ||
timeout = options.timeoutMs; | ||
/* set function name */ | ||
Context.functionName = options.functionName; | ||
/* set requestid */ | ||
Context.awsRequestId = options.awsRequestId; | ||
return; | ||
} | ||
/* | ||
* This `done` method is directly extracted from source. | ||
@@ -62,2 +101,3 @@ */ | ||
Context.fail = function (err) { | ||
console.log("FAILING!!"); | ||
Context.done(err); | ||
@@ -72,1 +112,11 @@ }; | ||
}; | ||
/* | ||
* 'getRemainingTimeInMillis' method return time before task is killed | ||
*/ | ||
Context.getRemainingTimeInMillis = function () { | ||
var now = new Date().getTime(); | ||
return (timeout + start_time - now); | ||
}; | ||
{ | ||
"name": "lambda-local", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "Commandline tool to run Lambda functions on your local machine.", | ||
@@ -11,3 +11,4 @@ "author": "ashiina", | ||
"aws-sdk": "^2.1.6", | ||
"commander": "^2.6.0" | ||
"commander": "^2.6.0", | ||
"mocha": "^2.4.5" | ||
}, | ||
@@ -14,0 +15,0 @@ "preferGlobal": true, |
Sorry, the diff of this file is not supported yet
12488
14
304
3
+ Addedmocha@^2.4.5
+ Addedcommander@0.6.12.3.0(transitive)
+ Addeddebug@2.2.0(transitive)
+ Addeddiff@1.4.0(transitive)
+ Addedescape-string-regexp@1.0.2(transitive)
+ Addedglob@3.2.11(transitive)
+ Addedgrowl@1.9.2(transitive)
+ Addedjade@0.26.3(transitive)
+ Addedlru-cache@2.7.3(transitive)
+ Addedminimatch@0.3.0(transitive)
+ Addedminimist@0.0.8(transitive)
+ Addedmkdirp@0.3.00.5.1(transitive)
+ Addedmocha@2.5.3(transitive)
+ Addedms@0.7.1(transitive)
+ Addedsigmund@1.0.1(transitive)
+ Addedsupports-color@1.2.0(transitive)
+ Addedto-iso-string@0.0.2(transitive)