Skip to content
This repository has been archived by the owner on Jul 12, 2019. It is now read-only.

fix regression where env is ignored #154

Merged
merged 2 commits into from
May 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions include/zapierwrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,5 @@
const path = require('path');
const zapier = require('zapier-platform-core');
const appPath = path.resolve(__dirname, 'index.js');
let opts;
try {
opts = require(appPath).flags;
} catch (error) {
// nothing to see here
}
module.exports = { handler: zapier.createAppHandler(appPath, opts) };
// don't `require(appPath)` out here
module.exports = { handler: zapier.createAppHandler(appPath) };
3 changes: 1 addition & 2 deletions src/tools/create-app-tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ const promisifyHandler = handler => {

// A shorthand compatible wrapper for testing.
const createAppTester = (appRaw, { customStoreKey } = {}) => {
const opts = appRaw.flags;
const handler = createLambdaHandler(appRaw, opts);
const handler = createLambdaHandler(appRaw);
const createHandlerPromise = promisifyHandler(handler);

const randomSeed = genId();
Expand Down
15 changes: 8 additions & 7 deletions src/tools/create-lambda-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,8 @@ const loadApp = (event, rpc, appRawOrPath) => {
});
};

const createLambdaHandler = (appRawOrPath, { skipHttpPatch } = {}) => {
const createLambdaHandler = appRawOrPath => {
codebycaleb marked this conversation as resolved.
Show resolved Hide resolved
const handler = (event, context, callback) => {
// Adds logging for _all_ kinds of http(s) requests, no matter the library
if (!skipHttpPatch) {
const httpPatch = createHttpPatch(event);
httpPatch(require('http')); // 'https' uses 'http' under the hood
}

// Wait for all async events to complete before callback returns.
// This is not strictly necessary since this is the default now when
// using the callback; just putting it here to be explicit.
Expand Down Expand Up @@ -200,6 +194,13 @@ const createLambdaHandler = (appRawOrPath, { skipHttpPatch } = {}) => {
.then(appRaw => {
const app = createApp(appRaw);

const { skipHttpPatch } = appRaw.flags || {};
// Adds logging for _all_ kinds of http(s) requests, no matter the library
if (!skipHttpPatch) {
const httpPatch = createHttpPatch(event);
httpPatch(require('http')); // 'https' uses 'http' under the hood
}

// TODO: Avoid calling prepareApp(appRaw) repeatedly here as createApp()
// already calls prepareApp() but just doesn't return it.
const compiledApp = schemaTools.prepareApp(appRaw);
Expand Down