jimpex 7.0.2 → 9.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 +93 -0
- package/LICENSE +1 -1
- package/README.md +447 -435
- package/dist/app/index.d.mts +14 -0
- package/dist/app/index.d.ts +14 -0
- package/dist/app/index.js +23 -0
- package/dist/app/index.js.map +1 -0
- package/dist/app/jimpex.d.mts +14 -0
- package/dist/app/jimpex.d.ts +14 -0
- package/dist/app/jimpex.js +665 -0
- package/dist/app/jimpex.js.map +1 -0
- package/dist/controllers/common/config.d.mts +79 -0
- package/dist/controllers/common/config.d.ts +79 -0
- package/dist/controllers/common/config.js +107 -0
- package/dist/controllers/common/config.js.map +1 -0
- package/dist/controllers/common/health.d.mts +83 -0
- package/dist/controllers/common/health.d.ts +83 -0
- package/dist/controllers/common/health.js +115 -0
- package/dist/controllers/common/health.js.map +1 -0
- package/dist/controllers/common/index.d.mts +21 -0
- package/dist/controllers/common/index.d.ts +21 -0
- package/dist/controllers/common/index.js +27 -0
- package/dist/controllers/common/index.js.map +1 -0
- package/dist/controllers/common/statics.d.mts +215 -0
- package/dist/controllers/common/statics.d.ts +215 -0
- package/dist/controllers/common/statics.js +253 -0
- package/dist/controllers/common/statics.js.map +1 -0
- package/dist/controllers/index.d.mts +24 -0
- package/dist/controllers/index.d.ts +24 -0
- package/dist/controllers/index.js +25 -0
- package/dist/controllers/index.js.map +1 -0
- package/dist/controllers/utils/gateway.d.mts +725 -0
- package/dist/controllers/utils/gateway.d.ts +725 -0
- package/dist/controllers/utils/gateway.js +577 -0
- package/dist/controllers/utils/gateway.js.map +1 -0
- package/dist/controllers/utils/index.d.mts +17 -0
- package/dist/controllers/utils/index.d.ts +17 -0
- package/dist/controllers/utils/index.js +23 -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 +636 -0
- package/dist/esm/app/jimpex.js.map +1 -0
- package/dist/esm/chunk-2B2CG5KL.js +11 -0
- package/dist/esm/chunk-2B2CG5KL.js.map +1 -0
- package/dist/esm/controllers/common/config.js +80 -0
- package/dist/esm/controllers/common/config.js.map +1 -0
- package/dist/esm/controllers/common/health.js +88 -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 +220 -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 +556 -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 +116 -0
- package/dist/esm/middlewares/common/errorHandler.js.map +1 -0
- package/dist/esm/middlewares/common/forceHTTPS.js +53 -0
- package/dist/esm/middlewares/common/forceHTTPS.js.map +1 -0
- package/dist/esm/middlewares/common/hsts.js +74 -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 +158 -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 +100 -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 +135 -0
- package/dist/esm/middlewares/utils/versionValidator.js.map +1 -0
- package/dist/esm/services/common/appError.js +98 -0
- package/dist/esm/services/common/appError.js.map +1 -0
- package/dist/esm/services/common/httpError.js +28 -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 +66 -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 +194 -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 +97 -0
- package/dist/esm/services/http/apiClient.js.map +1 -0
- package/dist/esm/services/http/http.js +174 -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 +152 -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 +94 -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-b2a04c78.d.ts +1282 -0
- package/dist/index-efeb437e.d.ts +1282 -0
- package/dist/index.d.mts +46 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/middlewares/common/errorHandler.d.mts +132 -0
- package/dist/middlewares/common/errorHandler.d.ts +132 -0
- package/dist/middlewares/common/errorHandler.js +143 -0
- package/dist/middlewares/common/errorHandler.js.map +1 -0
- package/dist/middlewares/common/forceHTTPS.d.mts +69 -0
- package/dist/middlewares/common/forceHTTPS.d.ts +69 -0
- package/dist/middlewares/common/forceHTTPS.js +80 -0
- package/dist/middlewares/common/forceHTTPS.js.map +1 -0
- package/dist/middlewares/common/hsts.d.mts +110 -0
- package/dist/middlewares/common/hsts.d.ts +110 -0
- package/dist/middlewares/common/hsts.js +101 -0
- package/dist/middlewares/common/hsts.js.map +1 -0
- package/dist/middlewares/common/index.d.mts +22 -0
- package/dist/middlewares/common/index.d.ts +22 -0
- package/dist/middlewares/common/index.js +27 -0
- package/dist/middlewares/common/index.js.map +1 -0
- package/dist/middlewares/html/fastHTML.d.mts +180 -0
- package/dist/middlewares/html/fastHTML.d.ts +180 -0
- package/dist/middlewares/html/fastHTML.js +185 -0
- package/dist/middlewares/html/fastHTML.js.map +1 -0
- package/dist/middlewares/html/index.d.mts +21 -0
- package/dist/middlewares/html/index.d.ts +21 -0
- package/dist/middlewares/html/index.js +25 -0
- package/dist/middlewares/html/index.js.map +1 -0
- package/dist/middlewares/html/showHTML.d.mts +127 -0
- package/dist/middlewares/html/showHTML.d.ts +127 -0
- package/dist/middlewares/html/showHTML.js +127 -0
- package/dist/middlewares/html/showHTML.js.map +1 -0
- package/dist/middlewares/index.d.mts +30 -0
- package/dist/middlewares/index.d.ts +30 -0
- package/dist/middlewares/index.js +27 -0
- package/dist/middlewares/index.js.map +1 -0
- package/dist/middlewares/utils/index.d.mts +20 -0
- package/dist/middlewares/utils/index.d.ts +20 -0
- package/dist/middlewares/utils/index.js +23 -0
- package/dist/middlewares/utils/index.js.map +1 -0
- package/dist/middlewares/utils/versionValidator.d.mts +215 -0
- package/dist/middlewares/utils/versionValidator.d.ts +215 -0
- package/dist/middlewares/utils/versionValidator.js +162 -0
- package/dist/middlewares/utils/versionValidator.js.map +1 -0
- package/dist/services/common/appError.d.mts +139 -0
- package/dist/services/common/appError.d.ts +139 -0
- package/dist/services/common/appError.js +126 -0
- package/dist/services/common/appError.js.map +1 -0
- package/dist/services/common/httpError.d.mts +80 -0
- package/dist/services/common/httpError.d.ts +80 -0
- package/dist/services/common/httpError.js +53 -0
- package/dist/services/common/httpError.js.map +1 -0
- package/dist/services/common/index.d.mts +47 -0
- package/dist/services/common/index.d.ts +47 -0
- package/dist/services/common/index.js +44 -0
- package/dist/services/common/index.js.map +1 -0
- package/dist/services/common/sendFile.d.mts +102 -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.mts +96 -0
- package/dist/services/frontend/frontendFs.d.ts +96 -0
- package/dist/services/frontend/frontendFs.js +103 -0
- package/dist/services/frontend/frontendFs.js.map +1 -0
- package/dist/services/frontend/index.d.mts +40 -0
- package/dist/services/frontend/index.d.ts +40 -0
- package/dist/services/frontend/index.js +36 -0
- package/dist/services/frontend/index.js.map +1 -0
- package/dist/services/html/htmlGenerator.d.mts +237 -0
- package/dist/services/html/htmlGenerator.d.ts +237 -0
- package/dist/services/html/htmlGenerator.js +221 -0
- package/dist/services/html/htmlGenerator.js.map +1 -0
- package/dist/services/html/index.d.mts +43 -0
- package/dist/services/html/index.d.ts +43 -0
- package/dist/services/html/index.js +36 -0
- package/dist/services/html/index.js.map +1 -0
- package/dist/services/http/apiClient.d.mts +170 -0
- package/dist/services/http/apiClient.d.ts +170 -0
- package/dist/services/http/apiClient.js +122 -0
- package/dist/services/http/apiClient.js.map +1 -0
- package/dist/services/http/http.d.mts +176 -0
- package/dist/services/http/http.d.ts +176 -0
- package/dist/services/http/http.js +211 -0
- package/dist/services/http/http.js.map +1 -0
- package/dist/services/http/index.d.mts +51 -0
- package/dist/services/http/index.d.ts +51 -0
- package/dist/services/http/index.js +44 -0
- package/dist/services/http/index.js.map +1 -0
- package/dist/services/http/responsesBuilder.d.mts +179 -0
- package/dist/services/http/responsesBuilder.d.ts +179 -0
- package/dist/services/http/responsesBuilder.js +179 -0
- package/dist/services/http/responsesBuilder.js.map +1 -0
- package/dist/services/index.d.mts +33 -0
- package/dist/services/index.d.ts +33 -0
- package/dist/services/index.js +31 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/utils/ensureBearerToken.d.mts +158 -0
- package/dist/services/utils/ensureBearerToken.d.ts +158 -0
- package/dist/services/utils/ensureBearerToken.js +121 -0
- package/dist/services/utils/ensureBearerToken.js.map +1 -0
- package/dist/services/utils/index.d.mts +44 -0
- package/dist/services/utils/index.d.ts +44 -0
- package/dist/services/utils/index.js +36 -0
- package/dist/services/utils/index.js.map +1 -0
- package/dist/types/events.d.mts +14 -0
- package/dist/types/events.d.ts +14 -0
- package/dist/types/events.js +17 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/express.d.mts +10 -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.mts +79 -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.mts +14 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/index.js +33 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/options.d.mts +14 -0
- package/dist/types/options.d.ts +14 -0
- package/dist/types/options.js +17 -0
- package/dist/types/options.js.map +1 -0
- package/dist/types/utils.d.mts +48 -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.mts +4 -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.mts +5 -0
- package/dist/utils/fns/index.d.ts +5 -0
- package/dist/utils/fns/index.js +29 -0
- package/dist/utils/fns/index.js.map +1 -0
- package/dist/utils/fns/others.d.mts +17 -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.mts +39 -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.mts +45 -0
- package/dist/utils/fns/statuses.d.ts +45 -0
- package/dist/utils/fns/statuses.js +39 -0
- package/dist/utils/fns/statuses.js.map +1 -0
- package/dist/utils/fns/text.d.mts +9 -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.mts +19 -0
- package/dist/utils/index.d.ts +19 -0
- package/dist/utils/index.js +25 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/wrappers.d.mts +14 -0
- package/dist/utils/wrappers.d.ts +14 -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 +60 -39
- 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,139 @@
|
|
|
1
|
+
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
+
import { J as Jimpex } from '../../index-efeb437e.js';
|
|
3
|
+
import { Statuses } from '../../utils/fns/statuses.mjs';
|
|
4
|
+
import '../../types/express.mjs';
|
|
5
|
+
import 'express';
|
|
6
|
+
import '../../types/http.mjs';
|
|
7
|
+
import 'https';
|
|
8
|
+
import 'http';
|
|
9
|
+
import 'spdy';
|
|
10
|
+
import 'node-fetch';
|
|
11
|
+
import '../../types/utils.mjs';
|
|
12
|
+
import '@homer0/path-utils';
|
|
13
|
+
import '@homer0/simple-logger';
|
|
14
|
+
import '@homer0/simple-config';
|
|
15
|
+
import '@homer0/events-hub';
|
|
16
|
+
import 'statuses';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A dictionary with some context information that can be provided to {@link AppError}.
|
|
20
|
+
*
|
|
21
|
+
* @group Services/AppError
|
|
22
|
+
*/
|
|
23
|
+
type AppErrorContext = {
|
|
24
|
+
/**
|
|
25
|
+
* Extra information that the error handler can pick and include the response.
|
|
26
|
+
*/
|
|
27
|
+
response?: unknown;
|
|
28
|
+
/**
|
|
29
|
+
* A status code or name for the error handler to set in the response.
|
|
30
|
+
*/
|
|
31
|
+
status?: string | number;
|
|
32
|
+
} & Record<string, unknown>;
|
|
33
|
+
/**
|
|
34
|
+
* A simple subclass of `Error` but with support for context information.
|
|
35
|
+
*
|
|
36
|
+
* @group Services
|
|
37
|
+
* @group Services/AppError
|
|
38
|
+
*/
|
|
39
|
+
declare class AppError extends Error {
|
|
40
|
+
/**
|
|
41
|
+
* The date of when the error was generated.
|
|
42
|
+
*/
|
|
43
|
+
readonly _date: Date;
|
|
44
|
+
/**
|
|
45
|
+
* The context information that can be provided to the error, and picked by the error
|
|
46
|
+
* handler.
|
|
47
|
+
*/
|
|
48
|
+
readonly _context: AppErrorContext;
|
|
49
|
+
/**
|
|
50
|
+
* The service that generates HTTP status codes.
|
|
51
|
+
*/
|
|
52
|
+
protected _statuses: Statuses;
|
|
53
|
+
/**
|
|
54
|
+
* @param message The message of the error.
|
|
55
|
+
* @param context The context information, for the error handler.
|
|
56
|
+
* @param statuses A reference to the service that generates HTTP status codes. This
|
|
57
|
+
* is in case the implementation wants to use a special version from
|
|
58
|
+
* the container; otherwise, it will use the `statuses` library
|
|
59
|
+
* directly.
|
|
60
|
+
*/
|
|
61
|
+
constructor(message: string, context?: AppErrorContext, statuses?: Statuses);
|
|
62
|
+
/**
|
|
63
|
+
* Gets an object that can be included in a response from the application. This method
|
|
64
|
+
* is a helper for the `response` getter, as it allows for the assertion of the response
|
|
65
|
+
* type.
|
|
66
|
+
*
|
|
67
|
+
* @template T The type of the response.
|
|
68
|
+
*/
|
|
69
|
+
getResponse<T>(): T;
|
|
70
|
+
/**
|
|
71
|
+
* Information about the error that can be included in a response. This is set using the
|
|
72
|
+
* `response` key in the `context` option.
|
|
73
|
+
*/
|
|
74
|
+
get response(): unknown;
|
|
75
|
+
/**
|
|
76
|
+
* An HTTP status code related to the error. This is set using the `status` key on the
|
|
77
|
+
* `context`.
|
|
78
|
+
*/
|
|
79
|
+
get status(): number | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Context information related to the error.
|
|
82
|
+
*/
|
|
83
|
+
get context(): unknown;
|
|
84
|
+
/**
|
|
85
|
+
* The date of when the error was generated.
|
|
86
|
+
*/
|
|
87
|
+
get date(): Date;
|
|
88
|
+
/**
|
|
89
|
+
* Utility method that formats the context before saving it in the instance:
|
|
90
|
+
* - If the context includes a `status` as a `string`, it will try to replace it with
|
|
91
|
+
* its actual status code from the `statuses `service.
|
|
92
|
+
*
|
|
93
|
+
* @param context The original context sent to the constructor.
|
|
94
|
+
*/
|
|
95
|
+
protected _parseContext(context: AppErrorContext): AppErrorContext;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Shorthand for `new AppError()`.
|
|
99
|
+
*
|
|
100
|
+
* @param args The same parameters as the {@link AppError} constructor.
|
|
101
|
+
* @returns A new instance of {@link AppError}.
|
|
102
|
+
* @group Services
|
|
103
|
+
* @group Services/AppError
|
|
104
|
+
*/
|
|
105
|
+
declare const createAppError: (message: string, context?: AppErrorContext | undefined, statuses?: Statuses | undefined) => AppError;
|
|
106
|
+
/**
|
|
107
|
+
* The type of the function that generates a new instance of {@link AppError}.
|
|
108
|
+
* This is exported to make it easy to type the dependency injection.
|
|
109
|
+
*
|
|
110
|
+
* @group Services/AppError
|
|
111
|
+
*/
|
|
112
|
+
type CreateAppErrorFn = typeof createAppError;
|
|
113
|
+
/**
|
|
114
|
+
* THe type of the {@link AppError} class.
|
|
115
|
+
* This is exported to make it easy to type the dependency injection.
|
|
116
|
+
*
|
|
117
|
+
* @group Services/AppError
|
|
118
|
+
*/
|
|
119
|
+
type AppErrorClass = typeof AppError;
|
|
120
|
+
/**
|
|
121
|
+
* A service provider that will register both, {@link AppError} and
|
|
122
|
+
* {@link createAppError}, on the container. `AppError` will be the key for class, and
|
|
123
|
+
* `appError` will be for the generator function.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
*
|
|
127
|
+
* // Register it on the container
|
|
128
|
+
* container.register(appErrorProvider);
|
|
129
|
+
* // Getting access to the class.
|
|
130
|
+
* const AppError = container.get<AppErrorClass>('AppError');
|
|
131
|
+
* // Getting access to the function.
|
|
132
|
+
* const appError = container.get<CreateAppErrorFn>('appError');
|
|
133
|
+
*
|
|
134
|
+
* @group Providers
|
|
135
|
+
* @group Services/AppError
|
|
136
|
+
*/
|
|
137
|
+
declare const appErrorProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
138
|
+
|
|
139
|
+
export { AppError, AppErrorClass, AppErrorContext, CreateAppErrorFn, appErrorProvider, createAppError };
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
+
import { J as Jimpex } from '../../index-b2a04c78.js';
|
|
3
|
+
import { Statuses } from '../../utils/fns/statuses.js';
|
|
4
|
+
import '../../types/express.js';
|
|
5
|
+
import 'express';
|
|
6
|
+
import '../../types/http.js';
|
|
7
|
+
import 'https';
|
|
8
|
+
import 'http';
|
|
9
|
+
import 'spdy';
|
|
10
|
+
import 'node-fetch';
|
|
11
|
+
import '../../types/utils.js';
|
|
12
|
+
import '@homer0/path-utils';
|
|
13
|
+
import '@homer0/simple-logger';
|
|
14
|
+
import '@homer0/simple-config';
|
|
15
|
+
import '@homer0/events-hub';
|
|
16
|
+
import 'statuses';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A dictionary with some context information that can be provided to {@link AppError}.
|
|
20
|
+
*
|
|
21
|
+
* @group Services/AppError
|
|
22
|
+
*/
|
|
23
|
+
type AppErrorContext = {
|
|
24
|
+
/**
|
|
25
|
+
* Extra information that the error handler can pick and include the response.
|
|
26
|
+
*/
|
|
27
|
+
response?: unknown;
|
|
28
|
+
/**
|
|
29
|
+
* A status code or name for the error handler to set in the response.
|
|
30
|
+
*/
|
|
31
|
+
status?: string | number;
|
|
32
|
+
} & Record<string, unknown>;
|
|
33
|
+
/**
|
|
34
|
+
* A simple subclass of `Error` but with support for context information.
|
|
35
|
+
*
|
|
36
|
+
* @group Services
|
|
37
|
+
* @group Services/AppError
|
|
38
|
+
*/
|
|
39
|
+
declare class AppError extends Error {
|
|
40
|
+
/**
|
|
41
|
+
* The date of when the error was generated.
|
|
42
|
+
*/
|
|
43
|
+
readonly _date: Date;
|
|
44
|
+
/**
|
|
45
|
+
* The context information that can be provided to the error, and picked by the error
|
|
46
|
+
* handler.
|
|
47
|
+
*/
|
|
48
|
+
readonly _context: AppErrorContext;
|
|
49
|
+
/**
|
|
50
|
+
* The service that generates HTTP status codes.
|
|
51
|
+
*/
|
|
52
|
+
protected _statuses: Statuses;
|
|
53
|
+
/**
|
|
54
|
+
* @param message The message of the error.
|
|
55
|
+
* @param context The context information, for the error handler.
|
|
56
|
+
* @param statuses A reference to the service that generates HTTP status codes. This
|
|
57
|
+
* is in case the implementation wants to use a special version from
|
|
58
|
+
* the container; otherwise, it will use the `statuses` library
|
|
59
|
+
* directly.
|
|
60
|
+
*/
|
|
61
|
+
constructor(message: string, context?: AppErrorContext, statuses?: Statuses);
|
|
62
|
+
/**
|
|
63
|
+
* Gets an object that can be included in a response from the application. This method
|
|
64
|
+
* is a helper for the `response` getter, as it allows for the assertion of the response
|
|
65
|
+
* type.
|
|
66
|
+
*
|
|
67
|
+
* @template T The type of the response.
|
|
68
|
+
*/
|
|
69
|
+
getResponse<T>(): T;
|
|
70
|
+
/**
|
|
71
|
+
* Information about the error that can be included in a response. This is set using the
|
|
72
|
+
* `response` key in the `context` option.
|
|
73
|
+
*/
|
|
74
|
+
get response(): unknown;
|
|
75
|
+
/**
|
|
76
|
+
* An HTTP status code related to the error. This is set using the `status` key on the
|
|
77
|
+
* `context`.
|
|
78
|
+
*/
|
|
79
|
+
get status(): number | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Context information related to the error.
|
|
82
|
+
*/
|
|
83
|
+
get context(): unknown;
|
|
84
|
+
/**
|
|
85
|
+
* The date of when the error was generated.
|
|
86
|
+
*/
|
|
87
|
+
get date(): Date;
|
|
88
|
+
/**
|
|
89
|
+
* Utility method that formats the context before saving it in the instance:
|
|
90
|
+
* - If the context includes a `status` as a `string`, it will try to replace it with
|
|
91
|
+
* its actual status code from the `statuses `service.
|
|
92
|
+
*
|
|
93
|
+
* @param context The original context sent to the constructor.
|
|
94
|
+
*/
|
|
95
|
+
protected _parseContext(context: AppErrorContext): AppErrorContext;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Shorthand for `new AppError()`.
|
|
99
|
+
*
|
|
100
|
+
* @param args The same parameters as the {@link AppError} constructor.
|
|
101
|
+
* @returns A new instance of {@link AppError}.
|
|
102
|
+
* @group Services
|
|
103
|
+
* @group Services/AppError
|
|
104
|
+
*/
|
|
105
|
+
declare const createAppError: (message: string, context?: AppErrorContext | undefined, statuses?: Statuses | undefined) => AppError;
|
|
106
|
+
/**
|
|
107
|
+
* The type of the function that generates a new instance of {@link AppError}.
|
|
108
|
+
* This is exported to make it easy to type the dependency injection.
|
|
109
|
+
*
|
|
110
|
+
* @group Services/AppError
|
|
111
|
+
*/
|
|
112
|
+
type CreateAppErrorFn = typeof createAppError;
|
|
113
|
+
/**
|
|
114
|
+
* THe type of the {@link AppError} class.
|
|
115
|
+
* This is exported to make it easy to type the dependency injection.
|
|
116
|
+
*
|
|
117
|
+
* @group Services/AppError
|
|
118
|
+
*/
|
|
119
|
+
type AppErrorClass = typeof AppError;
|
|
120
|
+
/**
|
|
121
|
+
* A service provider that will register both, {@link AppError} and
|
|
122
|
+
* {@link createAppError}, on the container. `AppError` will be the key for class, and
|
|
123
|
+
* `appError` will be for the generator function.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
*
|
|
127
|
+
* // Register it on the container
|
|
128
|
+
* container.register(appErrorProvider);
|
|
129
|
+
* // Getting access to the class.
|
|
130
|
+
* const AppError = container.get<AppErrorClass>('AppError');
|
|
131
|
+
* // Getting access to the function.
|
|
132
|
+
* const appError = container.get<CreateAppErrorFn>('appError');
|
|
133
|
+
*
|
|
134
|
+
* @group Providers
|
|
135
|
+
* @group Services/AppError
|
|
136
|
+
*/
|
|
137
|
+
declare const appErrorProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
138
|
+
|
|
139
|
+
export { AppError, AppErrorClass, AppErrorContext, CreateAppErrorFn, appErrorProvider, createAppError };
|
|
@@ -0,0 +1,126 @@
|
|
|
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 appError_exports = {};
|
|
25
|
+
__export(appError_exports, {
|
|
26
|
+
AppError: () => AppError,
|
|
27
|
+
appErrorProvider: () => appErrorProvider,
|
|
28
|
+
createAppError: () => createAppError
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(appError_exports);
|
|
31
|
+
var import_utils = require("../../utils");
|
|
32
|
+
class AppError extends Error {
|
|
33
|
+
/**
|
|
34
|
+
* @param message The message of the error.
|
|
35
|
+
* @param context The context information, for the error handler.
|
|
36
|
+
* @param statuses A reference to the service that generates HTTP status codes. This
|
|
37
|
+
* is in case the implementation wants to use a special version from
|
|
38
|
+
* the container; otherwise, it will use the `statuses` library
|
|
39
|
+
* directly.
|
|
40
|
+
*/
|
|
41
|
+
constructor(message, context = {}, statuses = import_utils.statuses) {
|
|
42
|
+
super(message);
|
|
43
|
+
/**
|
|
44
|
+
* The date of when the error was generated.
|
|
45
|
+
*/
|
|
46
|
+
__publicField(this, "_date");
|
|
47
|
+
/**
|
|
48
|
+
* The context information that can be provided to the error, and picked by the error
|
|
49
|
+
* handler.
|
|
50
|
+
*/
|
|
51
|
+
__publicField(this, "_context");
|
|
52
|
+
/**
|
|
53
|
+
* The service that generates HTTP status codes.
|
|
54
|
+
*/
|
|
55
|
+
__publicField(this, "_statuses");
|
|
56
|
+
this.name = this.constructor.name;
|
|
57
|
+
this._date = /* @__PURE__ */ new Date();
|
|
58
|
+
this._statuses = statuses;
|
|
59
|
+
this._context = this._parseContext(context);
|
|
60
|
+
if (Error.captureStackTrace) {
|
|
61
|
+
Error.captureStackTrace(this, this.constructor);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Gets an object that can be included in a response from the application. This method
|
|
66
|
+
* is a helper for the `response` getter, as it allows for the assertion of the response
|
|
67
|
+
* type.
|
|
68
|
+
*
|
|
69
|
+
* @template T The type of the response.
|
|
70
|
+
*/
|
|
71
|
+
getResponse() {
|
|
72
|
+
return this.response;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Information about the error that can be included in a response. This is set using the
|
|
76
|
+
* `response` key in the `context` option.
|
|
77
|
+
*/
|
|
78
|
+
get response() {
|
|
79
|
+
return this._context.response || {};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* An HTTP status code related to the error. This is set using the `status` key on the
|
|
83
|
+
* `context`.
|
|
84
|
+
*/
|
|
85
|
+
get status() {
|
|
86
|
+
return this._context.status;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Context information related to the error.
|
|
90
|
+
*/
|
|
91
|
+
get context() {
|
|
92
|
+
return this._context;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The date of when the error was generated.
|
|
96
|
+
*/
|
|
97
|
+
get date() {
|
|
98
|
+
return this._date;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Utility method that formats the context before saving it in the instance:
|
|
102
|
+
* - If the context includes a `status` as a `string`, it will try to replace it with
|
|
103
|
+
* its actual status code from the `statuses `service.
|
|
104
|
+
*
|
|
105
|
+
* @param context The original context sent to the constructor.
|
|
106
|
+
*/
|
|
107
|
+
_parseContext(context) {
|
|
108
|
+
const result = { ...context };
|
|
109
|
+
if (result.status && typeof result.status === "string") {
|
|
110
|
+
result.status = this._statuses.code[result.status.toLowerCase()] || result.status;
|
|
111
|
+
}
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const createAppError = (...args) => new AppError(...args);
|
|
116
|
+
const appErrorProvider = (0, import_utils.provider)((app) => {
|
|
117
|
+
app.set("AppError", () => AppError);
|
|
118
|
+
app.set("appError", () => createAppError);
|
|
119
|
+
});
|
|
120
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
121
|
+
0 && (module.exports = {
|
|
122
|
+
AppError,
|
|
123
|
+
appErrorProvider,
|
|
124
|
+
createAppError
|
|
125
|
+
});
|
|
126
|
+
//# sourceMappingURL=appError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/services/common/appError.ts"],"sourcesContent":["import { provider, statuses as statusesFn, type Statuses } from '../../utils';\n/**\n * A dictionary with some context information that can be provided to {@link AppError}.\n *\n * @group Services/AppError\n */\nexport type AppErrorContext = {\n /**\n * Extra information that the error handler can pick and include the response.\n */\n response?: unknown;\n /**\n * A status code or name for the error handler to set in the response.\n */\n status?: string | number;\n} & Record<string, unknown>;\n/**\n * A simple subclass of `Error` but with support for context information.\n *\n * @group Services\n * @group Services/AppError\n */\nexport class AppError extends Error {\n /**\n * The date of when the error was generated.\n */\n readonly _date: Date;\n /**\n * The context information that can be provided to the error, and picked by the error\n * handler.\n */\n readonly _context: AppErrorContext;\n /**\n * The service that generates HTTP status codes.\n */\n protected _statuses: Statuses;\n /**\n * @param message The message of the error.\n * @param context The context information, for the error handler.\n * @param statuses A reference to the service that generates HTTP status codes. This\n * is in case the implementation wants to use a special version from\n * the container; otherwise, it will use the `statuses` library\n * directly.\n */\n constructor(\n message: string,\n context: AppErrorContext = {},\n statuses: Statuses = statusesFn,\n ) {\n super(message);\n this.name = this.constructor.name;\n this._date = new Date();\n this._statuses = statuses;\n this._context = this._parseContext(context);\n\n // Limit the stack trace if possible.\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n }\n /**\n * Gets an object that can be included in a response from the application. This method\n * is a helper for the `response` getter, as it allows for the assertion of the response\n * type.\n *\n * @template T The type of the response.\n */\n getResponse<T>(): T {\n return this.response as T;\n }\n /**\n * Information about the error that can be included in a response. This is set using the\n * `response` key in the `context` option.\n */\n get response(): unknown {\n return this._context.response || {};\n }\n /**\n * An HTTP status code related to the error. This is set using the `status` key on the\n * `context`.\n */\n get status(): number | undefined {\n return this._context.status as number | undefined;\n }\n /**\n * Context information related to the error.\n */\n get context(): unknown {\n return this._context;\n }\n /**\n * The date of when the error was generated.\n */\n get date(): Date {\n return this._date;\n }\n /**\n * Utility method that formats the context before saving it in the instance:\n * - If the context includes a `status` as a `string`, it will try to replace it with\n * its actual status code from the `statuses `service.\n *\n * @param context The original context sent to the constructor.\n */\n protected _parseContext(context: AppErrorContext): AppErrorContext {\n const result = { ...context };\n if (result.status && typeof result.status === 'string') {\n result.status = this._statuses.code[result.status.toLowerCase()] || result.status;\n }\n\n return result;\n }\n}\n/**\n * Shorthand for `new AppError()`.\n *\n * @param args The same parameters as the {@link AppError} constructor.\n * @returns A new instance of {@link AppError}.\n * @group Services\n * @group Services/AppError\n */\nexport const createAppError = (\n ...args: ConstructorParameters<typeof AppError>\n): AppError => new AppError(...args);\n/**\n * The type of the function that generates a new instance of {@link AppError}.\n * This is exported to make it easy to type the dependency injection.\n *\n * @group Services/AppError\n */\nexport type CreateAppErrorFn = typeof createAppError;\n/**\n * THe type of the {@link AppError} class.\n * This is exported to make it easy to type the dependency injection.\n *\n * @group Services/AppError\n */\nexport type AppErrorClass = typeof AppError;\n/**\n * A service provider that will register both, {@link AppError} and\n * {@link createAppError}, on the container. `AppError` will be the key for class, and\n * `appError` will be for the generator function.\n *\n * @example\n *\n * // Register it on the container\n * container.register(appErrorProvider);\n * // Getting access to the class.\n * const AppError = container.get<AppErrorClass>('AppError');\n * // Getting access to the function.\n * const appError = container.get<CreateAppErrorFn>('appError');\n *\n * @group Providers\n * @group Services/AppError\n */\nexport const appErrorProvider = provider((app) => {\n app.set('AppError', () => AppError);\n app.set('appError', () => createAppError);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAgE;AAsBzD,MAAM,iBAAiB,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsBlC,YACE,SACA,UAA2B,CAAC,GAC5B,WAAqB,aAAAA,UACrB;AACA,UAAM,OAAO;AAvBf;AAAA;AAAA;AAAA,wBAAS;AAKT;AAAA;AAAA;AAAA;AAAA,wBAAS;AAIT;AAAA;AAAA;AAAA,wBAAU;AAeR,SAAK,OAAO,KAAK,YAAY;AAC7B,SAAK,QAAQ,oBAAI,KAAK;AACtB,SAAK,YAAY;AACjB,SAAK,WAAW,KAAK,cAAc,OAAO;AAG1C,QAAI,MAAM,mBAAmB;AAC3B,YAAM,kBAAkB,MAAM,KAAK,WAAW;AAAA,IAChD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,cAAoB;AAClB,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,WAAoB;AACtB,WAAO,KAAK,SAAS,YAAY,CAAC;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,SAA6B;AAC/B,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA,EAIA,IAAI,UAAmB;AACrB,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAIA,IAAI,OAAa;AACf,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQU,cAAc,SAA2C;AACjE,UAAM,SAAS,EAAE,GAAG,QAAQ;AAC5B,QAAI,OAAO,UAAU,OAAO,OAAO,WAAW,UAAU;AACtD,aAAO,SAAS,KAAK,UAAU,KAAK,OAAO,OAAO,YAAY,CAAC,KAAK,OAAO;AAAA,IAC7E;AAEA,WAAO;AAAA,EACT;AACF;AASO,MAAM,iBAAiB,IACzB,SACU,IAAI,SAAS,GAAG,IAAI;AAgC5B,MAAM,uBAAmB,uBAAS,CAAC,QAAQ;AAChD,MAAI,IAAI,YAAY,MAAM,QAAQ;AAClC,MAAI,IAAI,YAAY,MAAM,cAAc;AAC1C,CAAC;","names":["statusesFn"]}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
+
import { J as Jimpex } from '../../index-efeb437e.js';
|
|
3
|
+
import { Statuses } from '../../utils/fns/statuses.mjs';
|
|
4
|
+
import { AppError, AppErrorContext } from './appError.mjs';
|
|
5
|
+
import '../../types/express.mjs';
|
|
6
|
+
import 'express';
|
|
7
|
+
import '../../types/http.mjs';
|
|
8
|
+
import 'https';
|
|
9
|
+
import 'http';
|
|
10
|
+
import 'spdy';
|
|
11
|
+
import 'node-fetch';
|
|
12
|
+
import '../../types/utils.mjs';
|
|
13
|
+
import '@homer0/path-utils';
|
|
14
|
+
import '@homer0/simple-logger';
|
|
15
|
+
import '@homer0/simple-config';
|
|
16
|
+
import '@homer0/events-hub';
|
|
17
|
+
import 'statuses';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A type of error to be used on HTTP requests. This is the most common type of error used
|
|
21
|
+
* by Jimpex.
|
|
22
|
+
*
|
|
23
|
+
* @group Services
|
|
24
|
+
* @group Services/HTTPError
|
|
25
|
+
*/
|
|
26
|
+
declare class HTTPError extends AppError {
|
|
27
|
+
/**
|
|
28
|
+
* @param message The error message.
|
|
29
|
+
* @param status The HTTP status code.
|
|
30
|
+
* @param context Context information related to the error.
|
|
31
|
+
* @param statuses A reference to the service that generates HTTP status codes. This
|
|
32
|
+
* is in case the implementation wants to use a special version from
|
|
33
|
+
* the container; otherwise, it will use the `statuses` library
|
|
34
|
+
* directly.
|
|
35
|
+
*/
|
|
36
|
+
constructor(message: string, status?: number | string, context?: AppErrorContext, statuses?: Statuses);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Shorthand for `new HTTPError()`.
|
|
40
|
+
*
|
|
41
|
+
* @param args The same parameters as the {@link HTTPError} constructor.
|
|
42
|
+
* @returns A new instance of {@link HTTPError}.
|
|
43
|
+
* @group Services
|
|
44
|
+
* @group Services/HTTPError
|
|
45
|
+
*/
|
|
46
|
+
declare const createHTTPError: (message: string, status?: string | number | undefined, context?: AppErrorContext | undefined, statuses?: Statuses | undefined) => HTTPError;
|
|
47
|
+
/**
|
|
48
|
+
* The type of the function that generates a new instance of {@link HTTPError}.
|
|
49
|
+
* This is exported to make it easy to type the dependency injection.
|
|
50
|
+
*
|
|
51
|
+
* @group Services/HTTPError
|
|
52
|
+
*/
|
|
53
|
+
type CreateHTTPErrorFn = typeof createHTTPError;
|
|
54
|
+
/**
|
|
55
|
+
* THe type of the {@link HTTPError} class.
|
|
56
|
+
* This is exported to make it easy to type the dependency injection.
|
|
57
|
+
*
|
|
58
|
+
* @group Services/HTTPError
|
|
59
|
+
*/
|
|
60
|
+
type HTTPErrorClass = typeof HTTPError;
|
|
61
|
+
/**
|
|
62
|
+
* A service provider that will register both the {@link HTTPError} and a generator
|
|
63
|
+
* function on the container. `HTTPError` will be the key for class, and `httpError` will
|
|
64
|
+
* be for the generator function.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
*
|
|
68
|
+
* // Register it on the container
|
|
69
|
+
* container.register(httpErrorProvider);
|
|
70
|
+
* // Getting access to the class.
|
|
71
|
+
* const HTTPError = container.get<HTTPErrorClass>('HTTPError');
|
|
72
|
+
* // Getting access to the function.
|
|
73
|
+
* const httpError = container.get<CreateHTTPErrorFn>('httpError');
|
|
74
|
+
*
|
|
75
|
+
* @group Providers
|
|
76
|
+
* @group Services/HTTPError
|
|
77
|
+
*/
|
|
78
|
+
declare const httpErrorProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
79
|
+
|
|
80
|
+
export { CreateHTTPErrorFn, HTTPError, HTTPErrorClass, createHTTPError, httpErrorProvider };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
+
import { J as Jimpex } from '../../index-b2a04c78.js';
|
|
3
|
+
import { Statuses } from '../../utils/fns/statuses.js';
|
|
4
|
+
import { AppError, AppErrorContext } from './appError.js';
|
|
5
|
+
import '../../types/express.js';
|
|
6
|
+
import 'express';
|
|
7
|
+
import '../../types/http.js';
|
|
8
|
+
import 'https';
|
|
9
|
+
import 'http';
|
|
10
|
+
import 'spdy';
|
|
11
|
+
import 'node-fetch';
|
|
12
|
+
import '../../types/utils.js';
|
|
13
|
+
import '@homer0/path-utils';
|
|
14
|
+
import '@homer0/simple-logger';
|
|
15
|
+
import '@homer0/simple-config';
|
|
16
|
+
import '@homer0/events-hub';
|
|
17
|
+
import 'statuses';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A type of error to be used on HTTP requests. This is the most common type of error used
|
|
21
|
+
* by Jimpex.
|
|
22
|
+
*
|
|
23
|
+
* @group Services
|
|
24
|
+
* @group Services/HTTPError
|
|
25
|
+
*/
|
|
26
|
+
declare class HTTPError extends AppError {
|
|
27
|
+
/**
|
|
28
|
+
* @param message The error message.
|
|
29
|
+
* @param status The HTTP status code.
|
|
30
|
+
* @param context Context information related to the error.
|
|
31
|
+
* @param statuses A reference to the service that generates HTTP status codes. This
|
|
32
|
+
* is in case the implementation wants to use a special version from
|
|
33
|
+
* the container; otherwise, it will use the `statuses` library
|
|
34
|
+
* directly.
|
|
35
|
+
*/
|
|
36
|
+
constructor(message: string, status?: number | string, context?: AppErrorContext, statuses?: Statuses);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Shorthand for `new HTTPError()`.
|
|
40
|
+
*
|
|
41
|
+
* @param args The same parameters as the {@link HTTPError} constructor.
|
|
42
|
+
* @returns A new instance of {@link HTTPError}.
|
|
43
|
+
* @group Services
|
|
44
|
+
* @group Services/HTTPError
|
|
45
|
+
*/
|
|
46
|
+
declare const createHTTPError: (message: string, status?: string | number | undefined, context?: AppErrorContext | undefined, statuses?: Statuses | undefined) => HTTPError;
|
|
47
|
+
/**
|
|
48
|
+
* The type of the function that generates a new instance of {@link HTTPError}.
|
|
49
|
+
* This is exported to make it easy to type the dependency injection.
|
|
50
|
+
*
|
|
51
|
+
* @group Services/HTTPError
|
|
52
|
+
*/
|
|
53
|
+
type CreateHTTPErrorFn = typeof createHTTPError;
|
|
54
|
+
/**
|
|
55
|
+
* THe type of the {@link HTTPError} class.
|
|
56
|
+
* This is exported to make it easy to type the dependency injection.
|
|
57
|
+
*
|
|
58
|
+
* @group Services/HTTPError
|
|
59
|
+
*/
|
|
60
|
+
type HTTPErrorClass = typeof HTTPError;
|
|
61
|
+
/**
|
|
62
|
+
* A service provider that will register both the {@link HTTPError} and a generator
|
|
63
|
+
* function on the container. `HTTPError` will be the key for class, and `httpError` will
|
|
64
|
+
* be for the generator function.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
*
|
|
68
|
+
* // Register it on the container
|
|
69
|
+
* container.register(httpErrorProvider);
|
|
70
|
+
* // Getting access to the class.
|
|
71
|
+
* const HTTPError = container.get<HTTPErrorClass>('HTTPError');
|
|
72
|
+
* // Getting access to the function.
|
|
73
|
+
* const httpError = container.get<CreateHTTPErrorFn>('httpError');
|
|
74
|
+
*
|
|
75
|
+
* @group Providers
|
|
76
|
+
* @group Services/HTTPError
|
|
77
|
+
*/
|
|
78
|
+
declare const httpErrorProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
79
|
+
|
|
80
|
+
export { CreateHTTPErrorFn, HTTPError, HTTPErrorClass, createHTTPError, httpErrorProvider };
|
|
@@ -0,0 +1,53 @@
|
|
|
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var httpError_exports = {};
|
|
20
|
+
__export(httpError_exports, {
|
|
21
|
+
HTTPError: () => HTTPError,
|
|
22
|
+
createHTTPError: () => createHTTPError,
|
|
23
|
+
httpErrorProvider: () => httpErrorProvider
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(httpError_exports);
|
|
26
|
+
var import_utils = require("../../utils");
|
|
27
|
+
var import_appError = require("./appError");
|
|
28
|
+
class HTTPError extends import_appError.AppError {
|
|
29
|
+
/**
|
|
30
|
+
* @param message The error message.
|
|
31
|
+
* @param status The HTTP status code.
|
|
32
|
+
* @param context Context information related to the error.
|
|
33
|
+
* @param statuses A reference to the service that generates HTTP status codes. This
|
|
34
|
+
* is in case the implementation wants to use a special version from
|
|
35
|
+
* the container; otherwise, it will use the `statuses` library
|
|
36
|
+
* directly.
|
|
37
|
+
*/
|
|
38
|
+
constructor(message, status = (0, import_utils.statuses)("ok"), context = {}, statuses = import_utils.statuses) {
|
|
39
|
+
super(message, { ...context, status }, statuses);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const createHTTPError = (...args) => new HTTPError(...args);
|
|
43
|
+
const httpErrorProvider = (0, import_utils.provider)((app) => {
|
|
44
|
+
app.set("HTTPError", () => HTTPError);
|
|
45
|
+
app.set("httpError", () => createHTTPError);
|
|
46
|
+
});
|
|
47
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
+
0 && (module.exports = {
|
|
49
|
+
HTTPError,
|
|
50
|
+
createHTTPError,
|
|
51
|
+
httpErrorProvider
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=httpError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/services/common/httpError.ts"],"sourcesContent":["import { provider, statuses as statusesFn, type Statuses } from '../../utils';\nimport { AppError, type AppErrorContext } from './appError';\n/**\n * A type of error to be used on HTTP requests. This is the most common type of error used\n * by Jimpex.\n *\n * @group Services\n * @group Services/HTTPError\n */\nexport class HTTPError extends AppError {\n /**\n * @param message The error message.\n * @param status The HTTP status code.\n * @param context Context information related to the error.\n * @param statuses A reference to the service that generates HTTP status codes. This\n * is in case the implementation wants to use a special version from\n * the container; otherwise, it will use the `statuses` library\n * directly.\n */\n constructor(\n message: string,\n status: number | string = statusesFn('ok'),\n context: AppErrorContext = {},\n statuses: Statuses = statusesFn,\n ) {\n super(message, { ...context, status }, statuses);\n }\n}\n/**\n * Shorthand for `new HTTPError()`.\n *\n * @param args The same parameters as the {@link HTTPError} constructor.\n * @returns A new instance of {@link HTTPError}.\n * @group Services\n * @group Services/HTTPError\n */\nexport const createHTTPError = (\n ...args: ConstructorParameters<typeof HTTPError>\n): HTTPError => new HTTPError(...args);\n/**\n * The type of the function that generates a new instance of {@link HTTPError}.\n * This is exported to make it easy to type the dependency injection.\n *\n * @group Services/HTTPError\n */\nexport type CreateHTTPErrorFn = typeof createHTTPError;\n/**\n * THe type of the {@link HTTPError} class.\n * This is exported to make it easy to type the dependency injection.\n *\n * @group Services/HTTPError\n */\nexport type HTTPErrorClass = typeof HTTPError;\n/**\n * A service provider that will register both the {@link HTTPError} and a generator\n * function on the container. `HTTPError` will be the key for class, and `httpError` will\n * be for the generator function.\n *\n * @example\n *\n * // Register it on the container\n * container.register(httpErrorProvider);\n * // Getting access to the class.\n * const HTTPError = container.get<HTTPErrorClass>('HTTPError');\n * // Getting access to the function.\n * const httpError = container.get<CreateHTTPErrorFn>('httpError');\n *\n * @group Providers\n * @group Services/HTTPError\n */\nexport const httpErrorProvider = provider((app) => {\n app.set('HTTPError', () => HTTPError);\n app.set('httpError', () => createHTTPError);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAgE;AAChE,sBAA+C;AAQxC,MAAM,kBAAkB,yBAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUtC,YACE,SACA,aAA0B,aAAAA,UAAW,IAAI,GACzC,UAA2B,CAAC,GAC5B,WAAqB,aAAAA,UACrB;AACA,UAAM,SAAS,EAAE,GAAG,SAAS,OAAO,GAAG,QAAQ;AAAA,EACjD;AACF;AASO,MAAM,kBAAkB,IAC1B,SACW,IAAI,UAAU,GAAG,IAAI;AAgC9B,MAAM,wBAAoB,uBAAS,CAAC,QAAQ;AACjD,MAAI,IAAI,aAAa,MAAM,SAAS;AACpC,MAAI,IAAI,aAAa,MAAM,eAAe;AAC5C,CAAC;","names":["statusesFn"]}
|