lambda-local
Advanced tools
Comparing version 2.1.2 to 2.2.0
@@ -40,4 +40,4 @@ #!/usr/bin/env node | ||
.option('--envdestroy', '(optional) Destroy added environment on closing. Defaults to false') | ||
.option('-v, --verboselevel <3/2/1/0>', '(optional) Default 3. Level 2 dismiss handler() text, level 1 dismiss lambda-local text ' + | ||
'and level 0 dismiss also the result.', 3) | ||
.option('-v, --verboselevel <3/2/1/0/-1>', '(optional) Default 3. Level 2 dismiss handler() text, level 1 dismiss lambda-local text ' + | ||
'and level 0 dismiss also the result. Level -1 only displays handler() text.', 3) | ||
.option('--envfile <path/to/env/file>', '(optional) Load additional environment variables from a file') | ||
@@ -47,3 +47,3 @@ .option('--inspect [[host:]port]', '(optional) Starts lambda-local using the NodeJS inspector (available in nodejs > 8.0.0)') | ||
.parse(process.argv); | ||
var eventPath = program.eventPath, lambdaPath = program.lambdaPath, lambdaHandler = program.handler, esm = program.esm, profilePath = program.profilePath, profileName = program.profile, region = program.region, environment = program.environment, envdestroy = program.envdestroy, envfile = program.envfile, callbackWaitsForEmptyEventLoop = program.waitEmptyEventLoop, verboseLevel = program.verboselevel; | ||
var eventPath = program.eventPath, lambdaPath = program.lambdaPath, lambdaHandler = program.handler, esm = program.esm, profilePath = program.profilePath, profileName = program.profile, region = program.region, environment = program.environment, envdestroy = program.envdestroy, envfile = program.envfile, callbackWaitsForEmptyEventLoop = program.waitEmptyEventLoop, verboseLevel = parseInt(program.verboselevel); | ||
var port; | ||
@@ -61,2 +61,6 @@ if (program.watch) { | ||
} | ||
if (isNaN(verboseLevel)) { | ||
console.log("Invalid verboseLevel. Must be number."); | ||
process.exit(1); | ||
} | ||
if (!lambdaPath || !eventPath) { | ||
@@ -63,0 +67,0 @@ program.help(); |
@@ -1,2 +0,2 @@ | ||
export declare const version = "2.1.1"; | ||
export declare const version = "2.2.0"; | ||
export declare function setLogger(_logger: any): void; | ||
@@ -3,0 +3,0 @@ export declare function getLogger(): any; |
@@ -67,3 +67,3 @@ 'use strict'; | ||
*/ | ||
exports.version = "2.1.1"; | ||
exports.version = "2.2.0"; | ||
var logger = utils.getWinstonConsole(); | ||
@@ -239,3 +239,3 @@ function setLogger(_logger) { | ||
function _executeSync(opts) { | ||
var event = opts.event, lambdaFunc = opts.lambdaFunc, lambdaPath = opts.lambdaPath, lambdaHandler = opts.lambdaHandler || 'handler', esm = opts.esm, profilePath = opts.profilePath, profileName = opts.profileName || process.env['AWS_PROFILE'] || process.env['AWS_DEFAULT_PROFILE'], region = opts.region, environment = opts.environment, envdestroy = opts.envdestroy, envfile = opts.envfile, callbackWaitsForEmptyEventLoop = opts.callbackWaitsForEmptyEventLoop || false, timeoutMs = opts.timeoutMs || 3000, verboseLevel = opts.verboseLevel, callback = opts.callback, clientContext = null; | ||
var event = opts.event, lambdaFunc = opts.lambdaFunc, lambdaPath = opts.lambdaPath, lambdaHandler = opts.lambdaHandler || 'handler', esm = opts.esm, profilePath = opts.profilePath, profileName = opts.profileName || process.env['AWS_PROFILE'] || process.env['AWS_DEFAULT_PROFILE'], region = opts.region, environment = opts.environment, envdestroy = opts.envdestroy, envfile = opts.envfile, callbackWaitsForEmptyEventLoop = opts.callbackWaitsForEmptyEventLoop || false, timeoutMs = opts.timeoutMs || 3000, verboseLevel = opts.verboseLevel, callback = opts.callback, contextOverwrite = opts.contextOverwrite, onInvocationEnd = opts.onInvocationEnd, clientContext = null; | ||
if (opts.clientContext) { | ||
@@ -340,3 +340,4 @@ if (typeof opts.clientContext === "string") { | ||
}, | ||
clientContext: clientContext | ||
clientContext: clientContext, | ||
onInvocationEnd: onInvocationEnd, | ||
}); | ||
@@ -346,2 +347,4 @@ if (callback) | ||
var ctx = context.generate_context(); | ||
if (contextOverwrite) | ||
opts.contextOverwrite(ctx); | ||
var executeLambdaFunc = function (lambdaFunc) { | ||
@@ -348,0 +351,0 @@ try { |
@@ -9,2 +9,3 @@ 'use strict'; | ||
var mute = require("./mute.js"); | ||
var streaming_js_1 = require("./streaming.js"); | ||
function Context() { | ||
@@ -40,2 +41,3 @@ this.logger = null; | ||
this.clientContext = null; | ||
this.onInvocationEnd = null; | ||
/* | ||
@@ -99,6 +101,7 @@ * callback function called after done | ||
} | ||
if (this.verboseLevel < 3) { | ||
if (this.verboseLevel < 3 && this.verboseLevel >= 0) { | ||
this.unmute = mute(); | ||
} | ||
this.clientContext = options.clientContext; | ||
this.onInvocationEnd = options.onInvocationEnd; | ||
return; | ||
@@ -138,3 +141,7 @@ }; | ||
clientContext: this.clientContext, | ||
_stopped: false | ||
_stopped: false, | ||
// INTERNAL | ||
__lambdaLocal: { | ||
onInvocationEnd: this.onInvocationEnd | ||
}, | ||
}; | ||
@@ -147,2 +154,3 @@ return ctx; | ||
Context.prototype.done = function (err, message) { | ||
var _a; | ||
// May only be called once | ||
@@ -198,2 +206,6 @@ if (this._stopped) { | ||
this.finalCallback(); //Destroy env... | ||
var isStream = typeof message === "object" && (message === null || message === void 0 ? void 0 : message.body) instanceof streaming_js_1.StreamingBody; | ||
if (!isStream) { | ||
(_a = this.onInvocationEnd) === null || _a === void 0 ? void 0 : _a.call(this); | ||
} | ||
/* | ||
@@ -200,0 +212,0 @@ The finalCallback method will be instantly called if 'this.callbackWaitsForEmptyEventLoop' is False |
@@ -9,2 +9,11 @@ /** | ||
*/ | ||
export {}; | ||
/// <reference types="node" /> | ||
import { PassThrough } from "stream"; | ||
export declare class StreamingBody extends PassThrough { | ||
private readonly resolve; | ||
constructor(resolve: (metadata: any) => void); | ||
headersSent: boolean; | ||
sendHeader(metadata?: any): void; | ||
private contentType; | ||
setContentType(contentType: any): void; | ||
} |
@@ -73,2 +73,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.StreamingBody = void 0; | ||
var stream_1 = require("stream"); | ||
@@ -80,19 +81,22 @@ function streamifyResponse(handler) { | ||
var body, metadata, error_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
var _a, _b, _c, _d; | ||
return __generator(this, function (_e) { | ||
switch (_e.label) { | ||
case 0: | ||
body = new StreamingBody(resolve); | ||
_a.label = 1; | ||
_e.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
_e.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, handler(event, body, context)]; | ||
case 2: | ||
metadata = _a.sent(); | ||
metadata = _e.sent(); | ||
if (!body.headersSent) { | ||
body.sendHeader(metadata); | ||
} | ||
(_b = (_a = context.__lambdaLocal).onInvocationEnd) === null || _b === void 0 ? void 0 : _b.call(_a); | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
error_1 = _a.sent(); | ||
error_1 = _e.sent(); | ||
reject(error_1); | ||
(_d = (_c = context.__lambdaLocal).onInvocationEnd) === null || _d === void 0 ? void 0 : _d.call(_c, error_1); | ||
return [3 /*break*/, 4]; | ||
@@ -127,2 +131,3 @@ case 4: return [2 /*return*/]; | ||
}(stream_1.PassThrough)); | ||
exports.StreamingBody = StreamingBody; | ||
var HttpResponseStream = /** @class */ (function () { | ||
@@ -129,0 +134,0 @@ function HttpResponseStream() { |
{ | ||
"name": "lambda-local", | ||
"version": "2.1.2", | ||
"description": "Commandline tool to run Lambda functions on your local machine.", | ||
"version": "2.2.0", | ||
"description": "Commandline tool and API to run Lambda functions on your local machine.", | ||
"main": "build/lambdalocal.js", | ||
@@ -6,0 +6,0 @@ "types": "build/lambdalocal.d.ts", |
@@ -71,5 +71,7 @@ # Lambda-local | ||
| `envdestroy`|optional, destroy added environment on closing, default to false| | ||
| `verboseLevel`|optional, default 3. Level 2 dismiss handler() text, level 1 dismiss lambda-local text and level 0 dismiss also the result.| | ||
| `verboseLevel`|optional, default 3. Level 2 dismiss handler() text, level 1 dismiss lambda-local text and level 0 dismiss also the result. Level -1 only displays handler() text.| | ||
| `callback`|optional, lambda third parameter [callback][1]. When left out a Promise is returned| | ||
| `onInvocationEnd`|optional. called once the invocation ended. useful when awslambda.streamifyResponse is used to distinguish between end of response stream and end of invocation. | | ||
| `clientContext`|optional, used to populated clientContext property of lambda second parameter (context) | ||
| `contextOverwrite`| optional, a function that overwrites the context object. It can get and overwrite the values of the context (such as awsRequestId). | | ||
@@ -76,0 +78,0 @@ #### `lambdaLocal.setLogger(logger)` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
71935
1574
232