Skip to content

Commit 21b5303

Browse files
committed
fix(gateway): enhance readability
1 parent 56d3a1a commit 21b5303

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

index.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,16 @@ const PROXY_TYPES = ['http', 'lambda']
1515
const registerWebSocketRoutes = require('./lib/ws-proxy')
1616

1717
const gateway = (opts) => {
18-
const proxyFactory = opts.proxyFactory ? (...args) => ((r) => r === undefined ? defaultProxyFactory(...args) : r)(opts.proxyFactory(...args)) : defaultProxyFactory
18+
let proxyFactory
19+
20+
if (opts.proxyFactory) {
21+
proxyFactory = (...args) => {
22+
const result = opts.proxyFactory(...args)
23+
return result === undefined ? defaultProxyFactory(...args) : result
24+
}
25+
} else {
26+
proxyFactory = defaultProxyFactory
27+
}
1928

2029
opts = Object.assign(
2130
{
@@ -76,7 +85,9 @@ const gateway = (opts) => {
7685
}
7786

7887
// retrieve default hooks for proxy
79-
const hooksForDefaultType = isDefaultProxyType ? require('./lib/default-hooks')[proxyType] : {}
88+
const hooksForDefaultType = isDefaultProxyType
89+
? require('./lib/default-hooks')[proxyType]
90+
: {}
8091
const { onRequestNoOp = NOOP, onResponse = NOOP } = hooksForDefaultType
8192

8293
// populating required NOOPS

0 commit comments

Comments
 (0)