From 4f00a1a2eed898d0371233d24e24b283b87eb9d4 Mon Sep 17 00:00:00 2001 From: Andres Vargas Date: Tue, 8 Sep 2020 12:26:41 -0500 Subject: [PATCH 1/8] better handler --- index.js | 301 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 170 insertions(+), 131 deletions(-) diff --git a/index.js b/index.js index f5efbc2..700ec88 100644 --- a/index.js +++ b/index.js @@ -1,18 +1,18 @@ -'use strict'; +"use strict"; /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -const aws = require('aws-sdk'); -const debug = require('debug')('engine:lambda'); -const A = require('async'); -const _ = require('lodash'); -const helpers = require('artillery/core/lib/engine_util'); +const aws = require("aws-sdk"); +const debug = require("debug")("engine:lambda"); +const A = require("async"); +const _ = require("lodash"); +const helpers = require("artillery/core/lib/engine_util"); -const utils = require('./utils'); +const utils = require("./utils"); -function LambdaEngine (script, ee) { +function LambdaEngine(script, ee) { this.script = script; this.ee = ee; this.helpers = helpers; @@ -23,107 +23,125 @@ function LambdaEngine (script, ee) { return this; } -LambdaEngine.prototype.createScenario = function createScenario (scenarioSpec, ee) { - +LambdaEngine.prototype.createScenario = function createScenario( + scenarioSpec, + ee +) { // as for http engine we add before and after scenario hook // as normal functions in scenario's steps - const beforeScenarioFns = _.map( - scenarioSpec.beforeScenario, - function(hookFunctionName) { - return {'function': hookFunctionName}; - }); - const afterScenarioFns = _.map( - scenarioSpec.afterScenario, - function(hookFunctionName) { - return {'function': hookFunctionName}; - }); + const beforeScenarioFns = _.map(scenarioSpec.beforeScenario, function( + hookFunctionName + ) { + return { function: hookFunctionName }; + }); + const afterScenarioFns = _.map(scenarioSpec.afterScenario, function( + hookFunctionName + ) { + return { function: hookFunctionName }; + }); const newFlow = beforeScenarioFns.concat( - scenarioSpec.flow.concat(afterScenarioFns)); + scenarioSpec.flow.concat(afterScenarioFns) + ); scenarioSpec.flow = newFlow; - const tasks = scenarioSpec.flow.map(rs => this.step(rs, ee, { - beforeRequest: scenarioSpec.beforeRequest, - afterResponse: scenarioSpec.afterResponse, - })); + const tasks = scenarioSpec.flow.map(rs => + this.step(rs, ee, { + beforeRequest: scenarioSpec.beforeRequest, + afterResponse: scenarioSpec.afterResponse + }) + ); return this.compile(tasks, scenarioSpec.flow, ee); }; -LambdaEngine.prototype.step = function step (rs, ee, opts) { +LambdaEngine.prototype.step = function step(rs, ee, opts) { opts = opts || {}; let self = this; if (rs.loop) { - let steps = _.map(rs.loop, function (rs) { + let steps = _.map(rs.loop, function(rs) { return self.step(rs, ee, opts); }); - return this.helpers.createLoopWithCount( - rs.count || -1, - steps, - { - loopValue: rs.loopValue || '$loopCount', - overValues: rs.over, - whileTrue: self.config.processor - ? self.config.processor[rs.whileTrue] : undefined - }); + return this.helpers.createLoopWithCount(rs.count || -1, steps, { + loopValue: rs.loopValue || "$loopCount", + overValues: rs.over, + whileTrue: self.config.processor + ? self.config.processor[rs.whileTrue] + : undefined + }); } if (rs.log) { - return function log (context, callback) { - return process.nextTick(function () { callback(null, context); }); + return function log(context, callback) { + return process.nextTick(function() { + callback(null, context); + }); }; } if (rs.think) { - return this.helpers.createThink(rs, _.get(self.config, 'defaults.think', {})); + return this.helpers.createThink( + rs, + _.get(self.config, "defaults.think", {}) + ); } if (rs.function) { - return function (context, callback) { + return function(context, callback) { let func = self.config.processor[rs.function]; if (!func) { - return process.nextTick(function () { callback(null, context); }); + return process.nextTick(function() { + callback(null, context); + }); } - return func(context, ee, function () { + return func(context, ee, function() { return callback(null, context); }); }; } if (rs.invoke) { - return function invoke (context, callback) { - + return function invoke(context, callback) { context.funcs.$increment = self.$increment; context.funcs.$decrement = self.$decrement; - context.funcs.$contextUid = function () { + context.funcs.$contextUid = function() { return context._uid; }; - const payload = typeof rs.invoke.payload === 'object' - ? JSON.stringify(rs.invoke.payload) - : String(rs.invoke.payload); + const payload = + typeof rs.invoke.payload === "object" + ? JSON.stringify(rs.invoke.payload) + : String(rs.invoke.payload); // see documentation for a description of these fields // https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html#invoke-property var awsParams = { - ClientContext: Buffer.from(rs.invoke.clientContext || '{}').toString('base64'), + ClientContext: Buffer.from(rs.invoke.clientContext || "{}").toString( + "base64" + ), FunctionName: rs.invoke.target || self.script.config.target, - InvocationType: rs.invoke.invocationType || 'Event', - LogType: rs.invoke.logType || 'Tail', + InvocationType: rs.invoke.invocationType || "Event", + LogType: rs.invoke.logType || "Tail", Payload: helpers.template(payload, context), - Qualifier: rs.invoke.qualifier || '$LATEST' + Qualifier: rs.invoke.qualifier || "$LATEST" }; // build object to pass to hooks // we do not pass only aws params but also additional information // we need to make the engine work with other plugins - const params = _.assign({ - url: context.lambda.endpoint.href, - awsParams: awsParams, - }, rs.invoke); - - const beforeRequestFunctionNames = _.concat(opts.beforeRequest || [], rs.invoke.beforeRequest || []); + const params = _.assign( + { + url: context.lambda.endpoint.href, + awsParams: awsParams + }, + rs.invoke + ); + + const beforeRequestFunctionNames = _.concat( + opts.beforeRequest || [], + rs.invoke.beforeRequest || [] + ); utils.processBeforeRequestFunctions( self.script, @@ -137,7 +155,7 @@ LambdaEngine.prototype.step = function step (rs, ee, opts) { return callback(err, context); } - ee.emit('request'); + ee.emit("request"); const startedAt = process.hrtime(); // after running "before request" functions @@ -146,89 +164,112 @@ LambdaEngine.prototype.step = function step (rs, ee, opts) { awsParams.Payload = helpers.template(payload, context); // invoke lambda function - context.lambda.invoke(awsParams, function (err, data) { - + context.lambda.invoke(awsParams, function(err, data) { if (err) { debug(err); - ee.emit('error', err); + ee.emit("error", err); return callback(err, context); + } else if (data.FunctionError) { + ee.emit("error", data.FunctionError); + return callback(data.FunctionError, context); } - let code = data.StatusCode || 0; - const endedAt = process.hrtime(startedAt); - let delta = (endedAt[0] * 1e9) + endedAt[1]; - ee.emit('response', delta, code, context._uid); - // AWS output is a generic string // we need to guess its content type const payload = utils.tryToParse(data.Payload); + let response; + if (awsParams.InvocationType === "RequestRsponse") { + // we build a fake http response + // it is needed to make the lib work with other plugins + // such as https://github.com/artilleryio/artillery-plugin-expect + response = { + body: payload.body.body, + statusCode: payload.body.statusCode, + headers: { + "content-type": payload.contentType + } + }; + if (response.statusCode != 200) { + ee.emit("error", response.statusCode); + return callback(response.statusCode, context); + } + } else { + response = { + body: payload.body, + statusCode: data.StatusCode, + body: payload.body.body, + statusCode: payload.body.statusCode, + headers: { + "content-type": payload.contentType + } + }; + } - // we build a fake http response - // it is needed to make the lib work with other plugins - // such as https://github.com/artilleryio/artillery-plugin-expect - const response = { - body: payload.body, - statusCode: data.StatusCode, - headers: { - 'content-type': payload.contentType - }, - }; - helpers.captureOrMatch( - params, - response, - context, - function captured(err, result) { - if(result && result.captures) { - // TODO handle matches - let haveFailedCaptures = _.some(result.captures, function(v, k) { - return v === ''; - }); - - if (!haveFailedCaptures) { - _.each(result.captures, function(v, k) { - _.set(context.vars, k, v); - }); - } + let code = data.StatusCode || 0; + const endedAt = process.hrtime(startedAt); + let delta = endedAt[0] * 1e9 + endedAt[1]; + ee.emit("response", delta, code, context._uid); + + debug("response=", response); + helpers.captureOrMatch(params, response, context, function captured( + err, + result + ) { + if (result && result.captures) { + // TODO handle matches + let haveFailedCaptures = _.some(result.captures, function( + v, + k + ) { + return v === ""; + }); + + if (!haveFailedCaptures) { + _.each(result.captures, function(v, k) { + _.set(context.vars, k, v); + }); } + } - const afterResponseFunctionNames = _.concat(opts.afterResponse || [], rs.invoke.afterResponse || []); - - utils.processAfterResponseFunctions( - self.script, - afterResponseFunctionNames, - params, - response, - context, - ee, - function done(err) { - if (err) { - debug(err); - return callback(err, context); - } - - return callback(null, context); + const afterResponseFunctionNames = _.concat( + opts.afterResponse || [], + rs.invoke.afterResponse || [] + ); + + utils.processAfterResponseFunctions( + self.script, + afterResponseFunctionNames, + params, + response, + context, + ee, + function done(err) { + if (err) { + debug(err); + return callback(err, context); } - ); - } - ); + return callback(null, context); + } + ); + }); }); } - ) + ); }; } - return function (context, callback) { + return function(context, callback) { return callback(null, context); }; }; -LambdaEngine.prototype.compile = function compile (tasks, scenarioSpec, ee) { +LambdaEngine.prototype.compile = function compile(tasks, scenarioSpec, ee) { const self = this; - return function scenario (initialContext, callback) { - const init = function init (next) { + return function scenario(initialContext, callback) { + const init = function init(next) { let opts = { - region: self.script.config.lambda.region || 'us-east-1' + region: self.script.config.lambda.region || "us-east-1" }; if (self.script.config.lambda.function) { @@ -236,31 +277,29 @@ LambdaEngine.prototype.compile = function compile (tasks, scenarioSpec, ee) { } initialContext.lambda = new aws.Lambda(opts); - ee.emit('started'); + ee.emit("started"); return next(null, initialContext); }; let steps = [init].concat(tasks); - A.waterfall( - steps, - function done (err, context) { - if (err) { - debug(err); - } + A.waterfall(steps, function done(err, context) { + if (err) { + debug(err); + } - return callback(err, context); - }); + return callback(err, context); + }); }; }; -LambdaEngine.prototype.$increment = function $increment (value) { - let result = Number.isInteger(value) ? value += 1 : NaN; +LambdaEngine.prototype.$increment = function $increment(value) { + let result = Number.isInteger(value) ? (value += 1) : NaN; return result; }; -LambdaEngine.prototype.$decrement = function $decrement (value) { - let result = Number.isInteger(value) ? value -= 1 : NaN; +LambdaEngine.prototype.$decrement = function $decrement(value) { + let result = Number.isInteger(value) ? (value -= 1) : NaN; return result; }; From 5d64b59d91f6a4d5401acee4b173de658f6e5a1a Mon Sep 17 00:00:00 2001 From: Andres Vargas Date: Tue, 8 Sep 2020 13:17:29 -0500 Subject: [PATCH 2/8] fix typo --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 700ec88..0660fd7 100644 --- a/index.js +++ b/index.js @@ -178,7 +178,7 @@ LambdaEngine.prototype.step = function step(rs, ee, opts) { // we need to guess its content type const payload = utils.tryToParse(data.Payload); let response; - if (awsParams.InvocationType === "RequestRsponse") { + if (awsParams.InvocationType === "RequestResponse") { // we build a fake http response // it is needed to make the lib work with other plugins // such as https://github.com/artilleryio/artillery-plugin-expect From 92723a643f8657af3ca20a38ac21ac82f2f9fd8a Mon Sep 17 00:00:00 2001 From: Andres Vargas Date: Fri, 18 Sep 2020 12:24:29 -0500 Subject: [PATCH 3/8] rollback eslint changes, yes i know it is too much changes --- index.js | 242 ++++++++++++++++++++++++++----------------------------- 1 file changed, 113 insertions(+), 129 deletions(-) diff --git a/index.js b/index.js index 0660fd7..d2eac4a 100644 --- a/index.js +++ b/index.js @@ -1,18 +1,18 @@ -"use strict"; +'use strict'; /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -const aws = require("aws-sdk"); -const debug = require("debug")("engine:lambda"); -const A = require("async"); -const _ = require("lodash"); -const helpers = require("artillery/core/lib/engine_util"); +const aws = require('aws-sdk'); +const debug = require('debug')('engine:lambda'); +const A = require('async'); +const _ = require('lodash'); +const helpers = require('artillery/core/lib/engine_util'); -const utils = require("./utils"); +const utils = require('./utils'); -function LambdaEngine(script, ee) { +function LambdaEngine (script, ee) { this.script = script; this.ee = ee; this.helpers = helpers; @@ -23,125 +23,111 @@ function LambdaEngine(script, ee) { return this; } -LambdaEngine.prototype.createScenario = function createScenario( - scenarioSpec, - ee -) { +LambdaEngine.prototype.createScenario = function createScenario (scenarioSpec, ee) { + // as for http engine we add before and after scenario hook // as normal functions in scenario's steps - const beforeScenarioFns = _.map(scenarioSpec.beforeScenario, function( - hookFunctionName - ) { - return { function: hookFunctionName }; - }); - const afterScenarioFns = _.map(scenarioSpec.afterScenario, function( - hookFunctionName - ) { - return { function: hookFunctionName }; - }); + const beforeScenarioFns = _.map( + scenarioSpec.beforeScenario, + function(hookFunctionName) { + return {'function': hookFunctionName}; + }); + const afterScenarioFns = _.map( + scenarioSpec.afterScenario, + function(hookFunctionName) { + return {'function': hookFunctionName}; + }); const newFlow = beforeScenarioFns.concat( - scenarioSpec.flow.concat(afterScenarioFns) - ); + scenarioSpec.flow.concat(afterScenarioFns)); scenarioSpec.flow = newFlow; - const tasks = scenarioSpec.flow.map(rs => - this.step(rs, ee, { - beforeRequest: scenarioSpec.beforeRequest, - afterResponse: scenarioSpec.afterResponse - }) - ); + const tasks = scenarioSpec.flow.map(rs => this.step(rs, ee, { + beforeRequest: scenarioSpec.beforeRequest, + afterResponse: scenarioSpec.afterResponse, + })); return this.compile(tasks, scenarioSpec.flow, ee); }; -LambdaEngine.prototype.step = function step(rs, ee, opts) { +LambdaEngine.prototype.step = function step (rs, ee, opts) { opts = opts || {}; let self = this; if (rs.loop) { - let steps = _.map(rs.loop, function(rs) { + let steps = _.map(rs.loop, function (rs) { return self.step(rs, ee, opts); }); - return this.helpers.createLoopWithCount(rs.count || -1, steps, { - loopValue: rs.loopValue || "$loopCount", - overValues: rs.over, - whileTrue: self.config.processor - ? self.config.processor[rs.whileTrue] - : undefined - }); + return this.helpers.createLoopWithCount( + rs.count || -1, + steps, + { + loopValue: rs.loopValue || '$loopCount', + overValues: rs.over, + whileTrue: self.config.processor + ? self.config.processor[rs.whileTrue] : undefined + }); } if (rs.log) { - return function log(context, callback) { - return process.nextTick(function() { - callback(null, context); - }); + return function log (context, callback) { + return process.nextTick(function () { callback(null, context); }); }; } if (rs.think) { - return this.helpers.createThink( - rs, - _.get(self.config, "defaults.think", {}) - ); + return this.helpers.createThink(rs, _.get(self.config, 'defaults.think', {})); } if (rs.function) { - return function(context, callback) { + return function (context, callback) { let func = self.config.processor[rs.function]; if (!func) { - return process.nextTick(function() { - callback(null, context); - }); + return process.nextTick(function () { callback(null, context); }); } - return func(context, ee, function() { + return func(context, ee, function () { return callback(null, context); }); }; } if (rs.invoke) { - return function invoke(context, callback) { + return function invoke (context, callback) { + context.funcs.$increment = self.$increment; context.funcs.$decrement = self.$decrement; - context.funcs.$contextUid = function() { + context.funcs.$contextUid = function () { return context._uid; }; - const payload = - typeof rs.invoke.payload === "object" - ? JSON.stringify(rs.invoke.payload) - : String(rs.invoke.payload); + + const payload = typeof rs.invoke.payload === 'object' + ? JSON.stringify(rs.invoke.payload) + : String(rs.invoke.payload); + // see documentation for a description of these fields // https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html#invoke-property var awsParams = { - ClientContext: Buffer.from(rs.invoke.clientContext || "{}").toString( - "base64" - ), + ClientContext: Buffer.from(rs.invoke.clientContext || '{}').toString('base64'), FunctionName: rs.invoke.target || self.script.config.target, - InvocationType: rs.invoke.invocationType || "Event", - LogType: rs.invoke.logType || "Tail", + InvocationType: rs.invoke.invocationType || 'Event', + LogType: rs.invoke.logType || 'Tail', Payload: helpers.template(payload, context), - Qualifier: rs.invoke.qualifier || "$LATEST" + Qualifier: rs.invoke.qualifier || '$LATEST' }; + // build object to pass to hooks // we do not pass only aws params but also additional information // we need to make the engine work with other plugins - const params = _.assign( - { - url: context.lambda.endpoint.href, - awsParams: awsParams - }, - rs.invoke - ); - - const beforeRequestFunctionNames = _.concat( - opts.beforeRequest || [], - rs.invoke.beforeRequest || [] - ); + const params = _.assign({ + url: context.lambda.endpoint.href, + awsParams: awsParams, + }, rs.invoke); + + + const beforeRequestFunctionNames = _.concat(opts.beforeRequest || [], rs.invoke.beforeRequest || []); utils.processBeforeRequestFunctions( self.script, @@ -155,7 +141,7 @@ LambdaEngine.prototype.step = function step(rs, ee, opts) { return callback(err, context); } - ee.emit("request"); + ee.emit('request'); const startedAt = process.hrtime(); // after running "before request" functions @@ -164,10 +150,11 @@ LambdaEngine.prototype.step = function step(rs, ee, opts) { awsParams.Payload = helpers.template(payload, context); // invoke lambda function - context.lambda.invoke(awsParams, function(err, data) { + context.lambda.invoke(awsParams, function (err, data) { + if (err) { debug(err); - ee.emit("error", err); + ee.emit('error', err); return callback(err, context); } else if (data.FunctionError) { ee.emit("error", data.FunctionError); @@ -210,20 +197,16 @@ LambdaEngine.prototype.step = function step(rs, ee, opts) { let delta = endedAt[0] * 1e9 + endedAt[1]; ee.emit("response", delta, code, context._uid); - debug("response=", response); - helpers.captureOrMatch(params, response, context, function captured( - err, - result - ) { - if (result && result.captures) { + helpers.captureOrMatch( + params, + response, + context, + function captured(err, result) { // TODO handle matches - let haveFailedCaptures = _.some(result.captures, function( - v, - k - ) { - return v === ""; + let haveFailedCaptures = _.some(result.captures, function(v, k) { + return v === ''; }); - + if (!haveFailedCaptures) { _.each(result.captures, function(v, k) { _.set(context.vars, k, v); @@ -231,45 +214,44 @@ LambdaEngine.prototype.step = function step(rs, ee, opts) { } } - const afterResponseFunctionNames = _.concat( - opts.afterResponse || [], - rs.invoke.afterResponse || [] - ); - - utils.processAfterResponseFunctions( - self.script, - afterResponseFunctionNames, - params, - response, - context, - ee, - function done(err) { - if (err) { - debug(err); - return callback(err, context); + const afterResponseFunctionNames = _.concat(opts.afterResponse || [], rs.invoke.afterResponse || []); + + utils.processAfterResponseFunctions( + self.script, + afterResponseFunctionNames, + params, + response, + context, + ee, + function done(err) { + if (err) { + debug(err); + return callback(err, context); + } + + return callback(null, context); } - - return callback(null, context); - } - ); - }); + ); + } + ); + }); } - ); + ) }; } - return function(context, callback) { + return function (context, callback) { return callback(null, context); }; }; -LambdaEngine.prototype.compile = function compile(tasks, scenarioSpec, ee) { +LambdaEngine.prototype.compile = function compile (tasks, scenarioSpec, ee) { const self = this; - return function scenario(initialContext, callback) { - const init = function init(next) { + return function scenario (initialContext, callback) { + const init = function init (next) { let opts = { - region: self.script.config.lambda.region || "us-east-1" + region: self.script.config.lambda.region || 'us-east-1' }; if (self.script.config.lambda.function) { @@ -277,29 +259,31 @@ LambdaEngine.prototype.compile = function compile(tasks, scenarioSpec, ee) { } initialContext.lambda = new aws.Lambda(opts); - ee.emit("started"); + ee.emit('started'); return next(null, initialContext); }; let steps = [init].concat(tasks); - A.waterfall(steps, function done(err, context) { - if (err) { - debug(err); - } + A.waterfall( + steps, + function done (err, context) { + if (err) { + debug(err); + } - return callback(err, context); - }); + return callback(err, context); + }); }; }; -LambdaEngine.prototype.$increment = function $increment(value) { - let result = Number.isInteger(value) ? (value += 1) : NaN; +LambdaEngine.prototype.$increment = function $increment (value) { + let result = Number.isInteger(value) ? value += 1 : NaN; return result; }; -LambdaEngine.prototype.$decrement = function $decrement(value) { - let result = Number.isInteger(value) ? (value -= 1) : NaN; +LambdaEngine.prototype.$decrement = function $decrement (value) { + let result = Number.isInteger(value) ? value -= 1 : NaN; return result; }; From a99e107f06e99d4d03b642cb4a0478129bc4398b Mon Sep 17 00:00:00 2001 From: Andres Vargas Date: Fri, 18 Sep 2020 12:28:14 -0500 Subject: [PATCH 4/8] missing if --- index.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index d2eac4a..9bb11da 100644 --- a/index.js +++ b/index.js @@ -202,17 +202,18 @@ LambdaEngine.prototype.step = function step (rs, ee, opts) { response, context, function captured(err, result) { - // TODO handle matches - let haveFailedCaptures = _.some(result.captures, function(v, k) { - return v === ''; - }); - - if (!haveFailedCaptures) { - _.each(result.captures, function(v, k) { - _.set(context.vars, k, v); - }); + if( result && results.captures) { + // TODO handle matches + let haveFailedCaptures = _.some(result.captures, function(v, k) { + return v === ''; + }); + + if (!haveFailedCaptures) { + _.each(result.captures, function(v, k) { + _.set(context.vars, k, v); + }); + } } - } const afterResponseFunctionNames = _.concat(opts.afterResponse || [], rs.invoke.afterResponse || []); From d5bd15f934426d659e5c480d5bbf7404391cbd33 Mon Sep 17 00:00:00 2001 From: Andres Vargas Date: Fri, 18 Sep 2020 12:31:04 -0500 Subject: [PATCH 5/8] remove spaces --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 9bb11da..4edc650 100644 --- a/index.js +++ b/index.js @@ -207,7 +207,7 @@ LambdaEngine.prototype.step = function step (rs, ee, opts) { let haveFailedCaptures = _.some(result.captures, function(v, k) { return v === ''; }); - + if (!haveFailedCaptures) { _.each(result.captures, function(v, k) { _.set(context.vars, k, v); @@ -229,13 +229,13 @@ LambdaEngine.prototype.step = function step (rs, ee, opts) { debug(err); return callback(err, context); } - + return callback(null, context); } ); } ); - + }); } ) From ebd30848ff23a256e3de9361ec87158277dc6641 Mon Sep 17 00:00:00 2001 From: Andres Vargas Date: Fri, 18 Sep 2020 12:32:07 -0500 Subject: [PATCH 6/8] remove more spaces --- index.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/index.js b/index.js index 4edc650..b02322e 100644 --- a/index.js +++ b/index.js @@ -102,11 +102,9 @@ LambdaEngine.prototype.step = function step (rs, ee, opts) { context.funcs.$contextUid = function () { return context._uid; }; - const payload = typeof rs.invoke.payload === 'object' ? JSON.stringify(rs.invoke.payload) : String(rs.invoke.payload); - // see documentation for a description of these fields // https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html#invoke-property var awsParams = { @@ -126,7 +124,6 @@ LambdaEngine.prototype.step = function step (rs, ee, opts) { awsParams: awsParams, }, rs.invoke); - const beforeRequestFunctionNames = _.concat(opts.beforeRequest || [], rs.invoke.beforeRequest || []); utils.processBeforeRequestFunctions( @@ -235,7 +232,6 @@ LambdaEngine.prototype.step = function step (rs, ee, opts) { ); } ); - }); } ) From b985fe6bfde2e86a597166f6a3e5eeb0ab594b14 Mon Sep 17 00:00:00 2001 From: Andres Vargas Date: Fri, 18 Sep 2020 12:32:48 -0500 Subject: [PATCH 7/8] remove more spaces --- index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/index.js b/index.js index b02322e..ded0338 100644 --- a/index.js +++ b/index.js @@ -115,7 +115,6 @@ LambdaEngine.prototype.step = function step (rs, ee, opts) { Payload: helpers.template(payload, context), Qualifier: rs.invoke.qualifier || '$LATEST' }; - // build object to pass to hooks // we do not pass only aws params but also additional information // we need to make the engine work with other plugins From 7ca725259f106e9d37f00e340ba09ef2a5e797ed Mon Sep 17 00:00:00 2001 From: Andres Vargas Date: Fri, 18 Sep 2020 12:42:39 -0500 Subject: [PATCH 8/8] missing typo --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index ded0338..888637c 100644 --- a/index.js +++ b/index.js @@ -198,7 +198,7 @@ LambdaEngine.prototype.step = function step (rs, ee, opts) { response, context, function captured(err, result) { - if( result && results.captures) { + if( result && result.captures) { // TODO handle matches let haveFailedCaptures = _.some(result.captures, function(v, k) { return v === '';