From 3ecbd1e3742ea3473b8f3864a2214dc286dd412c Mon Sep 17 00:00:00 2001 From: Richard Connon Date: Fri, 16 Nov 2018 14:53:08 +0000 Subject: [PATCH] Remove FN_FORMAT variable handling --- fn-fdk.js | 18 +----------------- test/fn-fdk-test.js | 44 -------------------------------------------- 2 files changed, 1 insertion(+), 61 deletions(-) diff --git a/fn-fdk.js b/fn-fdk.js index 1c6683a..d5631c1 100644 --- a/fn-fdk.js +++ b/fn-fdk.js @@ -24,23 +24,7 @@ const fnFunctionExceptionMessage = 'Exception in function, consult logs for deta * @param fnfunction {fnHandler} the function to invoke * @param options {object} */ -exports.handle = function (fnfunction, options) { - let fnFormat = process.env['FN_FORMAT'] || '' - let fdkHandler - - // format has been explicitly specified - switch (fnFormat.toLowerCase()) { - case 'http-stream': - fdkHandler = handleHTTPStream - break - default: - console.warn( - `The Node.js FDK does not support the '${fnFormat}' format, change the function format to 'http-stream'. Exiting)`) - process.exit(2) - } - - return fdkHandler(fnfunction, options) -} +exports.handle = handleHTTPStream /** * A function result = this causes the handler wrapper to use a specific response writer diff --git a/test/fn-fdk-test.js b/test/fn-fdk-test.js index ae68dd3..4a10002 100644 --- a/test/fn-fdk-test.js +++ b/test/fn-fdk-test.js @@ -6,28 +6,6 @@ const path = require('path') const fs = require('fs') const rewire = require('rewire') -test('reject missing format env ', function (t) { - let fdk = rewire('../fn-fdk.js') - fdk.__set__( - { - process: { - env: { - FN_LISTENER: 'unix:/tmp/foo.sock' - }, - exit: function (code) { - t.equals(code, 2) - throw new Error('got exit') - } - } - }) - try { - fdk.handle(null) - t.fail() - } catch (e) { - t.end() - } -}) - test('reject missing listener env ', function (t) { let fdk = rewire('../fn-fdk.js') fdk.__set__( @@ -50,28 +28,6 @@ test('reject missing listener env ', function (t) { } }) -test('reject invalid format', function (t) { - let fdk = rewire('../fn-fdk.js') - fdk.__set__( - { - process: { - env: { - FN_FORMAT: '' - }, - exit: function (code) { - t.equals(code, 2) - throw new Error('got exit') - } - } - }) - try { - fdk.handle(null) - t.fail() - } catch (e) { - t.end() - } -}) - test('Listens and accepts request', function (t) { let fdk = rewire('../fn-fdk.js') let tmpDir = tmp.dirSync({})