@@ -7,7 +7,6 @@ A super fast, framework agnostic Node.js API Gateway for the masses ❤️
77## Medium articles:
88- https://itnext.io/a-js-api-gateway-for-the-masses-a12fdb9e961c
99
10-
1110## Install
1211``` js
1312npm i fast- gateway
@@ -46,10 +45,10 @@ npm i http-lambda-proxy
4645const gateway = require (' fast-gateway' )
4746const server = gateway ({
4847 routes: [{
49- proxyType: ' lambda' ,
5048 prefix: ' /service' ,
5149 target: ' my-lambda-serverless-api' ,
52- lambdaProxy: {
50+ proxyType: ' lambda' ,
51+ proxyConfig: {
5352 region: ' eu-central-1'
5453 }
5554 }]
@@ -104,27 +103,27 @@ module.exports.handler = serverless(service)
104103 timeout: 0 ,
105104 // Optional "target" value that overrides the routes "target" config value. Feature intended for testing purposes.
106105 targetOverride: " https://yourdev.api-gateway.com" ,
106+ // Optional "Proxy Factory" implementation, allows the integration of custom proxying strategies.
107+ // Default value: require('fast-proxy-lite/lib/proxy-factory')
108+ proxyFactory : ({ proxyType, opts, route }) => {... }
107109
108110 // HTTP proxy
109111 routes: [{
110- // Optional proxy type definition. Supported values: http, lambda
112+ // Optional proxy type definition. Supported values: http, http-legacy, lambda
113+ // Modules:
114+ // - http: fast-proxy-lite
115+ // - http-legacy: fast-proxy
116+ // - lambda: http-lambda-proxy
111117 // Default value: http
112118 proxyType: ' http'
113- // Optional `fast-proxy` library configuration (https://www.npmjs.com/package/fast-proxy#options)
114- // base parameter defined as the route target. Default value: {}
115- // This settings apply only when proxyType = 'http'
116- fastProxy: {},
117- // Optional `http-lambda-proxy` library configuration (https://www.npmjs.com/package/http-lambda-proxy#options)
118- // The 'target' parameter is extracted from route.target, default region = 'eu-central-1'
119- // This settings apply only when proxyType = 'lambda'
120- lambdaProxy: {
121- region: ' eu-central-1'
122- },
119+ // Optional proxy library configuration:
120+ // - fast-proxy-lite: https://www.npmjs.com/package/fast-proxy-lite#options
121+ // - fast-proxy: https://www.npmjs.com/package/fast-proxy#options
122+ // - http-lambda-proxy: https://www.npmjs.com/package/http-lambda-proxy#options
123+ // Default value: {}
124+ proxyConfig: {},
123125 // Optional proxy handler function. Default value: (req, res, url, proxy, proxyOpts) => proxy(req, res, url, proxyOpts)
124126 proxyHandler : () => {},
125- // Optional flag to indicate if target uses the HTTP2 protocol. Default value: false
126- // This setting apply only when proxyType = 'http'
127- http2: false ,
128127 // Optional path matching regex. Default value: '/*'
129128 // In order to disable the 'pathRegex' at all, you can use an empty string: ''
130129 pathRegex: ' /*' ,
@@ -167,7 +166,7 @@ module.exports.handler = serverless(service)
167166 // ...
168167 }
169168
170- // if proxyType= 'http', other options allowed https://www.npmjs.com/package/fast-proxy#opts
169+ // if proxyType= 'http', other options allowed https://www.npmjs.com/package/fast-proxy-lite #opts
171170 }
172171 }]
173172}
@@ -384,7 +383,7 @@ routes: [{
384383
385384## Related projects
386385- middleware-if-unless (https://www.npmjs.com/package/middleware-if-unless )
387- - fast-proxy (https://www.npmjs.com/package/fast-proxy )
386+ - fast-proxy-lite (https://www.npmjs.com/package/fast-proxy-lite )
388387- http-lambda-proxy (https://www.npmjs.com/package/http-lambda-proxy )
389388- restana (https://www.npmjs.com/package/restana )
390389
@@ -402,4 +401,11 @@ Benchmark scripts can be found in benchmark folder.
402401## Support / Donate 💚
403402You can support the maintenance of this project:
404403- PayPal: https://www.paypal.me/kyberneees
405- - [ TRON] ( https://www.binance.com/en/buy-TRON ) Wallet: ` TJ5Bbf9v4kpptnRsePXYDvnYcYrS5Tyxus `
404+ - [ TRON] ( https://www.binance.com/en/buy-TRON ) Wallet: ` TJ5Bbf9v4kpptnRsePXYDvnYcYrS5Tyxus `
405+
406+
407+ ## Breaking Changes
408+ ### v3.x
409+ - The ` fast-proxy-lite ` module is used by default to support ` http ` proxy type 🔥. This means, no ` undici ` or ` http2 ` are supported by default.
410+ - The old ` fast-proxy ` module is available under the ` http-legacy ` proxy type, but the module is not installed by default.
411+ - Proxy configuration is now generalized under the ` proxyConfig ` property.
0 commit comments