jimpex 7.0.2 → 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 +80 -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
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var __publicField = (obj, key, value) => {
|
|
21
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
22
|
+
return value;
|
|
23
|
+
};
|
|
24
|
+
var ensureBearerToken_exports = {};
|
|
25
|
+
__export(ensureBearerToken_exports, {
|
|
26
|
+
EnsureBearerToken: () => EnsureBearerToken,
|
|
27
|
+
ensureBearerTokenProvider: () => ensureBearerTokenProvider
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(ensureBearerToken_exports);
|
|
30
|
+
var import_deep_assign = require("@homer0/deep-assign");
|
|
31
|
+
var import_utils = require("../../utils");
|
|
32
|
+
class EnsureBearerToken {
|
|
33
|
+
constructor({
|
|
34
|
+
inject: { HTTPError, statuses },
|
|
35
|
+
...options
|
|
36
|
+
}) {
|
|
37
|
+
__publicField(this, "_HTTPError");
|
|
38
|
+
__publicField(this, "_options");
|
|
39
|
+
this._HTTPError = HTTPError;
|
|
40
|
+
this._options = (0, import_deep_assign.deepAssignWithOverwrite)(
|
|
41
|
+
{
|
|
42
|
+
error: {
|
|
43
|
+
message: "Unauthorized",
|
|
44
|
+
status: statuses("unauthorized"),
|
|
45
|
+
response: {}
|
|
46
|
+
},
|
|
47
|
+
expression: /bearer (.*?)(?:$|\s)/i,
|
|
48
|
+
local: "token"
|
|
49
|
+
},
|
|
50
|
+
options
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
getMiddleware() {
|
|
54
|
+
return (req, res, next) => {
|
|
55
|
+
let unauthorized = true;
|
|
56
|
+
const {
|
|
57
|
+
headers: { authorization }
|
|
58
|
+
} = req;
|
|
59
|
+
if (authorization) {
|
|
60
|
+
const matches = this._options.expression.exec(authorization);
|
|
61
|
+
if (matches) {
|
|
62
|
+
const [, token] = matches;
|
|
63
|
+
res.locals[this._options.local] = token;
|
|
64
|
+
unauthorized = false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (unauthorized) {
|
|
68
|
+
const {
|
|
69
|
+
error: { message, status, response }
|
|
70
|
+
} = this._options;
|
|
71
|
+
next(
|
|
72
|
+
new this._HTTPError(message, status, {
|
|
73
|
+
response
|
|
74
|
+
})
|
|
75
|
+
);
|
|
76
|
+
} else {
|
|
77
|
+
next();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
get options() {
|
|
82
|
+
return (0, import_deep_assign.deepAssignWithOverwrite)({}, this._options);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const ensureBearerTokenProvider = (0, import_utils.providerCreator)(
|
|
86
|
+
(options = {}) => (app) => {
|
|
87
|
+
const { serviceName = "ensureBearerToken", ...rest } = options;
|
|
88
|
+
app.set(
|
|
89
|
+
serviceName,
|
|
90
|
+
() => new EnsureBearerToken({
|
|
91
|
+
inject: {
|
|
92
|
+
HTTPError: app.get("HTTPError"),
|
|
93
|
+
statuses: app.get("statuses")
|
|
94
|
+
},
|
|
95
|
+
...rest
|
|
96
|
+
}).getMiddleware()
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
101
|
+
0 && (module.exports = {
|
|
102
|
+
EnsureBearerToken,
|
|
103
|
+
ensureBearerTokenProvider
|
|
104
|
+
});
|
|
105
|
+
//# sourceMappingURL=ensureBearerToken.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/services/utils/ensureBearerToken.ts"],"sourcesContent":["import { deepAssignWithOverwrite } from '@homer0/deep-assign';\nimport { providerCreator, type Statuses } from '../../utils';\nimport type { HTTPErrorClass } from '../common';\nimport type { DeepPartial, ExpressMiddleware } from '../../types';\n/**\n * The options for the error the middleare can generate.\n *\n * @group Services/EnsureBearerToken\n */\nexport type EnsureBearerTokenErrorOptions = {\n /**\n * The error message for the response.\n *\n * @default 'Unauthorized'\n */\n message: string;\n /**\n * The HTTP status that will be added to the error context.\n *\n * @default 401\n */\n status: number;\n /**\n * Context information for the error handler and that can be added to the actual\n * response.\n */\n response: unknown;\n};\n/**\n * The options to customize the service/middleware.\n *\n * @group Services/EnsureBearerToken\n */\nexport type EnsureBearerTokenOptions = {\n error: EnsureBearerTokenErrorOptions;\n expression: RegExp;\n local: string;\n};\n/**\n * The options to construct a {@link EnsureBearerToken}.\n *\n * @group Services/EnsureBearerToken\n */\nexport type EnsureBearerConstructorOptions = DeepPartial<EnsureBearerTokenOptions> & {\n /**\n * A dictionary with the dependencies to inject.\n */\n inject: {\n HTTPError: HTTPErrorClass;\n statuses: Statuses;\n };\n};\n/**\n * Custom options for the provider that will register an instance of\n * {@link EnsureBearerToken}\n * as a service.\n *\n * @group Services/EnsureBearerToken\n */\nexport type EnsureBearerTokenProviderOptions = DeepPartial<EnsureBearerTokenOptions> & {\n /**\n * The name that will be used to register the service on the container. This is to allow\n * multiple \"instances\" of the service to be created.\n *\n * @default 'ensureBearerToken'\n */\n serviceName?: string;\n};\n/**\n * This service gives you a middleware that verifies if a request has an `Authorization`\n * header with a bearer token; if it does, the token will be saved on the `res.locals`,\n * otherwise, it will generate an error.\n *\n * This is a \"service middleware\" to allow certain flexibility: you can have controllers\n * where some routes are protected and others are not. For those cases, you get the\n * service from the container, and include it only in the routes that need it.\n *\n * @group Services\n * @group Services/EnsureBearerToken\n */\nexport class EnsureBearerToken {\n /**\n * To generate the errors when the validation fails.\n */\n protected readonly _HTTPError: HTTPErrorClass;\n /**\n * The customization options for the service.\n */\n protected readonly _options: EnsureBearerTokenOptions;\n /**\n * @param options The options to construct the class.\n */\n constructor({\n inject: { HTTPError, statuses },\n ...options\n }: EnsureBearerConstructorOptions) {\n this._HTTPError = HTTPError;\n this._options = deepAssignWithOverwrite(\n {\n error: {\n message: 'Unauthorized',\n status: statuses('unauthorized'),\n response: {},\n },\n expression: /bearer (.*?)(?:$|\\s)/i,\n local: 'token',\n },\n options,\n );\n }\n /**\n * Generates the middleware that verifies if a request has an `Authorization` header\n * with a bearer token.\n */\n getMiddleware(): ExpressMiddleware {\n return (req, res, next) => {\n let unauthorized = true;\n const {\n headers: { authorization },\n } = req;\n if (authorization) {\n const matches = this._options.expression.exec(authorization);\n if (matches) {\n const [, token] = matches;\n res.locals[this._options.local] = token;\n unauthorized = false;\n }\n }\n\n if (unauthorized) {\n const {\n error: { message, status, response },\n } = this._options;\n next(\n new this._HTTPError(message, status, {\n response,\n }),\n );\n } else {\n next();\n }\n };\n }\n /**\n * The customization options.\n */\n get options(): Readonly<EnsureBearerTokenOptions> {\n return deepAssignWithOverwrite({}, this._options);\n }\n}\n/**\n * Generates a \"service middleware\" that can be used on route controllers in order to\n * validate the presence of a bearer token on the requests authorization header.\n *\n * The registered service is an instance of {@link EnsureBearerToken}, and it uses the key\n * `ensureBearerToken`.\n *\n * Since it's a \"provider creator\", when registering it, you can pass custom options.\n *\n * @example\n *\n * <caption>Basic usage</caption>\n *\n * // Register it on the container\n * container.register(ensureBearerTokenProvider);\n *\n * // Let's assume we are in a controller now...\n * // Getting access to the middleware.\n * const ensureBearerToken = container.get<ExpressMiddleware>('ensureBearerToken');\n *\n * @example\n *\n * <caption>Customizing the service</caption>\n *\n * // Register it on the container\n * container.register(\n * ensureBearerTokenProvider({\n * serviceName: 'ensureBearerTokenCustom',\n * error: {\n * message: 'Missing token!',\n * },\n * }),\n * );\n *\n * @group Providers\n * @group Services/EnsureBearerToken\n */\nexport const ensureBearerTokenProvider = providerCreator(\n (options: EnsureBearerTokenProviderOptions = {}) =>\n (app) => {\n const { serviceName = 'ensureBearerToken', ...rest } = options;\n app.set(serviceName, () =>\n new EnsureBearerToken({\n inject: {\n HTTPError: app.get('HTTPError'),\n statuses: app.get('statuses'),\n },\n ...rest,\n }).getMiddleware(),\n );\n },\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAwC;AACxC,mBAA+C;AA+ExC,MAAM,kBAAkB;AAAA,EAY7B,YAAY;AAAA,IACV,QAAQ,EAAE,WAAW,SAAS;AAAA,OAC3B;AAAA,EACL,GAAmC;AAXnC,wBAAmB;AAInB,wBAAmB;AAQjB,SAAK,aAAa;AAClB,SAAK,eAAW;AAAA,MACd;AAAA,QACE,OAAO;AAAA,UACL,SAAS;AAAA,UACT,QAAQ,SAAS,cAAc;AAAA,UAC/B,UAAU,CAAC;AAAA,QACb;AAAA,QACA,YAAY;AAAA,QACZ,OAAO;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EAKA,gBAAmC;AACjC,WAAO,CAAC,KAAK,KAAK,SAAS;AACzB,UAAI,eAAe;AACnB,YAAM;AAAA,QACJ,SAAS,EAAE,cAAc;AAAA,MAC3B,IAAI;AACJ,UAAI,eAAe;AACjB,cAAM,UAAU,KAAK,SAAS,WAAW,KAAK,aAAa;AAC3D,YAAI,SAAS;AACX,gBAAM,CAAC,EAAE,KAAK,IAAI;AAClB,cAAI,OAAO,KAAK,SAAS,SAAS;AAClC,yBAAe;AAAA,QACjB;AAAA,MACF;AAEA,UAAI,cAAc;AAChB,cAAM;AAAA,UACJ,OAAO,EAAE,SAAS,QAAQ,SAAS;AAAA,QACrC,IAAI,KAAK;AACT;AAAA,UACE,IAAI,KAAK,WAAW,SAAS,QAAQ;AAAA,YACnC;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF,OAAO;AACL,aAAK;AAAA,MACP;AAAA,IACF;AAAA,EACF;AAAA,EAIA,IAAI,UAA8C;AAChD,eAAO,4CAAwB,CAAC,GAAG,KAAK,QAAQ;AAAA,EAClD;AACF;AAsCO,MAAM,gCAA4B;AAAA,EACvC,CAAC,UAA4C,CAAC,MAC5C,CAAC,QAAQ;AACP,UAAM,EAAE,cAAc,wBAAwB,KAAK,IAAI;AACvD,QAAI;AAAA,MAAI;AAAA,MAAa,MACnB,IAAI,kBAAkB;AAAA,QACpB,QAAQ;AAAA,UACN,WAAW,IAAI,IAAI,WAAW;AAAA,UAC9B,UAAU,IAAI,IAAI,UAAU;AAAA,QAC9B;AAAA,QACA,GAAG;AAAA,MACL,CAAC,EAAE,cAAc;AAAA,IACnB;AAAA,EACF;AACJ;","names":[]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
+
import { J as Jimpex } from '../../jimpex-7eaee271.js';
|
|
3
|
+
import { EnsureBearerTokenProviderOptions } from './ensureBearerToken.js';
|
|
4
|
+
export { EnsureBearerConstructorOptions, EnsureBearerToken, EnsureBearerTokenErrorOptions, EnsureBearerTokenOptions, ensureBearerTokenProvider } from './ensureBearerToken.js';
|
|
5
|
+
import '@homer0/events-hub';
|
|
6
|
+
import '../../types/express.js';
|
|
7
|
+
import 'express';
|
|
8
|
+
import '../../types/http.js';
|
|
9
|
+
import 'https';
|
|
10
|
+
import 'http';
|
|
11
|
+
import 'spdy';
|
|
12
|
+
import 'node-fetch';
|
|
13
|
+
import '@homer0/simple-config';
|
|
14
|
+
import '../../types/utils.js';
|
|
15
|
+
import '@homer0/simple-logger';
|
|
16
|
+
import '../../utils/fns/statuses.js';
|
|
17
|
+
import 'statuses';
|
|
18
|
+
import '../common/httpError.js';
|
|
19
|
+
import '../common/appError.js';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Registers all the utility services on the container.
|
|
23
|
+
*
|
|
24
|
+
* - {@link EnsureBearerToken | ensureBearerToken}
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
*
|
|
28
|
+
* // Register the collection on the container
|
|
29
|
+
* container.register(utilsServicesProvider);
|
|
30
|
+
* // Getting access to one the services instance
|
|
31
|
+
* const ensureBearerToken = container.get<EnsureBearerToken>('ensureBearerToken');
|
|
32
|
+
*
|
|
33
|
+
* @group Providers
|
|
34
|
+
*/
|
|
35
|
+
declare const utilsServicesProvider: {
|
|
36
|
+
ensureBearerTokenProvider: _homer0_jimple.ResourceCreator<"provider", "register", (options?: EnsureBearerTokenProviderOptions) => (app: Jimpex) => void, _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
37
|
+
} & Record<string, _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>> & {
|
|
38
|
+
provider: true;
|
|
39
|
+
} & {
|
|
40
|
+
register: _homer0_jimple.ProviderRegisterFn<Jimpex>;
|
|
41
|
+
} & Record<string, unknown>;
|
|
42
|
+
|
|
43
|
+
export { EnsureBearerTokenProviderOptions, utilsServicesProvider };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var utils_exports = {};
|
|
21
|
+
__export(utils_exports, {
|
|
22
|
+
utilsServicesProvider: () => utilsServicesProvider
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(utils_exports);
|
|
25
|
+
var import_utils = require("../../utils");
|
|
26
|
+
var import_ensureBearerToken = require("./ensureBearerToken");
|
|
27
|
+
__reExport(utils_exports, require("./ensureBearerToken"), module.exports);
|
|
28
|
+
const utilsServicesProvider = (0, import_utils.providers)({
|
|
29
|
+
ensureBearerTokenProvider: import_ensureBearerToken.ensureBearerTokenProvider
|
|
30
|
+
});
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
utilsServicesProvider
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/services/utils/index.ts"],"sourcesContent":["import { providers } from '../../utils';\nimport { ensureBearerTokenProvider } from './ensureBearerToken';\n/**\n * Registers all the utility services on the container.\n *\n * - {@link EnsureBearerToken | ensureBearerToken}\n *\n * @example\n *\n * // Register the collection on the container\n * container.register(utilsServicesProvider);\n * // Getting access to one the services instance\n * const ensureBearerToken = container.get<EnsureBearerToken>('ensureBearerToken');\n *\n * @group Providers\n */\nexport const utilsServicesProvider = providers({\n ensureBearerTokenProvider,\n});\n\nexport * from './ensureBearerToken';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0B;AAC1B,+BAA0C;AAmB1C,0BAAc,gCApBd;AAgBO,MAAM,4BAAwB,wBAAU;AAAA,EAC7C;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import './express.js';
|
|
2
|
+
export { E as EventPayload, l as Events, k as JimpexEventListener, b as JimpexEventName, i as JimpexEventNameLike, c as JimpexEventPayload, a as JimpexEvents, f as JimpexReducerEventName, h as JimpexReducerEventPayload, e as JimpexReducerEventPayloads, g as JimpexReducerEventTarget, d as JimpexReducerEventTargets } from '../jimpex-7eaee271.js';
|
|
3
|
+
import 'express';
|
|
4
|
+
import '@homer0/jimple';
|
|
5
|
+
import '@homer0/events-hub';
|
|
6
|
+
import './http.js';
|
|
7
|
+
import 'https';
|
|
8
|
+
import 'http';
|
|
9
|
+
import 'spdy';
|
|
10
|
+
import 'node-fetch';
|
|
11
|
+
import '@homer0/simple-config';
|
|
12
|
+
import './utils.js';
|
|
13
|
+
import '@homer0/simple-logger';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var events_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(events_exports);
|
|
17
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/types/events.ts"],"sourcesContent":["import type { Router, ExpressMiddlewareLike } from './express';\nimport type { Controller, Middleware } from '../utils';\nimport type { Jimpex } from '../app/jimpex';\n/**\n * The base payload the events emitted by the application send.\n *\n * @template T Extra properties beside the reference to the application.\n * @group Services/Events\n */\nexport type EventPayload<T = Record<string, unknown>> = {\n /**\n * A reference to the application.\n */\n app: Jimpex;\n} & T;\n/**\n * A dictionary with the events emitted by the application and their payloads.\n *\n * @group Services/Events\n */\nexport interface JimpexEvents {\n /**\n * Called right before creating the server and calling `listen` on it.\n */\n beforeStart: EventPayload;\n /**\n * Called once the server confirmed that is listening.\n */\n start: EventPayload;\n /**\n * Called after the controllers and middlewares have been mounted.\n */\n afterStart: EventPayload;\n /**\n * Called after the `onStart` callback has been called.\n */\n afterStartCallback: EventPayload;\n /**\n * Called before closing the server instance.\n */\n beforeStop: EventPayload;\n /**\n * Called after the server instance has been closed.\n */\n afterStop: EventPayload;\n /**\n * Called every time a new route is mounted in the application.\n */\n routeAdded: EventPayload<{ route: string }>;\n}\n/**\n * The events emitted by the application.\n *\n * @group Services/Events\n */\nexport type JimpexEventName = keyof JimpexEvents;\n/**\n * The type of the payload sent by a specific event.\n *\n * @template EventName The literal type of the event, to obtain the type of the\n * payload.\n * @group Services/Events\n */\nexport type JimpexEventPayload<EventName extends JimpexEventName> =\n JimpexEvents[EventName];\n/**\n * A dictionary of the reducer events and their targets.\n *\n * @group Services/Events\n */\nexport interface JimpexReducerEventTargets {\n /**\n * It gets called before mounting a router/middleware for a specific route.\n */\n controllerWillBeMounted: Router | ExpressMiddlewareLike;\n /**\n * It gets called before using a middleware without route.\n */\n middlewareWillBeUsed: ExpressMiddlewareLike;\n}\n/**\n * A dictionary of the payloads the reducer events the application uses.\n *\n * @group Services/Events\n */\nexport interface JimpexReducerEventPayloads {\n /**\n * It gets called before mounting a router/middleware for a specific route.\n */\n controllerWillBeMounted: EventPayload<{\n /**\n * The route in which the controller will be mounted.\n */\n route: string;\n /**\n * A reference for the controller/middleware before being \"connected\".\n */\n controller: Controller | Middleware;\n }>;\n /**\n * It gets called before using a middleware without route.\n */\n middlewareWillBeUsed: EventPayload;\n}\n/**\n * The reducer events used by the application.\n *\n * @group Services/Events\n */\nexport type JimpexReducerEventName = keyof JimpexReducerEventTargets;\n/**\n * The type of the target of a specific reducer event.\n *\n * @template EventName The literal type of the event, to obtain the type of the\n * target.\n * @group Services/Events\n */\nexport type JimpexReducerEventTarget<EventName extends JimpexReducerEventName> =\n JimpexReducerEventTargets[EventName];\n/**\n * The type of the payload of a specific reducer event.\n *\n * @template EventName The literal type of the event, to obtain the type of the\n * payload.\n * @group Services/Events\n */\nexport type JimpexReducerEventPayload<EventName extends JimpexReducerEventName> =\n JimpexReducerEventPayloads[EventName];\n/**\n * The name of the events o reducer events emitted/used by the application.\n * This generic type exists because the listener for both types are added using the same\n * method.\n *\n * @group Services/Events\n */\nexport type JimpexEventNameLike = JimpexEventName | JimpexReducerEventName;\n/**\n * The definition of a listener for an event or a reducer event.\n *\n * @template EventName The literal type of the event, to validate whether the\n * parameters should be for a reducer event or an event.\n * @group Services/Events\n */\nexport type JimpexEventListener<EventName extends JimpexEventNameLike> =\n EventName extends JimpexEventName\n ? (payload: JimpexEventPayload<EventName>) => void\n : EventName extends JimpexReducerEventName\n ? (\n target: JimpexReducerEventTarget<EventName>,\n payload: JimpexReducerEventPayload<EventName>,\n ) => JimpexReducerEventTarget<EventName>\n : never;\n/**\n * The `events` service Jimpex uses.\n * This is an alternative declaration of the `EventsHub` class that uses the interfaces\n * and types from this project.\n *\n * @group Services\n * @group Services/Events\n */\nexport type Events = {\n /**\n * Adds a new event listener.\n *\n * @param event The name of the event.\n * @param listener The listener function.\n * @returns An unsubscribe function to remove the listener.\n * @template EventName The literal type of the event, to generate the type of the\n * listener.\n * @example\n *\n * const unsubscribe = events.on('afterStart', ({ app }) => {\n * app.getLogger().info('Hello world!');\n * unsubscribe();\n * });\n *\n */\n on: <EventName extends JimpexEventNameLike>(\n eventName: EventName,\n listener: JimpexEventListener<EventName>,\n ) => () => boolean;\n /**\n * Adds an event listener that will only be executed once.\n *\n * @param event The name of the event.\n * @param listener The listener function.\n * @returns An unsubscribe function to remove the listener.\n * @template EventName The literal type of the event, to generate the type of the\n * listener.\n * @example\n *\n * events.once('afterStart', ({ app }) => {\n * app.getLogger().info('Hello world!');\n * unsubscribe();\n * });\n *\n */\n once: <EventName extends JimpexEventNameLike>(\n eventName: EventName,\n listener: JimpexEventListener<EventName>,\n ) => () => boolean;\n /**\n * Emits an event and call all its listeners.\n *\n * @param event The name of the events.\n * @param payload Context information for the event.\n * @template EventName The literal type of the event, to generate the type of the\n * payload.\n * @example\n *\n * // Extend the interface to type the payload.\n * interface JimpexEvents {\n * myEvent: { message: string };\n * }\n * // Add the listener.\n * events.on('myEvent', ({ message }) => {\n * console.log('Event received:', message);\n * });\n * // Trigger the event.\n * events.emit('myEvent', { message: 'Hello' });\n * // prints \"Event received: Hello\"\n *\n */\n emit: <EventName extends JimpexEventName>(\n event: JimpexEventName,\n payload: JimpexEventPayload<EventName>,\n ) => void;\n /**\n * Asynchronously reduces a target using an event. It's like emit, but the event\n * listeners return a modified (or not) version of the `target`.\n *\n * @param event The name of the event.\n * @param target The variable to reduce with the reducers/listeners.\n * @param payload Context information for the event.\n * @returns A version of the `target` processed by the listeners.\n * @template EventName The literal type of the event, to generate the types of the\n * target and the payload.\n * @example\n *\n * // Extend the interface to type the target.\n * interface JimpexReducerEventTargets {\n * myReducer: unknown[];\n * }\n * // Extend the interface to type the payload.\n * interface JimpexReducerEventPayloads {\n * myReducer: {\n * message: string;\n * };\n * }\n * // Add the reducer.\n * events.on('myReducer', async (target, { message }) => {\n * const data = await fetch('https://api.example.com/' + message);\n * target.push(data);\n * return target;\n * });\n * // Trigger the event.\n * const result = await events.reduce('myReducer', [], { message: 'Hello' });\n * // result would be a list of data fetched from the API.\n *\n */\n reduce: <EventName extends JimpexReducerEventName>(\n event: JimpexReducerEventName,\n target: JimpexReducerEventTarget<EventName>,\n payload: JimpexReducerEventPayload<EventName>,\n ) => Promise<JimpexReducerEventTarget<EventName>>;\n /**\n * Synchronously reduces a target using an event. It's like emit, but the events\n * listener return a modified (or not) version of the `target`.\n *\n * @param event The name of the event.\n * @param target The variable to reduce with the reducers/listeners.\n * @param payload Context information for the event.\n * @returns A version of the `target` processed by the listeners.\n * @template EventName The literal type of the event, to generate the types of the\n * target and the payload.\n * @example\n *\n * // Extend the interface to type the target.\n * interface JimpexReducerEventTargets {\n * myReducer: string[];\n * }\n * // Extend the interface to type the payload.\n * interface JimpexReducerEventPayloads {\n * myReducer: {\n * message: string;\n * };\n * }\n * // Add the reducer.\n * events.on('myReducer', (target, { message }) => {\n * target.push(message);\n * return target;\n * });\n * // Trigger the event.\n * events.reduce('event', [], 'Hello');\n * // returns ['Hello']\n *\n */\n reduceSync: <EventName extends JimpexReducerEventName>(\n event: JimpexReducerEventName,\n target: JimpexReducerEventTarget<EventName>,\n payload: JimpexReducerEventPayload<EventName>,\n ) => JimpexReducerEventTarget<EventName>;\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RequestHandler, ErrorRequestHandler } from 'express';
|
|
2
|
+
export { Express, NextFunction, Request, Response, Router } from 'express';
|
|
3
|
+
|
|
4
|
+
type ExpressMiddlewareLike = RequestHandler | ErrorRequestHandler;
|
|
5
|
+
type ExpressMiddleware = RequestHandler;
|
|
6
|
+
type AsyncExpressMiddleware = (...args: Parameters<ExpressMiddleware>) => Promise<void>;
|
|
7
|
+
type ExpressErrorHandler = ErrorRequestHandler;
|
|
8
|
+
type RouterMethod = 'all' | 'get' | 'head' | 'post' | 'patch' | 'put' | 'delete' | 'connect' | 'options' | 'trace';
|
|
9
|
+
|
|
10
|
+
export { AsyncExpressMiddleware, ExpressErrorHandler, ExpressMiddleware, ExpressMiddlewareLike, RouterMethod };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var express_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(express_exports);
|
|
17
|
+
//# sourceMappingURL=express.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/types/express.ts"],"sourcesContent":["import type { RequestHandler, ErrorRequestHandler } from 'express';\n\nexport type { Express, Router, Request, Response, NextFunction } from 'express';\n\nexport type ExpressMiddlewareLike = RequestHandler | ErrorRequestHandler;\nexport type ExpressMiddleware = RequestHandler;\nexport type AsyncExpressMiddleware = (\n ...args: Parameters<ExpressMiddleware>\n) => Promise<void>;\nexport type ExpressErrorHandler = ErrorRequestHandler;\nexport type RouterMethod =\n | 'all'\n | 'get'\n | 'head'\n | 'post'\n | 'patch'\n | 'put'\n | 'delete'\n | 'connect'\n | 'options'\n | 'trace';\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Server } from 'https';
|
|
2
|
+
export { Server as HTTPSServer } from 'https';
|
|
3
|
+
import { Server as Server$1 } from 'http';
|
|
4
|
+
export { Server as HTTPServer } from 'http';
|
|
5
|
+
import { ServerOptions } from 'spdy';
|
|
6
|
+
import { Express } from 'express';
|
|
7
|
+
export { Response as HTTPResponse } from 'node-fetch';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @group Jimpex
|
|
11
|
+
*/
|
|
12
|
+
type JimpexServer = Express | Server;
|
|
13
|
+
/**
|
|
14
|
+
* @group Jimpex
|
|
15
|
+
*/
|
|
16
|
+
type JimpexServerInstance = Server$1 | Server;
|
|
17
|
+
/**
|
|
18
|
+
* The paths to the SSL credentials. Depending on the application options, they can be
|
|
19
|
+
* relative to the project root, or the application executable, but they can't be
|
|
20
|
+
* absolute.
|
|
21
|
+
*
|
|
22
|
+
* @group Jimpex
|
|
23
|
+
*/
|
|
24
|
+
type JimpexHTTPSCredentials = {
|
|
25
|
+
/**
|
|
26
|
+
* The path to the certificate authority file.
|
|
27
|
+
*/
|
|
28
|
+
ca?: string;
|
|
29
|
+
/**
|
|
30
|
+
* The path to the certificate file.
|
|
31
|
+
*/
|
|
32
|
+
cert?: string;
|
|
33
|
+
/**
|
|
34
|
+
* The path to the key file.
|
|
35
|
+
*/
|
|
36
|
+
key?: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The options to enable HTTP2.
|
|
40
|
+
*
|
|
41
|
+
* @group Jimpex
|
|
42
|
+
*/
|
|
43
|
+
type JimpexHTTP2Options = {
|
|
44
|
+
/**
|
|
45
|
+
* Whether or not to enable HTTP2.
|
|
46
|
+
*/
|
|
47
|
+
enabled?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Custom options for the Spdy server.
|
|
50
|
+
*
|
|
51
|
+
* @see {@link https://github.com/spdy-http2/node-spdy#options}
|
|
52
|
+
*/
|
|
53
|
+
spdy?: ServerOptions['spdy'];
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* The options to enable HTTPS.
|
|
57
|
+
*
|
|
58
|
+
* @group Jimpex
|
|
59
|
+
*/
|
|
60
|
+
type JimpexHTTPSOptions = {
|
|
61
|
+
/**
|
|
62
|
+
* Whether or not to enable HTTPS.
|
|
63
|
+
*/
|
|
64
|
+
enabled?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* The SSL credentials, and their location.
|
|
67
|
+
*/
|
|
68
|
+
credentials?: JimpexHTTPSCredentials & {
|
|
69
|
+
/**
|
|
70
|
+
* If `true`, the credentials will be located relative to the project root, otherwise,
|
|
71
|
+
* they will be located relative to the application executable.
|
|
72
|
+
*
|
|
73
|
+
* @default false
|
|
74
|
+
*/
|
|
75
|
+
onHome?: boolean;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export { JimpexHTTP2Options, JimpexHTTPSCredentials, JimpexHTTPSOptions, JimpexServer, JimpexServerInstance };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var http_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(http_exports);
|
|
17
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/types/http.ts"],"sourcesContent":["import type { Server as HTTPSServer } from 'https';\nimport type { Server as HTTPServer } from 'http';\nimport type { ServerOptions as SpdyServerOptions } from 'spdy';\nimport type { Express } from './express';\n\nexport type { Response as HTTPResponse } from 'node-fetch';\n\nexport type { HTTPSServer, HTTPServer };\n/**\n * @group Jimpex\n */\nexport type JimpexServer = Express | HTTPSServer;\n/**\n * @group Jimpex\n */\nexport type JimpexServerInstance = HTTPServer | HTTPSServer;\n/**\n * The paths to the SSL credentials. Depending on the application options, they can be\n * relative to the project root, or the application executable, but they can't be\n * absolute.\n *\n * @group Jimpex\n */\nexport type JimpexHTTPSCredentials = {\n /**\n * The path to the certificate authority file.\n */\n ca?: string;\n /**\n * The path to the certificate file.\n */\n cert?: string;\n /**\n * The path to the key file.\n */\n key?: string;\n};\n/**\n * The options to enable HTTP2.\n *\n * @group Jimpex\n */\nexport type JimpexHTTP2Options = {\n /**\n * Whether or not to enable HTTP2.\n */\n enabled?: boolean;\n /**\n * Custom options for the Spdy server.\n *\n * @see {@link https://github.com/spdy-http2/node-spdy#options}\n */\n spdy?: SpdyServerOptions['spdy'];\n};\n/**\n * The options to enable HTTPS.\n *\n * @group Jimpex\n */\nexport type JimpexHTTPSOptions = {\n /**\n * Whether or not to enable HTTPS.\n */\n enabled?: boolean;\n /**\n * The SSL credentials, and their location.\n */\n credentials?: JimpexHTTPSCredentials & {\n /**\n * If `true`, the credentials will be located relative to the project root, otherwise,\n * they will be located relative to the application executable.\n *\n * @default false\n */\n onHome?: boolean;\n };\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { E as EventPayload, l as Events, m as JimpexConfigOptions, k as JimpexEventListener, b as JimpexEventName, i as JimpexEventNameLike, c as JimpexEventPayload, a as JimpexEvents, o as JimpexExpressOptions, s as JimpexHealthCheckFn, r as JimpexHealthStatus, t as JimpexOptions, p as JimpexPathOptions, f as JimpexReducerEventName, h as JimpexReducerEventPayload, e as JimpexReducerEventPayloads, g as JimpexReducerEventTarget, d as JimpexReducerEventTargets, q as JimpexServicesOptions, u as JimpexStartCallback, n as JimpexStaticsOptions } from '../jimpex-7eaee271.js';
|
|
2
|
+
export { AsyncExpressMiddleware, ExpressErrorHandler, ExpressMiddleware, ExpressMiddlewareLike, RouterMethod } from './express.js';
|
|
3
|
+
export { JimpexHTTP2Options, JimpexHTTPSCredentials, JimpexHTTPSOptions, JimpexServer, JimpexServerInstance } from './http.js';
|
|
4
|
+
export { DeepPartial, DeepReadonly, Dict, NoStringIndex } from './utils.js';
|
|
5
|
+
export { PathUtils } from '@homer0/path-utils';
|
|
6
|
+
export { SimpleLogger as Logger } from '@homer0/simple-logger';
|
|
7
|
+
export { SimpleConfig as Config } from '@homer0/simple-config';
|
|
8
|
+
export { EventsHub } from '@homer0/events-hub';
|
|
9
|
+
export { Express, NextFunction, Request, Response, Router } from 'express';
|
|
10
|
+
export { Response as HTTPResponse } from 'node-fetch';
|
|
11
|
+
export { Server as HTTPSServer } from 'https';
|
|
12
|
+
export { Server as HTTPServer } from 'http';
|
|
13
|
+
import '@homer0/jimple';
|
|
14
|
+
import 'spdy';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var types_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(types_exports);
|
|
18
|
+
__reExport(types_exports, require("./events"), module.exports);
|
|
19
|
+
__reExport(types_exports, require("./express"), module.exports);
|
|
20
|
+
__reExport(types_exports, require("./http"), module.exports);
|
|
21
|
+
__reExport(types_exports, require("./options"), module.exports);
|
|
22
|
+
__reExport(types_exports, require("./utils"), module.exports);
|
|
23
|
+
__reExport(types_exports, require("./wootils"), module.exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["export * from './events';\nexport * from './express';\nexport * from './http';\nexport * from './options';\nexport * from './utils';\nexport * from './wootils';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,qBAAd;AACA,0BAAc,sBADd;AAEA,0BAAc,mBAFd;AAGA,0BAAc,sBAHd;AAIA,0BAAc,oBAJd;AAKA,0BAAc,sBALd;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import '@homer0/simple-config';
|
|
2
|
+
export { m as JimpexConfigOptions, o as JimpexExpressOptions, s as JimpexHealthCheckFn, r as JimpexHealthStatus, t as JimpexOptions, p as JimpexPathOptions, q as JimpexServicesOptions, u as JimpexStartCallback, n as JimpexStaticsOptions } from '../jimpex-7eaee271.js';
|
|
3
|
+
import '@homer0/jimple';
|
|
4
|
+
import '@homer0/events-hub';
|
|
5
|
+
import './express.js';
|
|
6
|
+
import 'express';
|
|
7
|
+
import './http.js';
|
|
8
|
+
import 'https';
|
|
9
|
+
import 'http';
|
|
10
|
+
import 'spdy';
|
|
11
|
+
import 'node-fetch';
|
|
12
|
+
import './utils.js';
|
|
13
|
+
import '@homer0/simple-logger';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var options_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(options_exports);
|
|
17
|
+
//# sourceMappingURL=options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/types/options.ts"],"sourcesContent":["import type { Config } from './wootils';\nimport type { Jimpex } from '../app';\n/**\n * The options for the application's configuration service.\n *\n * @see {@link https://www.npmjs.com/package/@homer0/simple-config}\n * @group Jimpex\n */\nexport type JimpexConfigOptions = {\n /**\n * The default settings for the configuration. If no external configuration is used,\n * this needs to include a `port` property.\n */\n default: unknown;\n /**\n * The name of the application, used for external configuration files.\n *\n * @default 'app'\n */\n name: string;\n /**\n * The path to where external configuration files are stored. Relative to the project\n * root.\n *\n * @default 'config/'\n */\n path: string;\n /**\n * Whether the configuration files are inside a sub directory or not. If `true`, a\n * configuration path would be `config/[app-name]/[file]`.\n *\n * @default false\n */\n hasFolder: boolean;\n /**\n * Whether or not to check for the environment variable and load a configuration file\n * based on its value.\n *\n * @default true\n */\n loadFromEnvironment: boolean;\n /**\n * The name of the environment variable that will be used to set the active\n * configuration.\n *\n * @default 'CONFIG'\n */\n environmentVariable: string;\n /**\n * The name of the default configuration file.\n *\n * @default '[app-name].config.js'\n */\n defaultConfigFilename: string;\n /**\n * The name format of other external configuration files.\n *\n * @default '[app-name].[config-name].config.js'\n */\n filenameFormat: string;\n};\n/**\n * The options for the middleware that serves static files.\n *\n * @group Jimpex\n */\nexport type JimpexStaticsOptions = {\n /**\n * Whether or not to enable the middleware.\n *\n * @default true\n */\n enabled: boolean;\n /**\n * If `true`, the path to the statics folder will be relative to the project root\n * directory, otherwise, it will be relative to the directory where the app executable\n * file is located.\n *\n * @default false\n */\n onHome: boolean;\n /**\n * The name of both the route and the folder, relative to whatever you defined with the\n * `onHome` option.\n *\n * @default 'statics'\n */\n route: string;\n /**\n * By default, the folder will be the same as the `route`,\n * but you can use this option to define a relative path that won't affect the route.\n *\n * @default ''\n */\n folder?: string;\n};\n/**\n * The options for the Express application.\n *\n * @group Jimpex\n */\nexport type JimpexExpressOptions = {\n /**\n * Whether or not to enable the `trust proxy` option.\n *\n * @default true\n */\n trustProxy: boolean;\n /**\n * Whether or not to remove the `x-powered-by` header.\n *\n * @default true\n */\n disableXPoweredBy: boolean;\n /**\n * Whether or not to add the `compression` middleware.\n *\n * @default true\n */\n compression: boolean;\n /**\n * Whether or not to add the `body-parser` middleware.\n *\n * @default true\n */\n bodyParser: boolean;\n /**\n * Whether or not to add the `multer` middleware.\n *\n * @see {@link https://www.npmjs.com/package/multer}\n */\n multer: boolean;\n};\n/**\n * The options to configure the application executable path.\n *\n * @group Jimpex\n */\nexport type JimpexPathOptions = {\n /**\n * A \"hardcoded\" path to the application executable file.\n *\n * @default ''\n */\n appPath?: string;\n /**\n * If `true`, it will try to figure out the parent file path, and use its directory as\n * the path.\n *\n * @default true\n */\n useParentPath: boolean;\n};\n/**\n * The options to enable some of the default services Jimpex comes with.\n *\n * @group Jimpex\n */\nexport type JimpexServicesOptions = {\n /**\n * Whether or not to register all the `common` services: `appError`, `httpError`, and\n * `sendFile`.\n *\n * @default true\n */\n common: boolean;\n /**\n * Whether or not to register the `http` services: `apiClient`, `http`, and\n * `responsesBuilder`.\n *\n * @default true\n */\n http: boolean;\n /**\n * Whether or not to register the `utils` services: `ensureBearerToken`.\n */\n utils: boolean;\n};\n/**\n * The format in which the application's health status can be returned.\n * It's either a simple boolean, or a more detailed object.\n *\n * @group Jimpex\n */\nexport type JimpexHealthStatus =\n | boolean\n | {\n isHealthy?: boolean;\n services?: Record<string, boolean>;\n };\n/**\n * Returns the application health status. This is normally used by the `healthController`.\n *\n * @group Jimpex\n */\nexport type JimpexHealthCheckFn = (app: Jimpex) => Promise<JimpexHealthStatus>;\n/**\n * The options to create a new instance of Jimpex.\n *\n * @group Jimpex\n */\nexport type JimpexOptions = {\n /**\n * The size limit for the requests payload.\n *\n * @default '15MB'\n */\n filesizeLimit: string;\n /**\n * Whether or not to call the `boot` method after initialization. This is useful if you\n * want to register/overwrite services only on certain contexts, like a dev environment.\n *\n * @default true\n */\n boot: boolean;\n /**\n * The options to configure the application executable path.\n */\n path: JimpexPathOptions;\n /**\n * Options for the configuration service.\n *\n * @see {@link https://www.npmjs.com/package/@homer0/simple-config}\n */\n config: JimpexConfigOptions;\n /**\n * Options for the middleware that serves static files.\n */\n statics: JimpexStaticsOptions;\n /**\n * Options for the Express application.\n */\n express: JimpexExpressOptions;\n /**\n * Options to manage the default services.\n */\n services: JimpexServicesOptions;\n /**\n * A function that will be used to check the application health status.\n */\n healthCheck: JimpexHealthCheckFn;\n};\n/**\n * The function called when the application starts listening for requests.\n *\n * @group Jimpex\n */\nexport type JimpexStartCallback = (config: Config) => void;\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A simple dictionary with unknown values.
|
|
3
|
+
*
|
|
4
|
+
* @group Utilities
|
|
5
|
+
*/
|
|
6
|
+
type Dict = Record<string, unknown>;
|
|
7
|
+
/**
|
|
8
|
+
* Utility to make a deep "partial" of an existing type.
|
|
9
|
+
*
|
|
10
|
+
* @template T The type to make a partial of.
|
|
11
|
+
* @group Utilities
|
|
12
|
+
*/
|
|
13
|
+
type DeepPartial<T> = {
|
|
14
|
+
[P in keyof T]?: T[P] extends (infer U)[] ? DeepPartial<U>[] : T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Utility to make a deep "readonly" of an existing type.
|
|
18
|
+
*
|
|
19
|
+
* @template T The type to make a readonly of.
|
|
20
|
+
* @group Utilities
|
|
21
|
+
*/
|
|
22
|
+
type DeepReadonly<T> = {
|
|
23
|
+
readonly [P in keyof T]: T[P] extends (infer U)[] ? DeepReadonly<U>[] : T[P] extends object ? DeepReadonly<T[P]> : T[P];
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Utility to remove string indexes from types.
|
|
27
|
+
*
|
|
28
|
+
* @template T The type to remove string indexes from.
|
|
29
|
+
* @example
|
|
30
|
+
*
|
|
31
|
+
* type Foo = {
|
|
32
|
+
* a: string;
|
|
33
|
+
* b: string;
|
|
34
|
+
* [key: string]: string;
|
|
35
|
+
* };
|
|
36
|
+
* type Bar = RemoveStringIndexes<Foo>;
|
|
37
|
+
* // Bar = {
|
|
38
|
+
* // a: string;
|
|
39
|
+
* // b: string;
|
|
40
|
+
* // };
|
|
41
|
+
*
|
|
42
|
+
* @group Utilities
|
|
43
|
+
*/
|
|
44
|
+
type NoStringIndex<T> = {
|
|
45
|
+
[K in keyof T as string extends K ? never : K]: T[K];
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { DeepPartial, DeepReadonly, Dict, NoStringIndex };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var utils_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(utils_exports);
|
|
17
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/types/utils.ts"],"sourcesContent":["/**\n * A simple dictionary with unknown values.\n *\n * @group Utilities\n */\nexport type Dict = Record<string, unknown>;\n/**\n * Utility to make a deep \"partial\" of an existing type.\n *\n * @template T The type to make a partial of.\n * @group Utilities\n */\nexport type DeepPartial<T> = {\n [P in keyof T]?: T[P] extends (infer U)[]\n ? DeepPartial<U>[]\n : T[P] extends object\n ? DeepPartial<T[P]>\n : T[P];\n};\n/**\n * Utility to make a deep \"readonly\" of an existing type.\n *\n * @template T The type to make a readonly of.\n * @group Utilities\n */\nexport type DeepReadonly<T> = {\n readonly [P in keyof T]: T[P] extends (infer U)[]\n ? DeepReadonly<U>[]\n : T[P] extends object\n ? DeepReadonly<T[P]>\n : T[P];\n};\n/**\n * Utility to remove string indexes from types.\n *\n * @template T The type to remove string indexes from.\n * @example\n *\n * type Foo = {\n * a: string;\n * b: string;\n * [key: string]: string;\n * };\n * type Bar = RemoveStringIndexes<Foo>;\n * // Bar = {\n * // a: string;\n * // b: string;\n * // };\n *\n * @group Utilities\n */\nexport type NoStringIndex<T> = { [K in keyof T as string extends K ? never : K]: T[K] };\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var wootils_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(wootils_exports);
|
|
17
|
+
//# sourceMappingURL=wootils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/types/wootils.ts"],"sourcesContent":["export type { PathUtils } from '@homer0/path-utils';\nexport type { SimpleLogger as Logger } from '@homer0/simple-logger';\nexport type { SimpleConfig as Config } from '@homer0/simple-config';\nexport type { EventsHub } from '@homer0/events-hub';\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { notUndefined } from './others.js';
|
|
2
|
+
export { createRouteExpression, removeLeadingSlash, removeSlashes, removeTrailingSlash } from './routes.js';
|
|
3
|
+
export { Statuses } from './statuses.js';
|
|
4
|
+
export { escapeForRegExp } from './text.js';
|
|
5
|
+
export { default as statuses } from 'statuses';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var fns_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(fns_exports);
|
|
18
|
+
__reExport(fns_exports, require("./others"), module.exports);
|
|
19
|
+
__reExport(fns_exports, require("./routes"), module.exports);
|
|
20
|
+
__reExport(fns_exports, require("./statuses"), module.exports);
|
|
21
|
+
__reExport(fns_exports, require("./text"), module.exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/fns/index.ts"],"sourcesContent":["export * from './others';\nexport * from './routes';\nexport * from './statuses';\nexport * from './text';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,qBAAd;AACA,wBAAc,qBADd;AAEA,wBAAc,uBAFd;AAGA,wBAAc,mBAHd;","names":[]}
|