Skip to content

Commit 3ecbd1e

Browse files
author
Richard Connon
committed
Remove FN_FORMAT variable handling
1 parent da5b48e commit 3ecbd1e

File tree

2 files changed

+1
-61
lines changed

2 files changed

+1
-61
lines changed

fn-fdk.js

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,7 @@ const fnFunctionExceptionMessage = 'Exception in function, consult logs for deta
2424
* @param fnfunction {fnHandler} the function to invoke
2525
* @param options {object}
2626
*/
27-
exports.handle = function (fnfunction, options) {
28-
let fnFormat = process.env['FN_FORMAT'] || ''
29-
let fdkHandler
30-
31-
// format has been explicitly specified
32-
switch (fnFormat.toLowerCase()) {
33-
case 'http-stream':
34-
fdkHandler = handleHTTPStream
35-
break
36-
default:
37-
console.warn(
38-
`The Node.js FDK does not support the '${fnFormat}' format, change the function format to 'http-stream'. Exiting)`)
39-
process.exit(2)
40-
}
41-
42-
return fdkHandler(fnfunction, options)
43-
}
27+
exports.handle = handleHTTPStream
4428

4529
/**
4630
* A function result = this causes the handler wrapper to use a specific response writer

test/fn-fdk-test.js

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,6 @@ const path = require('path')
66
const fs = require('fs')
77
const rewire = require('rewire')
88

9-
test('reject missing format env ', function (t) {
10-
let fdk = rewire('../fn-fdk.js')
11-
fdk.__set__(
12-
{
13-
process: {
14-
env: {
15-
FN_LISTENER: 'unix:/tmp/foo.sock'
16-
},
17-
exit: function (code) {
18-
t.equals(code, 2)
19-
throw new Error('got exit')
20-
}
21-
}
22-
})
23-
try {
24-
fdk.handle(null)
25-
t.fail()
26-
} catch (e) {
27-
t.end()
28-
}
29-
})
30-
319
test('reject missing listener env ', function (t) {
3210
let fdk = rewire('../fn-fdk.js')
3311
fdk.__set__(
@@ -50,28 +28,6 @@ test('reject missing listener env ', function (t) {
5028
}
5129
})
5230

53-
test('reject invalid format', function (t) {
54-
let fdk = rewire('../fn-fdk.js')
55-
fdk.__set__(
56-
{
57-
process: {
58-
env: {
59-
FN_FORMAT: ''
60-
},
61-
exit: function (code) {
62-
t.equals(code, 2)
63-
throw new Error('got exit')
64-
}
65-
}
66-
})
67-
try {
68-
fdk.handle(null)
69-
t.fail()
70-
} catch (e) {
71-
t.end()
72-
}
73-
})
74-
7531
test('Listens and accepts request', function (t) {
7632
let fdk = rewire('../fn-fdk.js')
7733
let tmpDir = tmp.dirSync({})

0 commit comments

Comments
 (0)