Skip to content
Open
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
18 changes: 1 addition & 17 deletions fn-fdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 0 additions & 44 deletions test/fn-fdk-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
Expand All @@ -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({})
Expand Down