jimpex 7.0.1 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +87 -0
- package/LICENSE +1 -1
- package/README.md +446 -434
- package/dist/app/index.d.ts +13 -0
- package/dist/app/index.js +19 -0
- package/dist/app/index.js.map +1 -0
- package/dist/app/jimpex.d.ts +13 -0
- package/dist/app/jimpex.js +440 -0
- package/dist/app/jimpex.js.map +1 -0
- package/dist/controllers/common/config.d.ts +78 -0
- package/dist/controllers/common/config.js +89 -0
- package/dist/controllers/common/config.js.map +1 -0
- package/dist/controllers/common/health.d.ts +82 -0
- package/dist/controllers/common/health.js +97 -0
- package/dist/controllers/common/health.js.map +1 -0
- package/dist/controllers/common/index.d.ts +21 -0
- package/dist/controllers/common/index.js +21 -0
- package/dist/controllers/common/index.js.map +1 -0
- package/dist/controllers/common/statics.d.ts +215 -0
- package/dist/controllers/common/statics.js +202 -0
- package/dist/controllers/common/statics.js.map +1 -0
- package/dist/controllers/index.d.ts +24 -0
- package/dist/controllers/index.js +20 -0
- package/dist/controllers/index.js.map +1 -0
- package/dist/controllers/utils/gateway.d.ts +724 -0
- package/dist/controllers/utils/gateway.js +425 -0
- package/dist/controllers/utils/gateway.js.map +1 -0
- package/dist/controllers/utils/index.d.ts +16 -0
- package/dist/controllers/utils/index.js +19 -0
- package/dist/controllers/utils/index.js.map +1 -0
- package/dist/esm/app/index.js +2 -0
- package/dist/esm/app/index.js.map +1 -0
- package/dist/esm/app/jimpex.js +415 -0
- package/dist/esm/app/jimpex.js.map +1 -0
- package/dist/esm/chunk-T2T6Q22Z.js +11 -0
- package/dist/esm/chunk-T2T6Q22Z.js.map +1 -0
- package/dist/esm/controllers/common/config.js +62 -0
- package/dist/esm/controllers/common/config.js.map +1 -0
- package/dist/esm/controllers/common/health.js +70 -0
- package/dist/esm/controllers/common/health.js.map +1 -0
- package/dist/esm/controllers/common/index.js +4 -0
- package/dist/esm/controllers/common/index.js.map +1 -0
- package/dist/esm/controllers/common/statics.js +173 -0
- package/dist/esm/controllers/common/statics.js.map +1 -0
- package/dist/esm/controllers/index.js +3 -0
- package/dist/esm/controllers/index.js.map +1 -0
- package/dist/esm/controllers/utils/gateway.js +404 -0
- package/dist/esm/controllers/utils/gateway.js.map +1 -0
- package/dist/esm/controllers/utils/index.js +2 -0
- package/dist/esm/controllers/utils/index.js.map +1 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/middlewares/common/errorHandler.js +92 -0
- package/dist/esm/middlewares/common/errorHandler.js.map +1 -0
- package/dist/esm/middlewares/common/forceHTTPS.js +41 -0
- package/dist/esm/middlewares/common/forceHTTPS.js.map +1 -0
- package/dist/esm/middlewares/common/hsts.js +53 -0
- package/dist/esm/middlewares/common/hsts.js.map +1 -0
- package/dist/esm/middlewares/common/index.js +4 -0
- package/dist/esm/middlewares/common/index.js.map +1 -0
- package/dist/esm/middlewares/html/fastHTML.js +104 -0
- package/dist/esm/middlewares/html/fastHTML.js.map +1 -0
- package/dist/esm/middlewares/html/index.js +3 -0
- package/dist/esm/middlewares/html/index.js.map +1 -0
- package/dist/esm/middlewares/html/showHTML.js +68 -0
- package/dist/esm/middlewares/html/showHTML.js.map +1 -0
- package/dist/esm/middlewares/index.js +4 -0
- package/dist/esm/middlewares/index.js.map +1 -0
- package/dist/esm/middlewares/utils/index.js +2 -0
- package/dist/esm/middlewares/utils/index.js.map +1 -0
- package/dist/esm/middlewares/utils/versionValidator.js +101 -0
- package/dist/esm/middlewares/utils/versionValidator.js.map +1 -0
- package/dist/esm/services/common/appError.js +52 -0
- package/dist/esm/services/common/appError.js.map +1 -0
- package/dist/esm/services/common/httpError.js +19 -0
- package/dist/esm/services/common/httpError.js.map +1 -0
- package/dist/esm/services/common/index.js +17 -0
- package/dist/esm/services/common/index.js.map +1 -0
- package/dist/esm/services/common/sendFile.js +27 -0
- package/dist/esm/services/common/sendFile.js.map +1 -0
- package/dist/esm/services/frontend/frontendFs.js +38 -0
- package/dist/esm/services/frontend/frontendFs.js.map +1 -0
- package/dist/esm/services/frontend/index.js +11 -0
- package/dist/esm/services/frontend/index.js.map +1 -0
- package/dist/esm/services/html/htmlGenerator.js +144 -0
- package/dist/esm/services/html/htmlGenerator.js.map +1 -0
- package/dist/esm/services/html/index.js +11 -0
- package/dist/esm/services/html/index.js.map +1 -0
- package/dist/esm/services/http/apiClient.js +71 -0
- package/dist/esm/services/http/apiClient.js.map +1 -0
- package/dist/esm/services/http/http.js +125 -0
- package/dist/esm/services/http/http.js.map +1 -0
- package/dist/esm/services/http/index.js +17 -0
- package/dist/esm/services/http/index.js.map +1 -0
- package/dist/esm/services/http/responsesBuilder.js +105 -0
- package/dist/esm/services/http/responsesBuilder.js.map +1 -0
- package/dist/esm/services/index.js +6 -0
- package/dist/esm/services/index.js.map +1 -0
- package/dist/esm/services/utils/ensureBearerToken.js +78 -0
- package/dist/esm/services/utils/ensureBearerToken.js.map +1 -0
- package/dist/esm/services/utils/index.js +11 -0
- package/dist/esm/services/utils/index.js.map +1 -0
- package/dist/esm/types/events.js +1 -0
- package/dist/esm/types/events.js.map +1 -0
- package/dist/esm/types/express.js +1 -0
- package/dist/esm/types/express.js.map +1 -0
- package/dist/esm/types/http.js +1 -0
- package/dist/esm/types/http.js.map +1 -0
- package/dist/esm/types/index.js +7 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/types/options.js +1 -0
- package/dist/esm/types/options.js.map +1 -0
- package/dist/esm/types/utils.js +1 -0
- package/dist/esm/types/utils.js.map +1 -0
- package/dist/esm/types/wootils.js +1 -0
- package/dist/esm/types/wootils.js.map +1 -0
- package/dist/esm/utils/fns/index.js +5 -0
- package/dist/esm/utils/fns/index.js.map +1 -0
- package/dist/esm/utils/fns/others.js +6 -0
- package/dist/esm/utils/fns/others.js.map +1 -0
- package/dist/esm/utils/fns/routes.js +25 -0
- package/dist/esm/utils/fns/routes.js.map +1 -0
- package/dist/esm/utils/fns/statuses.js +6 -0
- package/dist/esm/utils/fns/statuses.js.map +1 -0
- package/dist/esm/utils/fns/text.js +6 -0
- package/dist/esm/utils/fns/text.js.map +1 -0
- package/dist/esm/utils/index.js +3 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/esm/utils/wrappers.js +41 -0
- package/dist/esm/utils/wrappers.js.map +1 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/jimpex-7eaee271.d.ts +1278 -0
- package/dist/middlewares/common/errorHandler.d.ts +131 -0
- package/dist/middlewares/common/errorHandler.js +119 -0
- package/dist/middlewares/common/errorHandler.js.map +1 -0
- package/dist/middlewares/common/forceHTTPS.d.ts +68 -0
- package/dist/middlewares/common/forceHTTPS.js +68 -0
- package/dist/middlewares/common/forceHTTPS.js.map +1 -0
- package/dist/middlewares/common/hsts.d.ts +109 -0
- package/dist/middlewares/common/hsts.js +80 -0
- package/dist/middlewares/common/hsts.js.map +1 -0
- package/dist/middlewares/common/index.d.ts +21 -0
- package/dist/middlewares/common/index.js +21 -0
- package/dist/middlewares/common/index.js.map +1 -0
- package/dist/middlewares/html/fastHTML.d.ts +180 -0
- package/dist/middlewares/html/fastHTML.js +131 -0
- package/dist/middlewares/html/fastHTML.js.map +1 -0
- package/dist/middlewares/html/index.d.ts +21 -0
- package/dist/middlewares/html/index.js +20 -0
- package/dist/middlewares/html/index.js.map +1 -0
- package/dist/middlewares/html/showHTML.d.ts +127 -0
- package/dist/middlewares/html/showHTML.js +95 -0
- package/dist/middlewares/html/showHTML.js.map +1 -0
- package/dist/middlewares/index.d.ts +30 -0
- package/dist/middlewares/index.js +21 -0
- package/dist/middlewares/index.js.map +1 -0
- package/dist/middlewares/utils/index.d.ts +19 -0
- package/dist/middlewares/utils/index.js +19 -0
- package/dist/middlewares/utils/index.js.map +1 -0
- package/dist/middlewares/utils/versionValidator.d.ts +214 -0
- package/dist/middlewares/utils/versionValidator.js +128 -0
- package/dist/middlewares/utils/versionValidator.js.map +1 -0
- package/dist/services/common/appError.d.ts +138 -0
- package/dist/services/common/appError.js +80 -0
- package/dist/services/common/appError.js.map +1 -0
- package/dist/services/common/httpError.d.ts +79 -0
- package/dist/services/common/httpError.js +44 -0
- package/dist/services/common/httpError.js.map +1 -0
- package/dist/services/common/index.d.ts +47 -0
- package/dist/services/common/index.js +41 -0
- package/dist/services/common/index.js.map +1 -0
- package/dist/services/common/sendFile.d.ts +102 -0
- package/dist/services/common/sendFile.js +51 -0
- package/dist/services/common/sendFile.js.map +1 -0
- package/dist/services/frontend/frontendFs.d.ts +96 -0
- package/dist/services/frontend/frontendFs.js +71 -0
- package/dist/services/frontend/frontendFs.js.map +1 -0
- package/dist/services/frontend/index.d.ts +40 -0
- package/dist/services/frontend/index.js +35 -0
- package/dist/services/frontend/index.js.map +1 -0
- package/dist/services/html/htmlGenerator.d.ts +237 -0
- package/dist/services/html/htmlGenerator.js +171 -0
- package/dist/services/html/htmlGenerator.js.map +1 -0
- package/dist/services/html/index.d.ts +43 -0
- package/dist/services/html/index.js +35 -0
- package/dist/services/html/index.js.map +1 -0
- package/dist/services/http/apiClient.d.ts +169 -0
- package/dist/services/http/apiClient.js +96 -0
- package/dist/services/http/apiClient.js.map +1 -0
- package/dist/services/http/http.d.ts +175 -0
- package/dist/services/http/http.js +158 -0
- package/dist/services/http/http.js.map +1 -0
- package/dist/services/http/index.d.ts +50 -0
- package/dist/services/http/index.js +41 -0
- package/dist/services/http/index.js.map +1 -0
- package/dist/services/http/responsesBuilder.d.ts +178 -0
- package/dist/services/http/responsesBuilder.js +132 -0
- package/dist/services/http/responsesBuilder.js.map +1 -0
- package/dist/services/index.d.ts +33 -0
- package/dist/services/index.js +23 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/utils/ensureBearerToken.d.ts +157 -0
- package/dist/services/utils/ensureBearerToken.js +105 -0
- package/dist/services/utils/ensureBearerToken.js.map +1 -0
- package/dist/services/utils/index.d.ts +43 -0
- package/dist/services/utils/index.js +35 -0
- package/dist/services/utils/index.js.map +1 -0
- package/dist/types/events.d.ts +13 -0
- package/dist/types/events.js +17 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/express.d.ts +10 -0
- package/dist/types/express.js +17 -0
- package/dist/types/express.js.map +1 -0
- package/dist/types/http.d.ts +79 -0
- package/dist/types/http.js +17 -0
- package/dist/types/http.js.map +1 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/index.js +24 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/options.d.ts +13 -0
- package/dist/types/options.js +17 -0
- package/dist/types/options.js.map +1 -0
- package/dist/types/utils.d.ts +48 -0
- package/dist/types/utils.js +17 -0
- package/dist/types/utils.js.map +1 -0
- package/dist/types/wootils.d.ts +4 -0
- package/dist/types/wootils.js +17 -0
- package/dist/types/wootils.js.map +1 -0
- package/dist/utils/fns/index.d.ts +5 -0
- package/dist/utils/fns/index.js +22 -0
- package/dist/utils/fns/index.js.map +1 -0
- package/dist/utils/fns/others.d.ts +17 -0
- package/dist/utils/fns/others.js +29 -0
- package/dist/utils/fns/others.js.map +1 -0
- package/dist/utils/fns/routes.d.ts +39 -0
- package/dist/utils/fns/routes.js +51 -0
- package/dist/utils/fns/routes.js.map +1 -0
- package/dist/utils/fns/statuses.d.ts +45 -0
- package/dist/utils/fns/statuses.js +35 -0
- package/dist/utils/fns/statuses.js.map +1 -0
- package/dist/utils/fns/text.d.ts +9 -0
- package/dist/utils/fns/text.js +29 -0
- package/dist/utils/fns/text.js.map +1 -0
- package/dist/utils/index.d.ts +18 -0
- package/dist/utils/index.js +20 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/wrappers.d.ts +13 -0
- package/dist/utils/wrappers.js +68 -0
- package/dist/utils/wrappers.js.map +1 -0
- package/examples/basic/404.html +12 -0
- package/examples/basic/README.md +30 -0
- package/examples/basic/app.ts +18 -0
- package/examples/basic/controller.ts +45 -0
- package/examples/basic/index.ts +19 -0
- package/examples/basic/middleware.ts +13 -0
- package/examples/basic/service.ts +11 -0
- package/package.json +59 -38
- package/src/app/index.ts +1 -0
- package/src/app/jimpex.ts +743 -0
- package/src/controllers/common/config.ts +115 -0
- package/src/controllers/common/health.ts +128 -0
- package/src/controllers/common/index.ts +3 -0
- package/src/controllers/common/statics.ts +380 -0
- package/src/controllers/index.ts +2 -0
- package/src/controllers/utils/gateway.ts +1186 -0
- package/src/controllers/utils/index.ts +1 -0
- package/src/index.ts +6 -0
- package/src/middlewares/common/errorHandler.ts +203 -0
- package/src/middlewares/common/forceHTTPS.ts +83 -0
- package/src/middlewares/common/hsts.ts +135 -0
- package/src/middlewares/common/index.ts +3 -0
- package/src/middlewares/html/fastHTML.ts +255 -0
- package/src/middlewares/html/index.ts +2 -0
- package/src/middlewares/html/showHTML.ts +165 -0
- package/src/middlewares/index.ts +3 -0
- package/src/middlewares/utils/index.ts +1 -0
- package/src/middlewares/utils/versionValidator.ts +289 -0
- package/src/services/common/appError.ts +158 -0
- package/src/services/common/httpError.ts +74 -0
- package/src/services/common/index.ts +29 -0
- package/src/services/common/sendFile.ts +106 -0
- package/src/services/frontend/frontendFs.ts +101 -0
- package/src/services/frontend/index.ts +21 -0
- package/src/services/html/htmlGenerator.ts +356 -0
- package/src/services/html/index.ts +21 -0
- package/src/services/http/apiClient.ts +221 -0
- package/src/services/http/http.ts +286 -0
- package/src/services/http/index.ts +29 -0
- package/src/services/http/responsesBuilder.ts +265 -0
- package/src/services/index.ts +5 -0
- package/src/services/utils/ensureBearerToken.ts +202 -0
- package/src/services/utils/index.ts +21 -0
- package/src/types/events.ts +303 -0
- package/src/types/express.ts +21 -0
- package/src/types/http.ts +77 -0
- package/src/types/index.ts +6 -0
- package/src/types/options.ts +248 -0
- package/src/types/utils.ts +52 -0
- package/src/types/wootils.ts +4 -0
- package/src/utils/fns/index.ts +4 -0
- package/src/utils/fns/others.ts +15 -0
- package/src/utils/fns/routes.ts +64 -0
- package/src/utils/fns/statuses.ts +44 -0
- package/src/utils/fns/text.ts +8 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/wrappers.ts +537 -0
- package/tsconfig.json +5 -8
- package/tsup.config.ts +10 -0
- package/src/app/index.js +0 -692
- package/src/constants/eventNames.js +0 -48
- package/src/constants/index.js +0 -7
- package/src/controllers/common/configuration.js +0 -116
- package/src/controllers/common/health.js +0 -79
- package/src/controllers/common/index.js +0 -7
- package/src/controllers/common/statics.js +0 -336
- package/src/controllers/index.js +0 -9
- package/src/controllers/utils/gateway.js +0 -1039
- package/src/controllers/utils/index.js +0 -3
- package/src/index.js +0 -30
- package/src/middlewares/common/errorHandler.js +0 -185
- package/src/middlewares/common/forceHTTPS.js +0 -80
- package/src/middlewares/common/hsts.js +0 -122
- package/src/middlewares/common/index.js +0 -7
- package/src/middlewares/html/fastHTML.js +0 -298
- package/src/middlewares/html/index.js +0 -5
- package/src/middlewares/html/showHTML.js +0 -167
- package/src/middlewares/index.js +0 -11
- package/src/middlewares/utils/index.js +0 -3
- package/src/middlewares/utils/versionValidator.js +0 -261
- package/src/services/common/appError.js +0 -136
- package/src/services/common/httpError.js +0 -60
- package/src/services/common/index.js +0 -25
- package/src/services/common/sendFile.js +0 -68
- package/src/services/frontend/frontendFs.js +0 -85
- package/src/services/frontend/index.js +0 -17
- package/src/services/html/htmlGenerator.js +0 -391
- package/src/services/html/index.js +0 -17
- package/src/services/http/apiClient.js +0 -148
- package/src/services/http/http.js +0 -256
- package/src/services/http/index.js +0 -25
- package/src/services/http/responsesBuilder.js +0 -193
- package/src/services/index.js +0 -15
- package/src/services/utils/ensureBearerToken.js +0 -147
- package/src/services/utils/index.js +0 -19
- package/src/types.js +0 -377
- package/src/utils/functions.js +0 -78
- package/src/utils/wrappers.js +0 -131
- package/types/app/index.d.ts +0 -417
- package/types/constants/eventNames.d.ts +0 -93
- package/types/constants/index.d.ts +0 -2
- package/types/controllers/common/configuration.d.ts +0 -71
- package/types/controllers/common/health.d.ts +0 -55
- package/types/controllers/common/index.d.ts +0 -4
- package/types/controllers/common/statics.d.ts +0 -271
- package/types/controllers/index.d.ts +0 -3
- package/types/controllers/utils/gateway.d.ts +0 -947
- package/types/controllers/utils/index.d.ts +0 -2
- package/types/index.d.ts +0 -15
- package/types/middlewares/common/errorHandler.d.ts +0 -143
- package/types/middlewares/common/forceHTTPS.d.ts +0 -64
- package/types/middlewares/common/hsts.d.ts +0 -111
- package/types/middlewares/common/index.d.ts +0 -4
- package/types/middlewares/html/fastHTML.d.ts +0 -238
- package/types/middlewares/html/index.d.ts +0 -3
- package/types/middlewares/html/showHTML.d.ts +0 -128
- package/types/middlewares/index.d.ts +0 -4
- package/types/middlewares/utils/index.d.ts +0 -2
- package/types/middlewares/utils/versionValidator.d.ts +0 -247
- package/types/services/common/appError.d.ts +0 -89
- package/types/services/common/httpError.d.ts +0 -37
- package/types/services/common/index.d.ts +0 -18
- package/types/services/common/sendFile.d.ts +0 -56
- package/types/services/frontend/frontendFs.d.ts +0 -72
- package/types/services/frontend/index.d.ts +0 -3
- package/types/services/html/htmlGenerator.d.ts +0 -298
- package/types/services/html/index.d.ts +0 -3
- package/types/services/http/apiClient.d.ts +0 -141
- package/types/services/http/http.d.ts +0 -159
- package/types/services/http/index.d.ts +0 -18
- package/types/services/http/responsesBuilder.d.ts +0 -140
- package/types/services/index.d.ts +0 -6
- package/types/services/utils/ensureBearerToken.d.ts +0 -137
- package/types/services/utils/index.d.ts +0 -16
- package/types/types.d.ts +0 -280
- package/types/utils/functions.d.ts +0 -55
- package/types/utils/wrappers.d.ts +0 -127
|
@@ -1,947 +0,0 @@
|
|
|
1
|
-
export type ExpressRouter = import('../../types').ExpressRouter;
|
|
2
|
-
export type Jimpex = import('../../app').Jimpex;
|
|
3
|
-
export type ExpressRequest = import('../../types').ExpressRequest;
|
|
4
|
-
export type ExpressResponse = import('../../types').ExpressResponse;
|
|
5
|
-
export type ExpressNext = import('../../types').ExpressNext;
|
|
6
|
-
export type ExpressMiddleware = import('../../types').ExpressMiddleware;
|
|
7
|
-
export type MiddlewareLike = import('../../types').MiddlewareLike;
|
|
8
|
-
export type HTTP = import('../../services/http/http').HTTP;
|
|
9
|
-
export type HTTPFetchOptions = import('../../services/http/http').HTTPFetchOptions;
|
|
10
|
-
export type Response = import('../../services/http/http').Response;
|
|
11
|
-
export type APIClientConfiguration = import('../../services/http/apiClient').APIClientConfiguration;
|
|
12
|
-
/**
|
|
13
|
-
* <O>
|
|
14
|
-
*/
|
|
15
|
-
export type ProviderCreator<O> = import('../../types').ProviderCreator<O>;
|
|
16
|
-
/**
|
|
17
|
-
* This object represets an HTTP method for a route the controller will mount.
|
|
18
|
-
*/
|
|
19
|
-
export type GatewayControllerRouteMethod = {
|
|
20
|
-
/**
|
|
21
|
-
* The name of the HTTP method.
|
|
22
|
-
*/
|
|
23
|
-
method: string;
|
|
24
|
-
/**
|
|
25
|
-
* The information for the endpoint responsible from creating the route.
|
|
26
|
-
*/
|
|
27
|
-
endpoint: GatewayControllerEndpointInformation;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* This object contains the information for an specific route the controller will mount.
|
|
31
|
-
*/
|
|
32
|
-
export type GatewayControllerRoute = {
|
|
33
|
-
/**
|
|
34
|
-
* The path to the endpoint relative
|
|
35
|
-
* to the entry point.
|
|
36
|
-
*/
|
|
37
|
-
path: string;
|
|
38
|
-
/**
|
|
39
|
-
* The path the route will have. This
|
|
40
|
-
* is different from `path` as it's
|
|
41
|
-
* possible for the gateway to be
|
|
42
|
-
* implemented using the `root`
|
|
43
|
-
* option.
|
|
44
|
-
*/
|
|
45
|
-
route: string;
|
|
46
|
-
/**
|
|
47
|
-
* A list with all the methods the
|
|
48
|
-
* controller will use to mount the
|
|
49
|
-
* route.
|
|
50
|
-
*/
|
|
51
|
-
methods: GatewayControllerRouteMethod[];
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Normally, you would define an endpoint with just a string path, but you can use this
|
|
55
|
-
* type of object to add extra settings.
|
|
56
|
-
*/
|
|
57
|
-
export type GatewayConfigurationEndpoint = {
|
|
58
|
-
/**
|
|
59
|
-
* The path to the endpoint relative to the entry point. It can
|
|
60
|
-
* include placeholders for parameters like `/:parameter/`.
|
|
61
|
-
*/
|
|
62
|
-
path: string;
|
|
63
|
-
/**
|
|
64
|
-
* The HTTP method for the endpoint. This will tell the gateway
|
|
65
|
-
* the type of route it should mount. If is not specified, it
|
|
66
|
-
* will use `all`.
|
|
67
|
-
*/
|
|
68
|
-
method: string;
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* A dictionary of endpoints or sub endpoints the gateway will use in order to mount
|
|
72
|
-
* routes.
|
|
73
|
-
*/
|
|
74
|
-
export type GatewayConfigurationEndpoints = {
|
|
75
|
-
/**
|
|
76
|
-
* It can be the path to an actual endpoint, a dictionary of sub endpoints, or a
|
|
77
|
-
* definition of an endpoint with settings ({@link GatewayConfigurationEndpoint }).
|
|
78
|
-
*/
|
|
79
|
-
endpointName?: string | GatewayConfigurationEndpoints | GatewayConfigurationEndpoint;
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* This is a configuration object very similar to the one {@link APIClient } uses in order
|
|
83
|
-
* to configure the endpoints; the controller uses it to create the routes and to validate
|
|
84
|
-
* the HTTP methods.
|
|
85
|
-
*/
|
|
86
|
-
export type GatewayConfiguration = {
|
|
87
|
-
/**
|
|
88
|
-
* The entry point to the API the
|
|
89
|
-
* controller will make the requests
|
|
90
|
-
* to.
|
|
91
|
-
*/
|
|
92
|
-
url: string;
|
|
93
|
-
/**
|
|
94
|
-
* A dictionary with the endpoints the
|
|
95
|
-
* gateway will make available.
|
|
96
|
-
*/
|
|
97
|
-
gateway: GatewayConfigurationEndpoints;
|
|
98
|
-
};
|
|
99
|
-
/**
|
|
100
|
-
* The options for how the gateway will handle the headers from the requests and the
|
|
101
|
-
* responses.
|
|
102
|
-
*/
|
|
103
|
-
export type GatewayControllerHeadersOptions = {
|
|
104
|
-
/**
|
|
105
|
-
* Whether or not to include the header with the
|
|
106
|
-
* request's IP address. Default `true`.
|
|
107
|
-
*/
|
|
108
|
-
useXForwardedFor: boolean;
|
|
109
|
-
/**
|
|
110
|
-
* Whether or not to copy all custom headers from
|
|
111
|
-
* the request. By custom header, it means all the
|
|
112
|
-
* headers which names start with `x-`. Default
|
|
113
|
-
* `true`.
|
|
114
|
-
*/
|
|
115
|
-
copyCustomHeaders: boolean;
|
|
116
|
-
/**
|
|
117
|
-
* A list of "known" headers the gateway will try
|
|
118
|
-
* to copy from the incoming request. Default:
|
|
119
|
-
* `['authorization','content-type', 'referer',
|
|
120
|
-
* 'user-agent']`.
|
|
121
|
-
*/
|
|
122
|
-
copy: string[];
|
|
123
|
-
/**
|
|
124
|
-
* A list of "known" headers the gateway will try
|
|
125
|
-
* to remove the response. Default:
|
|
126
|
-
* `['server', 'x-powered-by']`.
|
|
127
|
-
*/
|
|
128
|
-
remove: string[];
|
|
129
|
-
};
|
|
130
|
-
/**
|
|
131
|
-
* The options to configure how the gateway will manage the requests and the responses.
|
|
132
|
-
*/
|
|
133
|
-
export type GatewayControllerOptions = {
|
|
134
|
-
/**
|
|
135
|
-
* This is really a helper for when the gateway is used with an API client. The idea is
|
|
136
|
-
* that,
|
|
137
|
-
* by default, the routes are mounted on the controller route, but with this option, you
|
|
138
|
-
* can specify another sub path. For example: The controller is mounted on `/routes`, if
|
|
139
|
-
* you set `root` to `gateway`, all the routes will be on `/routes/gateway`.
|
|
140
|
-
* This become important (and useful) when you get the API client configuration (with
|
|
141
|
-
* `endpointsForAPIClient`): The `url` will be the controller route, but all the endpoints
|
|
142
|
-
* will be modified and prefixed with the `root`. Default `''`.
|
|
143
|
-
*/
|
|
144
|
-
root: string;
|
|
145
|
-
/**
|
|
146
|
-
* This is another option for when the gateway is used with an API client. When calling
|
|
147
|
-
* `endpointsForAPIClient`, all the endpoints will be wrapped inside an object named after
|
|
148
|
-
* this option. For example: `{ url: '...', endpoints: { api: { ... } } }`. Default `api`.
|
|
149
|
-
*/
|
|
150
|
-
configurationSetting: string;
|
|
151
|
-
/**
|
|
152
|
-
* The options for how the gateway will handle the headers from the requests and the
|
|
153
|
-
* responses.
|
|
154
|
-
*/
|
|
155
|
-
headers: GatewayControllerHeadersOptions;
|
|
156
|
-
};
|
|
157
|
-
/**
|
|
158
|
-
* This are the options sent to the controller creator that instantiates
|
|
159
|
-
* {@link GatewayController }.
|
|
160
|
-
* They're basically the same as {@link GatewayControllerOptions } but with a couple of
|
|
161
|
-
* extra ones.
|
|
162
|
-
*/
|
|
163
|
-
export type GatewayControllerCreatorOptions = {
|
|
164
|
-
/**
|
|
165
|
-
* The name of the creator will use to register the controller in the container. No, this
|
|
166
|
-
* is not a typo. The creator will register the controller so other services can access
|
|
167
|
-
* the `endpointsForAPIClient` getter. The service will be available after the app routes
|
|
168
|
-
* are mounted.
|
|
169
|
-
* If this is overwritten, the creator will ensure that the name ends with `Gateway`; and
|
|
170
|
-
* if overwritten, but it doesn't include `Gateway` at the end, and no
|
|
171
|
-
* `configurationSetting` was defined, the creator will use the custom name (without
|
|
172
|
-
* `Gatway`) for `configurationSetting`.
|
|
173
|
-
* Default `'apiGeteway'`.
|
|
174
|
-
*/
|
|
175
|
-
serviceName: string;
|
|
176
|
-
/**
|
|
177
|
-
* The name of the helper service the creator will try to obtain from the container. If
|
|
178
|
-
* `serviceName` is overwritten, the default for this will be `${serviceName}Helper`.
|
|
179
|
-
* Default:
|
|
180
|
-
* `'apiGatewayHelper'`.
|
|
181
|
-
*/
|
|
182
|
-
helperServiceName: string;
|
|
183
|
-
/**
|
|
184
|
-
* The name of the configuration setting where the gateway configuration is stored. If not
|
|
185
|
-
* overwritten, check the description of `serviceName` to understand which will be its
|
|
186
|
-
* default value. Default `'api'`.
|
|
187
|
-
*/
|
|
188
|
-
configurationSetting: string;
|
|
189
|
-
/**
|
|
190
|
-
* The class the creator will instantiate. Similar to {@link APIClient }, this allows for
|
|
191
|
-
* extra customization in cases you may need multiple gateways. Default
|
|
192
|
-
* {@link GatewayController }.
|
|
193
|
-
*/
|
|
194
|
-
gatewayClass: typeof GatewayController;
|
|
195
|
-
/**
|
|
196
|
-
* This function can be used to add custom middlewares on the gateway routes. If
|
|
197
|
-
* implemented, it must return a list of middlewares when executed. Default `null`.
|
|
198
|
-
*/
|
|
199
|
-
middlewares: GatewayControllerMiddlewaresFn | null;
|
|
200
|
-
};
|
|
201
|
-
/**
|
|
202
|
-
* This is the information for a request the controller will make.
|
|
203
|
-
*/
|
|
204
|
-
export type GatewayControllerRequest = {
|
|
205
|
-
/**
|
|
206
|
-
* The URL for the request.
|
|
207
|
-
*/
|
|
208
|
-
url: string;
|
|
209
|
-
/**
|
|
210
|
-
* The request options.
|
|
211
|
-
*/
|
|
212
|
-
options: HTTPFetchOptions;
|
|
213
|
-
};
|
|
214
|
-
/**
|
|
215
|
-
* This is the information for an specific endpoint that the gateway may use to send to a
|
|
216
|
-
* helper method in order to give it context.
|
|
217
|
-
*/
|
|
218
|
-
export type GatewayControllerEndpointInformation = {
|
|
219
|
-
/**
|
|
220
|
-
* The name of the endpoint, which is actually the path inside the gateway configuration's
|
|
221
|
-
* `gateway` property.
|
|
222
|
-
*/
|
|
223
|
-
name: string;
|
|
224
|
-
/**
|
|
225
|
-
* The path for the endpoint, or the dictionary of settings.
|
|
226
|
-
*/
|
|
227
|
-
settings: string | GatewayConfigurationEndpoint;
|
|
228
|
-
};
|
|
229
|
-
/**
|
|
230
|
-
* This is called in order to allow the helper to modify the information of a request that
|
|
231
|
-
* is about the fired.
|
|
232
|
-
*/
|
|
233
|
-
export type GatewayHelperServiceRequestReducer = (request: GatewayControllerRequest, endpoint: GatewayControllerEndpointInformation, req: ExpressRequest, res: ExpressResponse, next: ExpressNext) => GatewayControllerRequest;
|
|
234
|
-
/**
|
|
235
|
-
* This is called in order to allow the helper to modify the information of a response the
|
|
236
|
-
* gateway made.
|
|
237
|
-
*/
|
|
238
|
-
export type GatewayHelperServiceResponseReducer = (response: any, endpoint: GatewayControllerEndpointInformation, req: ExpressRequest, res: ExpressResponse, next: ExpressNext) => any;
|
|
239
|
-
/**
|
|
240
|
-
* This is called in order to allow the helper to decide whether a fetch request response
|
|
241
|
-
* should be added to the server's response stream. This will only be called if the helper
|
|
242
|
-
* also implements `handleEndpointResponse`.
|
|
243
|
-
*/
|
|
244
|
-
export type GatewayHelperServiceStreamVerification = (response: any, endpoint: GatewayControllerEndpointInformation, req: ExpressRequest, res: ExpressResponse, next: ExpressNext) => boolean;
|
|
245
|
-
/**
|
|
246
|
-
* This is called in order for the helper to handle a response. This is only called if
|
|
247
|
-
* `shouldStreamEndpointResponse` returned `false`.
|
|
248
|
-
*/
|
|
249
|
-
export type GatewayHelperServiceResponseHandler = (response: any, endpoint: GatewayControllerEndpointInformation, req: ExpressRequest, res: ExpressResponse, next: ExpressNext) => any;
|
|
250
|
-
/**
|
|
251
|
-
* This is called in order for the helper to handle a fetch request error.
|
|
252
|
-
*/
|
|
253
|
-
export type GatewayHelperServiceErrorHandler = (error: Error, endpoint: GatewayControllerEndpointInformation, req: ExpressRequest, res: ExpressResponse, next: ExpressNext) => any;
|
|
254
|
-
/**
|
|
255
|
-
* A service that can have specific methods the gateway will call in order to modify
|
|
256
|
-
* requests,
|
|
257
|
-
* responses, handle errors, etc.
|
|
258
|
-
*/
|
|
259
|
-
export type GatewayHelperService = {
|
|
260
|
-
/**
|
|
261
|
-
* This is called in order to allow the helper to modify the information of a request that
|
|
262
|
-
* is about the fired.
|
|
263
|
-
*/
|
|
264
|
-
reduceEndpointRequest: GatewayHelperServiceRequestReducer | null;
|
|
265
|
-
/**
|
|
266
|
-
* This is called in order to allow the helper to modify the information of a response the
|
|
267
|
-
* gateway made.
|
|
268
|
-
*/
|
|
269
|
-
reduceEndpointResponse: GatewayHelperServiceResponseReducer | null;
|
|
270
|
-
/**
|
|
271
|
-
* This is called in order to allow the helper to decide whether a fetch request response
|
|
272
|
-
* should be added to the server's response stream. This will only be called if the helper
|
|
273
|
-
* also implements `handleEndpointResponse`.
|
|
274
|
-
*/
|
|
275
|
-
shouldStreamEndpointResponse: GatewayHelperServiceStreamVerification | null;
|
|
276
|
-
/**
|
|
277
|
-
* This is called in order for the helper to handle a response. This is only called if
|
|
278
|
-
* `shouldStreamEndpointResponse` returned `false`.
|
|
279
|
-
*/
|
|
280
|
-
handleEndpointResponse: GatewayHelperServiceResponseHandler | null;
|
|
281
|
-
/**
|
|
282
|
-
* This is called in order for the helper to handle a fetch request error.
|
|
283
|
-
*/
|
|
284
|
-
handleEndpointError: GatewayHelperServiceErrorHandler | null;
|
|
285
|
-
};
|
|
286
|
-
export type GatewayControllerMiddlewaresFn = (app: Jimpex) => MiddlewareLike[];
|
|
287
|
-
/**
|
|
288
|
-
* @typedef {import('../../types').ExpressRouter} ExpressRouter
|
|
289
|
-
* @typedef {import('../../app').Jimpex} Jimpex
|
|
290
|
-
* @typedef {import('../../types').ExpressRequest} ExpressRequest
|
|
291
|
-
* @typedef {import('../../types').ExpressResponse} ExpressResponse
|
|
292
|
-
* @typedef {import('../../types').ExpressNext} ExpressNext
|
|
293
|
-
* @typedef {import('../../types').ExpressMiddleware} ExpressMiddleware
|
|
294
|
-
* @typedef {import('../../types').MiddlewareLike} MiddlewareLike
|
|
295
|
-
* @typedef {import('../../services/http/http').HTTP} HTTP
|
|
296
|
-
* @typedef {import('../../services/http/http').HTTPFetchOptions} HTTPFetchOptions
|
|
297
|
-
* @typedef {import('../../services/http/http').Response} Response
|
|
298
|
-
* @typedef {import('../../services/http/apiClient').APIClientConfiguration} APIClientConfiguration
|
|
299
|
-
* @prettierignore
|
|
300
|
-
*/
|
|
301
|
-
/**
|
|
302
|
-
* @typedef {import('../../types').ProviderCreator<O>} ProviderCreator<O>
|
|
303
|
-
* @template O
|
|
304
|
-
*/
|
|
305
|
-
/**
|
|
306
|
-
* This object represets an HTTP method for a route the controller will mount.
|
|
307
|
-
*
|
|
308
|
-
* @typedef {Object} GatewayControllerRouteMethod
|
|
309
|
-
* @property {string} method
|
|
310
|
-
* The name of the HTTP method.
|
|
311
|
-
* @property {GatewayControllerEndpointInformation} endpoint
|
|
312
|
-
* The information for the endpoint responsible from creating the route.
|
|
313
|
-
* @parent module:controllers
|
|
314
|
-
* @ignore
|
|
315
|
-
*/
|
|
316
|
-
/**
|
|
317
|
-
* This object contains the information for an specific route the controller will mount.
|
|
318
|
-
*
|
|
319
|
-
* @typedef {Object} GatewayControllerRoute
|
|
320
|
-
* @property {string} path The path to the endpoint relative
|
|
321
|
-
* to the entry point.
|
|
322
|
-
* @property {string} route The path the route will have. This
|
|
323
|
-
* is different from `path` as it's
|
|
324
|
-
* possible for the gateway to be
|
|
325
|
-
* implemented using the `root`
|
|
326
|
-
* option.
|
|
327
|
-
* @property {GatewayControllerRouteMethod[]} methods A list with all the methods the
|
|
328
|
-
* controller will use to mount the
|
|
329
|
-
* route.
|
|
330
|
-
* @parent module:controllers
|
|
331
|
-
* @ignore
|
|
332
|
-
*/
|
|
333
|
-
/**
|
|
334
|
-
* Normally, you would define an endpoint with just a string path, but you can use this
|
|
335
|
-
* type of object to add extra settings.
|
|
336
|
-
*
|
|
337
|
-
* @typedef {Object} GatewayConfigurationEndpoint
|
|
338
|
-
* @property {string} path The path to the endpoint relative to the entry point. It can
|
|
339
|
-
* include placeholders for parameters like `/:parameter/`.
|
|
340
|
-
* @property {string} method The HTTP method for the endpoint. This will tell the gateway
|
|
341
|
-
* the type of route it should mount. If is not specified, it
|
|
342
|
-
* will use `all`.
|
|
343
|
-
* @parent module:controllers
|
|
344
|
-
*/
|
|
345
|
-
/**
|
|
346
|
-
* A dictionary of endpoints or sub endpoints the gateway will use in order to mount
|
|
347
|
-
* routes.
|
|
348
|
-
*
|
|
349
|
-
* @typedef {Object} GatewayConfigurationEndpoints
|
|
350
|
-
* @property {string | GatewayConfigurationEndpoints | GatewayConfigurationEndpoint} [endpointName]
|
|
351
|
-
* It can be the path to an actual endpoint, a dictionary of sub endpoints, or a
|
|
352
|
-
* definition of an endpoint with settings ({@link GatewayConfigurationEndpoint}).
|
|
353
|
-
* @parent module:controllers
|
|
354
|
-
* @prettierignore
|
|
355
|
-
*/
|
|
356
|
-
/**
|
|
357
|
-
* This is a configuration object very similar to the one {@link APIClient} uses in order
|
|
358
|
-
* to configure the endpoints; the controller uses it to create the routes and to validate
|
|
359
|
-
* the HTTP methods.
|
|
360
|
-
*
|
|
361
|
-
* @typedef {Object} GatewayConfiguration
|
|
362
|
-
* @property {string} url The entry point to the API the
|
|
363
|
-
* controller will make the requests
|
|
364
|
-
* to.
|
|
365
|
-
* @property {GatewayConfigurationEndpoints} gateway A dictionary with the endpoints the
|
|
366
|
-
* gateway will make available.
|
|
367
|
-
* @parent module:controllers
|
|
368
|
-
*/
|
|
369
|
-
/**
|
|
370
|
-
* The options for how the gateway will handle the headers from the requests and the
|
|
371
|
-
* responses.
|
|
372
|
-
*
|
|
373
|
-
* @typedef {Object} GatewayControllerHeadersOptions
|
|
374
|
-
* @property {boolean} useXForwardedFor Whether or not to include the header with the
|
|
375
|
-
* request's IP address. Default `true`.
|
|
376
|
-
* @property {boolean} copyCustomHeaders Whether or not to copy all custom headers from
|
|
377
|
-
* the request. By custom header, it means all the
|
|
378
|
-
* headers which names start with `x-`. Default
|
|
379
|
-
* `true`.
|
|
380
|
-
* @property {string[]} copy A list of "known" headers the gateway will try
|
|
381
|
-
* to copy from the incoming request. Default:
|
|
382
|
-
* `['authorization','content-type', 'referer',
|
|
383
|
-
* 'user-agent']`.
|
|
384
|
-
* @property {string[]} remove A list of "known" headers the gateway will try
|
|
385
|
-
* to remove the response. Default:
|
|
386
|
-
* `['server', 'x-powered-by']`.
|
|
387
|
-
* @parent module:controllers
|
|
388
|
-
*/
|
|
389
|
-
/**
|
|
390
|
-
* The options to configure how the gateway will manage the requests and the responses.
|
|
391
|
-
*
|
|
392
|
-
* @typedef {Object} GatewayControllerOptions
|
|
393
|
-
* @property {string} root
|
|
394
|
-
* This is really a helper for when the gateway is used with an API client. The idea is
|
|
395
|
-
* that,
|
|
396
|
-
* by default, the routes are mounted on the controller route, but with this option, you
|
|
397
|
-
* can specify another sub path. For example: The controller is mounted on `/routes`, if
|
|
398
|
-
* you set `root` to `gateway`, all the routes will be on `/routes/gateway`.
|
|
399
|
-
* This become important (and useful) when you get the API client configuration (with
|
|
400
|
-
* `endpointsForAPIClient`): The `url` will be the controller route, but all the endpoints
|
|
401
|
-
* will be modified and prefixed with the `root`. Default `''`.
|
|
402
|
-
* @property {string} configurationSetting
|
|
403
|
-
* This is another option for when the gateway is used with an API client. When calling
|
|
404
|
-
* `endpointsForAPIClient`, all the endpoints will be wrapped inside an object named after
|
|
405
|
-
* this option. For example: `{ url: '...', endpoints: { api: { ... } } }`. Default `api`.
|
|
406
|
-
* @property {GatewayControllerHeadersOptions} headers
|
|
407
|
-
* The options for how the gateway will handle the headers from the requests and the
|
|
408
|
-
* responses.
|
|
409
|
-
* @parent module:controllers
|
|
410
|
-
*/
|
|
411
|
-
/**
|
|
412
|
-
* This are the options sent to the controller creator that instantiates
|
|
413
|
-
* {@link GatewayController}.
|
|
414
|
-
* They're basically the same as {@link GatewayControllerOptions} but with a couple of
|
|
415
|
-
* extra ones.
|
|
416
|
-
*
|
|
417
|
-
* @typedef {Object} GatewayControllerCreatorOptions
|
|
418
|
-
* @property {string} serviceName
|
|
419
|
-
* The name of the creator will use to register the controller in the container. No, this
|
|
420
|
-
* is not a typo. The creator will register the controller so other services can access
|
|
421
|
-
* the `endpointsForAPIClient` getter. The service will be available after the app routes
|
|
422
|
-
* are mounted.
|
|
423
|
-
* If this is overwritten, the creator will ensure that the name ends with `Gateway`; and
|
|
424
|
-
* if overwritten, but it doesn't include `Gateway` at the end, and no
|
|
425
|
-
* `configurationSetting` was defined, the creator will use the custom name (without
|
|
426
|
-
* `Gatway`) for `configurationSetting`.
|
|
427
|
-
* Default `'apiGeteway'`.
|
|
428
|
-
* @property {string} helperServiceName
|
|
429
|
-
* The name of the helper service the creator will try to obtain from the container. If
|
|
430
|
-
* `serviceName` is overwritten, the default for this will be `${serviceName}Helper`.
|
|
431
|
-
* Default:
|
|
432
|
-
* `'apiGatewayHelper'`.
|
|
433
|
-
* @property {string} configurationSetting
|
|
434
|
-
* The name of the configuration setting where the gateway configuration is stored. If not
|
|
435
|
-
* overwritten, check the description of `serviceName` to understand which will be its
|
|
436
|
-
* default value. Default `'api'`.
|
|
437
|
-
* @property {typeof GatewayController} gatewayClass
|
|
438
|
-
* The class the creator will instantiate. Similar to {@link APIClient}, this allows for
|
|
439
|
-
* extra customization in cases you may need multiple gateways. Default
|
|
440
|
-
* {@link GatewayController}.
|
|
441
|
-
* @property {?GatewayControllerMiddlewaresFn} middlewares
|
|
442
|
-
* This function can be used to add custom middlewares on the gateway routes. If
|
|
443
|
-
* implemented, it must return a list of middlewares when executed. Default `null`.
|
|
444
|
-
* @parent module:controllers
|
|
445
|
-
*/
|
|
446
|
-
/**
|
|
447
|
-
* This is the information for a request the controller will make.
|
|
448
|
-
*
|
|
449
|
-
* @typedef {Object} GatewayControllerRequest
|
|
450
|
-
* @property {string} url The URL for the request.
|
|
451
|
-
* @property {HTTPFetchOptions} options The request options.
|
|
452
|
-
* @parent module:controllers
|
|
453
|
-
*/
|
|
454
|
-
/**
|
|
455
|
-
* This is the information for an specific endpoint that the gateway may use to send to a
|
|
456
|
-
* helper method in order to give it context.
|
|
457
|
-
*
|
|
458
|
-
* @typedef {Object} GatewayControllerEndpointInformation
|
|
459
|
-
* @property {string} name
|
|
460
|
-
* The name of the endpoint, which is actually the path inside the gateway configuration's
|
|
461
|
-
* `gateway` property.
|
|
462
|
-
* @property {string | GatewayConfigurationEndpoint} settings
|
|
463
|
-
* The path for the endpoint, or the dictionary of settings.
|
|
464
|
-
* @parent module:controllers
|
|
465
|
-
*/
|
|
466
|
-
/**
|
|
467
|
-
* This is called in order to allow the helper to modify the information of a request that
|
|
468
|
-
* is about the fired.
|
|
469
|
-
*
|
|
470
|
-
* @callback GatewayHelperServiceRequestReducer
|
|
471
|
-
* @param {GatewayControllerRequest} request
|
|
472
|
-
* The information for a request the controller will make.
|
|
473
|
-
* @param {GatewayControllerEndpointInformation} endpoint
|
|
474
|
-
* The information for the endpoint responsible of creating the route.
|
|
475
|
-
* @param {ExpressRequest} req
|
|
476
|
-
* The server's incoming request information.
|
|
477
|
-
* @param {ExpressResponse} res
|
|
478
|
-
* The server's response information.
|
|
479
|
-
* @param {ExpressNext} next
|
|
480
|
-
* The function to call the next middleware.
|
|
481
|
-
* @returns {GatewayControllerRequest}
|
|
482
|
-
* @parent module:controllers
|
|
483
|
-
*/
|
|
484
|
-
/**
|
|
485
|
-
* This is called in order to allow the helper to modify the information of a response the
|
|
486
|
-
* gateway made.
|
|
487
|
-
*
|
|
488
|
-
* @callback GatewayHelperServiceResponseReducer
|
|
489
|
-
* @param {Response} response
|
|
490
|
-
* The response generated by the fetch request.
|
|
491
|
-
* @param {GatewayControllerEndpointInformation} endpoint
|
|
492
|
-
* The information for the endpoint responsible of creating the route.
|
|
493
|
-
* @param {ExpressRequest} req
|
|
494
|
-
* The server's incoming request information.
|
|
495
|
-
* @param {ExpressResponse} res
|
|
496
|
-
* The server's response information.
|
|
497
|
-
* @param {ExpressNext} next
|
|
498
|
-
* The function to call the next middleware.
|
|
499
|
-
* @returns {Response}
|
|
500
|
-
* @parent module:controllers
|
|
501
|
-
*/
|
|
502
|
-
/**
|
|
503
|
-
* This is called in order to allow the helper to decide whether a fetch request response
|
|
504
|
-
* should be added to the server's response stream. This will only be called if the helper
|
|
505
|
-
* also implements `handleEndpointResponse`.
|
|
506
|
-
*
|
|
507
|
-
* @callback GatewayHelperServiceStreamVerification
|
|
508
|
-
* @param {Response} response
|
|
509
|
-
* The response generated by the fetch request.
|
|
510
|
-
* @param {GatewayControllerEndpointInformation} endpoint
|
|
511
|
-
* The information for the endpoint responsible of creating the route.
|
|
512
|
-
* @param {ExpressRequest} req
|
|
513
|
-
* The server's incoming request information.
|
|
514
|
-
* @param {ExpressResponse} res
|
|
515
|
-
* The server's response information.
|
|
516
|
-
* @param {ExpressNext} next
|
|
517
|
-
* The function to call the next middleware.
|
|
518
|
-
* @returns {boolean}
|
|
519
|
-
* @parent module:controllers
|
|
520
|
-
*/
|
|
521
|
-
/**
|
|
522
|
-
* This is called in order for the helper to handle a response. This is only called if
|
|
523
|
-
* `shouldStreamEndpointResponse` returned `false`.
|
|
524
|
-
*
|
|
525
|
-
* @callback GatewayHelperServiceResponseHandler
|
|
526
|
-
* @param {Response} response
|
|
527
|
-
* The response generated by the fetch request.
|
|
528
|
-
* @param {GatewayControllerEndpointInformation} endpoint
|
|
529
|
-
* The information for the endpoint responsible of creating the route.
|
|
530
|
-
* @param {ExpressRequest} req
|
|
531
|
-
* The server's incoming request information.
|
|
532
|
-
* @param {ExpressResponse} res
|
|
533
|
-
* The server's response information.
|
|
534
|
-
* @param {ExpressNext} next
|
|
535
|
-
* The function to call the next middleware.
|
|
536
|
-
* @parent module:controllers
|
|
537
|
-
*/
|
|
538
|
-
/**
|
|
539
|
-
* This is called in order for the helper to handle a fetch request error.
|
|
540
|
-
*
|
|
541
|
-
* @callback GatewayHelperServiceErrorHandler
|
|
542
|
-
* @param {Error} error
|
|
543
|
-
* The fetch request error.
|
|
544
|
-
* @param {GatewayControllerEndpointInformation} endpoint
|
|
545
|
-
* The information for the endpoint responsible of creating the route.
|
|
546
|
-
* @param {ExpressRequest} req
|
|
547
|
-
* The server's incoming request information.
|
|
548
|
-
* @param {ExpressResponse} res
|
|
549
|
-
* The server's response information.
|
|
550
|
-
* @param {ExpressNext} next
|
|
551
|
-
* The function to call the next middleware.
|
|
552
|
-
* @parent module:controllers
|
|
553
|
-
*/
|
|
554
|
-
/**
|
|
555
|
-
* A service that can have specific methods the gateway will call in order to modify
|
|
556
|
-
* requests,
|
|
557
|
-
* responses, handle errors, etc.
|
|
558
|
-
*
|
|
559
|
-
* @typedef {Object} GatewayHelperService
|
|
560
|
-
* @property {?GatewayHelperServiceRequestReducer} reduceEndpointRequest
|
|
561
|
-
* This is called in order to allow the helper to modify the information of a request that
|
|
562
|
-
* is about the fired.
|
|
563
|
-
* @property {?GatewayHelperServiceResponseReducer} reduceEndpointResponse
|
|
564
|
-
* This is called in order to allow the helper to modify the information of a response the
|
|
565
|
-
* gateway made.
|
|
566
|
-
* @property {?GatewayHelperServiceStreamVerification} shouldStreamEndpointResponse
|
|
567
|
-
* This is called in order to allow the helper to decide whether a fetch request response
|
|
568
|
-
* should be added to the server's response stream. This will only be called if the helper
|
|
569
|
-
* also implements `handleEndpointResponse`.
|
|
570
|
-
* @property {?GatewayHelperServiceResponseHandler} handleEndpointResponse
|
|
571
|
-
* This is called in order for the helper to handle a response. This is only called if
|
|
572
|
-
* `shouldStreamEndpointResponse` returned `false`.
|
|
573
|
-
* @property {?GatewayHelperServiceErrorHandler} handleEndpointError
|
|
574
|
-
* This is called in order for the helper to handle a fetch request error.
|
|
575
|
-
* @parent module:controllers
|
|
576
|
-
*/
|
|
577
|
-
/**
|
|
578
|
-
* @callback GatewayControllerMiddlewaresFn
|
|
579
|
-
* @param {Jimpex} app A reference for the container.
|
|
580
|
-
* @returns {MiddlewareLike[]}
|
|
581
|
-
* @parent module:controllers
|
|
582
|
-
*/
|
|
583
|
-
/**
|
|
584
|
-
* Geneters routes that will act as a gateway to an specific set of endpoints.
|
|
585
|
-
*
|
|
586
|
-
* @parent module:controllers
|
|
587
|
-
*/
|
|
588
|
-
export class GatewayController {
|
|
589
|
-
/**
|
|
590
|
-
* @param {GatewayConfiguration} gatewayConfig
|
|
591
|
-
* This is a configuration object very similar to the one {@link APIClient} uses in
|
|
592
|
-
* order to configure the endpoints; the controller uses it to create the routes and to
|
|
593
|
-
* validate the HTTP methods.
|
|
594
|
-
* @param {string} route
|
|
595
|
-
* The route where the controller will be mounted.
|
|
596
|
-
* @param {HTTP} http
|
|
597
|
-
* To make the fetch requests on the routes.
|
|
598
|
-
* @param {GatewayControllerOptions} [options={}]
|
|
599
|
-
* The options to configure how the gateway will manage the requests and the responses.
|
|
600
|
-
* @param {?GatewayHelperService} [helperService=null]
|
|
601
|
-
* A service that can have specific methods the gateway will call in order to modify
|
|
602
|
-
* requests,
|
|
603
|
-
* responses, handle errors, etc.
|
|
604
|
-
*/
|
|
605
|
-
constructor(gatewayConfig: GatewayConfiguration, route: string, http: HTTP, options?: GatewayControllerOptions, helperService?: GatewayHelperService | null);
|
|
606
|
-
/**
|
|
607
|
-
* The options to configure how the gateway will manage the requests and the
|
|
608
|
-
* responses.
|
|
609
|
-
*
|
|
610
|
-
* @type {GatewayControllerOptions}
|
|
611
|
-
* @access protected
|
|
612
|
-
* @ignore
|
|
613
|
-
* @todo Use deepAssign for this merge.
|
|
614
|
-
*/
|
|
615
|
-
_options: GatewayControllerOptions;
|
|
616
|
-
/**
|
|
617
|
-
* The configuration for the API the controller will make requests to.
|
|
618
|
-
*
|
|
619
|
-
* @type {GatewayConfiguration}
|
|
620
|
-
* @access protected
|
|
621
|
-
* @ignore
|
|
622
|
-
*/
|
|
623
|
-
_gatewayConfig: GatewayConfiguration;
|
|
624
|
-
/**
|
|
625
|
-
* A local reference for the `http` service.
|
|
626
|
-
*
|
|
627
|
-
* @type {HTTP}
|
|
628
|
-
* @access protected
|
|
629
|
-
* @ignore
|
|
630
|
-
*/
|
|
631
|
-
_http: HTTP;
|
|
632
|
-
/**
|
|
633
|
-
* A list of the allowed HTTP methods an endpoint can have.
|
|
634
|
-
*
|
|
635
|
-
* @type {string[]}
|
|
636
|
-
* @access protected
|
|
637
|
-
* @ignore
|
|
638
|
-
*/
|
|
639
|
-
_allowedHTTPMethods: string[];
|
|
640
|
-
/**
|
|
641
|
-
* A flat dictionary of the gateway endpoints. The key is the path on the original
|
|
642
|
-
* dictionary (`this._gatewayConfig.gateway`) and the value is either the path
|
|
643
|
-
* (`string`)
|
|
644
|
-
* or the endpoint settings ({@link GatewayConfigurationEndpoint}).
|
|
645
|
-
*
|
|
646
|
-
* @type {Object.<string, string | GatewayConfigurationEndpoint>}
|
|
647
|
-
* @access protected
|
|
648
|
-
* @ignore
|
|
649
|
-
*/
|
|
650
|
-
_endpoints: {
|
|
651
|
-
[x: string]: string | GatewayConfigurationEndpoint;
|
|
652
|
-
};
|
|
653
|
-
/**
|
|
654
|
-
* The route where the controller is mounted.
|
|
655
|
-
*
|
|
656
|
-
* @type {string}
|
|
657
|
-
* @access protected
|
|
658
|
-
* @ignore
|
|
659
|
-
*/
|
|
660
|
-
_route: string;
|
|
661
|
-
/**
|
|
662
|
-
* A regular expression that will be used to remove the controller route from a
|
|
663
|
-
* request path. This will allow the main middleware to extract the path to where the
|
|
664
|
-
* request should be made.
|
|
665
|
-
*
|
|
666
|
-
* @type {RegExp}
|
|
667
|
-
* @access protected
|
|
668
|
-
* @ignore
|
|
669
|
-
*/
|
|
670
|
-
_routeExpression: RegExp;
|
|
671
|
-
/**
|
|
672
|
-
* This is the list of routes the controller will define.
|
|
673
|
-
*
|
|
674
|
-
* @type {GatewayControllerRoute[]}
|
|
675
|
-
* @access protected
|
|
676
|
-
* @ignore
|
|
677
|
-
*/
|
|
678
|
-
_routes: GatewayControllerRoute[];
|
|
679
|
-
/**
|
|
680
|
-
* An {@link APIClient} configuration based on the controller routes.
|
|
681
|
-
*
|
|
682
|
-
* @type {APIClientConfiguration}
|
|
683
|
-
* @access protected
|
|
684
|
-
* @ignore
|
|
685
|
-
*/
|
|
686
|
-
_apiClientConfiguration: APIClientConfiguration;
|
|
687
|
-
/**
|
|
688
|
-
* A service that can have specific methods the gateway will call in order to modify
|
|
689
|
-
* requests, responses, handle errors, etc.
|
|
690
|
-
*
|
|
691
|
-
* @type {?GatewayHelperService}
|
|
692
|
-
* @access protected
|
|
693
|
-
*/
|
|
694
|
-
_helperService: GatewayHelperService | null;
|
|
695
|
-
/**
|
|
696
|
-
* A dictionary of boolean flags that specify if a helper service has method. This is
|
|
697
|
-
* to avoid checking if the helper is defined and if "x method" is a function. If no
|
|
698
|
-
* helper was specified, the object will have all the flags set to `false`.
|
|
699
|
-
*
|
|
700
|
-
* @type {Object.<string, boolean>}
|
|
701
|
-
* @access protected
|
|
702
|
-
* @ignore
|
|
703
|
-
*/
|
|
704
|
-
_helperServiceInfo: {
|
|
705
|
-
[x: string]: boolean;
|
|
706
|
-
};
|
|
707
|
-
/**
|
|
708
|
-
* Defines all the routes on a given router.
|
|
709
|
-
*
|
|
710
|
-
* @param {ExpressRouter} router The router where all the routes will
|
|
711
|
-
* be added.
|
|
712
|
-
* @param {ExpressMiddleware[]} [middlewares=[]] A list of custom middlewares that will
|
|
713
|
-
* be added before the one that makes the
|
|
714
|
-
* request.
|
|
715
|
-
* @returns {ExpressRouter}
|
|
716
|
-
*/
|
|
717
|
-
addRoutes(router: ExpressRouter, middlewares?: ExpressMiddleware[]): ExpressRouter;
|
|
718
|
-
/**
|
|
719
|
-
* An {@link APIClient} configuration based on the controller routes.
|
|
720
|
-
*
|
|
721
|
-
* @type {APIClientConfiguration}
|
|
722
|
-
*/
|
|
723
|
-
get endpointsForAPIClient(): import("../../services/http/apiClient").APIClientConfiguration;
|
|
724
|
-
/**
|
|
725
|
-
* The configuration for the API the controller will make requests to.
|
|
726
|
-
*
|
|
727
|
-
* @type {GatewayConfiguration}
|
|
728
|
-
*/
|
|
729
|
-
get gatewayConfig(): GatewayConfiguration;
|
|
730
|
-
/**
|
|
731
|
-
* The options to configure how the gateway will manage the requests and the responses.
|
|
732
|
-
*
|
|
733
|
-
* @type {GatewayControllerOptions}
|
|
734
|
-
*/
|
|
735
|
-
get options(): GatewayControllerOptions;
|
|
736
|
-
/**
|
|
737
|
-
* Adds a route on a given router.
|
|
738
|
-
*
|
|
739
|
-
* @param {ExpressRouter} router The router where the route will be
|
|
740
|
-
* added.
|
|
741
|
-
* @param {string} method The HTTP method for the route.
|
|
742
|
-
* @param {string} route The path for the route.
|
|
743
|
-
* @param {ExpressMiddleware} endpointMiddleware The middleware that makes the request.
|
|
744
|
-
* @param {Array} middlewares Extra middlewares to add before the
|
|
745
|
-
* main one.
|
|
746
|
-
* @returns {ExpressRouter}
|
|
747
|
-
* @access protected
|
|
748
|
-
* @ignore
|
|
749
|
-
*/
|
|
750
|
-
_addRoute(router: ExpressRouter, method: string, route: string, endpointMiddleware: ExpressMiddleware, middlewares: any[]): ExpressRouter;
|
|
751
|
-
/**
|
|
752
|
-
* Based on the controller options and the gateway endpoints, this method will create an
|
|
753
|
-
* API client configuration that can be used to make requests to this controller.
|
|
754
|
-
*
|
|
755
|
-
* @returns {APIClientConfiguration}
|
|
756
|
-
* @access protected
|
|
757
|
-
* @ignore
|
|
758
|
-
*/
|
|
759
|
-
_createAPIClientConfiguration(): APIClientConfiguration;
|
|
760
|
-
/**
|
|
761
|
-
* Based on the information from the endpoints, this method will create the routes the
|
|
762
|
-
* controller will later add on a router.
|
|
763
|
-
*
|
|
764
|
-
* @returns {GatewayControllerRoute[]}
|
|
765
|
-
* @throws {Error} If there's more than one endpoint using the same path with the same
|
|
766
|
-
* HTTP method.
|
|
767
|
-
* @access protected
|
|
768
|
-
* @ignore
|
|
769
|
-
*/
|
|
770
|
-
_createEndpointRoutes(): GatewayControllerRoute[];
|
|
771
|
-
/**
|
|
772
|
-
* Validates if a server helper exists and creates a dictionary with flags for all the
|
|
773
|
-
* methods a helper can have; this will allow other methods to check if the "helper
|
|
774
|
-
* method X" is available without having to check if the helper is defined and if
|
|
775
|
-
* "method X" is a function.
|
|
776
|
-
*
|
|
777
|
-
* @returns {Object.<string, boolean>}
|
|
778
|
-
* @access protected
|
|
779
|
-
* @ignore
|
|
780
|
-
*/
|
|
781
|
-
_createHelperServiceInfo(): {
|
|
782
|
-
[x: string]: boolean;
|
|
783
|
-
};
|
|
784
|
-
/**
|
|
785
|
-
* Creates a regular expression the main middleware will later use in order to remove
|
|
786
|
-
* the controller route from the request url. That's needed in order to build the URL
|
|
787
|
-
* where the request will be made.
|
|
788
|
-
*
|
|
789
|
-
* @returns {RegExp}
|
|
790
|
-
* @access protected
|
|
791
|
-
* @ignore
|
|
792
|
-
*/
|
|
793
|
-
_createRouteExpression(): RegExp;
|
|
794
|
-
/**
|
|
795
|
-
* Generates a middleware that will make a request and stream back the response.
|
|
796
|
-
*
|
|
797
|
-
* @param {GatewayControllerEndpointInformation} endpoint
|
|
798
|
-
* The information for the enpdoint for which the middleware is being created.
|
|
799
|
-
* @returns {ExpressMiddleware}
|
|
800
|
-
* @access protected
|
|
801
|
-
* @ignore
|
|
802
|
-
*/
|
|
803
|
-
_getMiddleware(endpoint: GatewayControllerEndpointInformation): ExpressMiddleware;
|
|
804
|
-
/**
|
|
805
|
-
* Flattens all the endpoints from gateway configuration into a one level dictionary,
|
|
806
|
-
* where the key are the paths they used to have on the original configuration, and the
|
|
807
|
-
* values are the endpoints definitions.
|
|
808
|
-
*
|
|
809
|
-
* @returns {Object.<string, string | GatewayConfigurationEndpoint>}
|
|
810
|
-
* @access protected
|
|
811
|
-
* @ignore
|
|
812
|
-
*/
|
|
813
|
-
_getNormalizedEndpoints(): {
|
|
814
|
-
[x: string]: string | GatewayConfigurationEndpoint;
|
|
815
|
-
};
|
|
816
|
-
/**
|
|
817
|
-
* This method is called in order to handle a fetch request error. It will check if a
|
|
818
|
-
* helper is defined and allow it to do it, or fallback and call the next middleware.
|
|
819
|
-
*
|
|
820
|
-
* @param {Error} error
|
|
821
|
-
* The fetch request error.
|
|
822
|
-
* @param {GatewayControllerEndpointInformation} endpoint
|
|
823
|
-
* The information for the endpoint responsible of creating the route.
|
|
824
|
-
* @param {ExpressRequest} req
|
|
825
|
-
* The server's incoming request information.
|
|
826
|
-
* @param {ExpressResponse} res
|
|
827
|
-
* The server's response information.
|
|
828
|
-
* @param {ExpressNext} next
|
|
829
|
-
* The function to call the next middleware.
|
|
830
|
-
* @returns {*}
|
|
831
|
-
* @access protected
|
|
832
|
-
* @ignore
|
|
833
|
-
*/
|
|
834
|
-
_handleEndpointError(error: Error, endpoint: GatewayControllerEndpointInformation, req: ExpressRequest, res: ExpressResponse, next: ExpressNext): any;
|
|
835
|
-
/**
|
|
836
|
-
* This is called when the helper say that a fetch response shouldn't be sent, so the
|
|
837
|
-
* controller will allow it to handle the response by itself.
|
|
838
|
-
*
|
|
839
|
-
* @param {Object} response
|
|
840
|
-
* The response generated by the fetch request.
|
|
841
|
-
* @param {GatewayControllerEndpointInformation} endpoint
|
|
842
|
-
* The information for the endpoint responsible of creating the route.
|
|
843
|
-
* @param {ExpressRequest} req
|
|
844
|
-
* The server's incoming request information.
|
|
845
|
-
* @param {ExpressResponse} res
|
|
846
|
-
* The server's response information.
|
|
847
|
-
* @param {ExpressNext} next
|
|
848
|
-
* The function to call the next middleware.
|
|
849
|
-
* @returns {*}
|
|
850
|
-
* @access protected
|
|
851
|
-
* @ignore
|
|
852
|
-
*/
|
|
853
|
-
_handleEndpointResponse(response: any, endpoint: GatewayControllerEndpointInformation, req: ExpressRequest, res: ExpressResponse, next: ExpressNext): any;
|
|
854
|
-
/**
|
|
855
|
-
* This is a helper method used in order to validate if an HTTP method can be used in
|
|
856
|
-
* order to define a route in the router. If the given method is not on the list of
|
|
857
|
-
* allowed methods,
|
|
858
|
-
* it will be "normalized" to `all`. It also transforms the method into lower case.
|
|
859
|
-
*
|
|
860
|
-
* @param {string} method The method to validate.
|
|
861
|
-
* @returns {string}
|
|
862
|
-
* @access protected
|
|
863
|
-
* @ignore
|
|
864
|
-
*/
|
|
865
|
-
_normalizeHTTPMethod(method: string): string;
|
|
866
|
-
/**
|
|
867
|
-
* Normalizes the options recevied by the controller:
|
|
868
|
-
* - Removes any trailing and leading slashes from the `root` path, if defined.
|
|
869
|
-
*
|
|
870
|
-
* @param {GatewayControllerOptions} options The options to normalize.
|
|
871
|
-
* @returns {GatewayControllerOptions}
|
|
872
|
-
* @access protected
|
|
873
|
-
* @ignore
|
|
874
|
-
*/
|
|
875
|
-
_normalizeOptions(options: GatewayControllerOptions): GatewayControllerOptions;
|
|
876
|
-
/**
|
|
877
|
-
* This method is called in order to reduce a fetch request information. It will check
|
|
878
|
-
* if a helper is defined and allow it to do it, or fallback and return the given
|
|
879
|
-
* information.
|
|
880
|
-
*
|
|
881
|
-
* @param {GatewayControllerRequest} request
|
|
882
|
-
* The information for a request the controller will make.
|
|
883
|
-
* @param {GatewayControllerEndpointInformation} endpoint
|
|
884
|
-
* The information for the endpoint responsible of creating the route.
|
|
885
|
-
* @param {ExpressRequest} req
|
|
886
|
-
* The server's incoming request information.
|
|
887
|
-
* @param {ExpressResponse} res
|
|
888
|
-
* The server's response information.
|
|
889
|
-
* @param {ExpressNext} next
|
|
890
|
-
* The function to call the next middleware.
|
|
891
|
-
* @returns {GatewayControllerRequest}
|
|
892
|
-
* @access protected
|
|
893
|
-
* @ignore
|
|
894
|
-
*/
|
|
895
|
-
_reduceEndpointRequest(request: GatewayControllerRequest, endpoint: GatewayControllerEndpointInformation, req: ExpressRequest, res: ExpressResponse, next: ExpressNext): GatewayControllerRequest;
|
|
896
|
-
/**
|
|
897
|
-
* This method is called in order to reduce a fetch response information. It will check
|
|
898
|
-
* if a helper is defined and allow it to do it, or fallback and return the given
|
|
899
|
-
* information.
|
|
900
|
-
*
|
|
901
|
-
* @param {Response} response
|
|
902
|
-
* The response generated by the fetch request.
|
|
903
|
-
* @param {GatewayControllerEndpointInformation} endpoint
|
|
904
|
-
* The information for the endpoint responsible of creating the route.
|
|
905
|
-
* @param {ExpressRequest} req
|
|
906
|
-
* The server's incoming request information.
|
|
907
|
-
* @param {ExpressResponse} res
|
|
908
|
-
* The server's response information.
|
|
909
|
-
* @param {ExpressNext} next
|
|
910
|
-
* The function to call the next middleware.
|
|
911
|
-
* @returns {Response}
|
|
912
|
-
* @access protected
|
|
913
|
-
* @ignore
|
|
914
|
-
*/
|
|
915
|
-
_reduceEndpointResponse(response: any, endpoint: GatewayControllerEndpointInformation, req: ExpressRequest, res: ExpressResponse, next: ExpressNext): any;
|
|
916
|
-
/**
|
|
917
|
-
* This method is called in order to validate if the main middleware should pipe the
|
|
918
|
-
* fetch response stream into the server's response or if the helper will handle the
|
|
919
|
-
* response.
|
|
920
|
-
* This method will only call the helper if it implements both
|
|
921
|
-
* `shouldStreamEndpointResponse`
|
|
922
|
-
* and `handleEndpointResponse`.
|
|
923
|
-
*
|
|
924
|
-
* @param {Response} response
|
|
925
|
-
* The response generated by the fetch request.
|
|
926
|
-
* @param {GatewayControllerEndpointInformation} endpoint
|
|
927
|
-
* The information for the endpoint responsible of creating the route.
|
|
928
|
-
* @param {ExpressRequest} req
|
|
929
|
-
* The server's incoming request information.
|
|
930
|
-
* @param {ExpressResponse} res
|
|
931
|
-
* The server's response information.
|
|
932
|
-
* @param {ExpressNext} next
|
|
933
|
-
* The function to call the next middleware.
|
|
934
|
-
* @returns {boolean}
|
|
935
|
-
* @access protected
|
|
936
|
-
* @ignore
|
|
937
|
-
*/
|
|
938
|
-
_shouldStreamEndpointResponse(response: any, endpoint: GatewayControllerEndpointInformation, req: ExpressRequest, res: ExpressResponse, next: ExpressNext): boolean;
|
|
939
|
-
}
|
|
940
|
-
/**
|
|
941
|
-
* This controller allows you to have gateway routes that actually make requests and
|
|
942
|
-
* respond with the contents from an specified API.
|
|
943
|
-
*
|
|
944
|
-
* @type {ProviderCreator<GatewayControllerCreatorOptions>}
|
|
945
|
-
* @parent module:controllers
|
|
946
|
-
*/
|
|
947
|
-
export const gatewayController: ProviderCreator<GatewayControllerCreatorOptions>;
|