fast-gateway
Version:
A Node.js API Gateway for the masses!
38 lines (31 loc) • 925 B
JavaScript
module.exports = (() => {
let fastProxyLite, httpLambdaProxy, fastProxyLegacy
return ({ proxyType, opts, route }) => {
const base = opts.targetOverride || route.target
const config = route.proxyConfig || {}
switch (proxyType) {
case 'http':
fastProxyLite = fastProxyLite || require('fast-proxy-lite')
return fastProxyLite({
base,
...config
}).proxy
case 'lambda':
httpLambdaProxy = httpLambdaProxy || require('http-lambda-proxy')
return httpLambdaProxy({
target: base,
region: 'eu-central-1',
...config
})
case 'http-legacy':
fastProxyLegacy = fastProxyLegacy || require('fast-proxy')
return fastProxyLegacy({
base,
...config
}).proxy
default:
throw new Error(`Unsupported proxy type: ${proxyType}!`)
}
}
})()