@forinda/kickjs 10.14.0 → 10.14.2
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/dist/{adapter-DL9JPcvC.d.mts → adapter-B64IOivZ.d.mts} +13 -53
- package/dist/adapter-B64IOivZ.d.mts.map +1 -0
- package/dist/{allowed-hosts-BpKwviq5.d.mts → allowed-hosts-U12_gESr.d.mts} +2 -4
- package/dist/allowed-hosts-U12_gESr.d.mts.map +1 -0
- package/dist/{app-module-Dk2Wenqx.d.mts → app-module-EmIojM4d.d.mts} +5 -11
- package/dist/app-module-EmIojM4d.d.mts.map +1 -0
- package/dist/application-BzimU62Q.mjs +14 -0
- package/dist/application-BzimU62Q.mjs.map +1 -0
- package/dist/{application-D921r4MW.d.mts → application-CGcY8SZZ.d.mts} +22 -74
- package/dist/application-CGcY8SZZ.d.mts.map +1 -0
- package/dist/{body-policy-CaerQ_lu.mjs → body-policy-Be3Y0hjq.mjs} +2 -2
- package/dist/{body-policy-CaerQ_lu.mjs.map → body-policy-Be3Y0hjq.mjs.map} +1 -1
- package/dist/{bootstrap-BXLsEeMW.mjs → bootstrap-Bvk3BWJX.mjs} +3 -3
- package/dist/{bootstrap-BXLsEeMW.mjs.map → bootstrap-Bvk3BWJX.mjs.map} +1 -1
- package/dist/{bounded-counters-DFef_B7d.mjs → bounded-counters-Bh5jeT9I.mjs} +2 -2
- package/dist/{bounded-counters-DFef_B7d.mjs.map → bounded-counters-Bh5jeT9I.mjs.map} +1 -1
- package/dist/{breach-padding-FBVGmcBb.d.mts → breach-padding-DfT9MXGb.d.mts} +2 -4
- package/dist/breach-padding-DfT9MXGb.d.mts.map +1 -0
- package/dist/{cache-CdRHSXow.d.mts → cache-DMIt3c6M.d.mts} +1 -3
- package/dist/cache-DMIt3c6M.d.mts.map +1 -0
- package/dist/{client-ip-DE5vkJWL.mjs → client-ip-CGH_IvnC.mjs} +2 -2
- package/dist/{client-ip-DE5vkJWL.mjs.map → client-ip-CGH_IvnC.mjs.map} +1 -1
- package/dist/config/index.d.mts +1 -1
- package/dist/config/index.mjs +2 -2
- package/dist/{config-De3xzaiZ.mjs → config-CjFxvh0v.mjs} +3 -3
- package/dist/{config-De3xzaiZ.mjs.map → config-CjFxvh0v.mjs.map} +1 -1
- package/dist/{connect-BlIamapT.d.mts → connect-DamOelO8.d.mts} +1 -3
- package/dist/connect-DamOelO8.d.mts.map +1 -0
- package/dist/{context-DBLyIErA.mjs → context-BvZLaTeE.mjs} +3 -3
- package/dist/{context-DBLyIErA.mjs.map → context-BvZLaTeE.mjs.map} +1 -1
- package/dist/{context-errors-By-pwipc.mjs → context-errors-BZVS0B1O.mjs} +2 -2
- package/dist/{context-errors-By-pwipc.mjs.map → context-errors-BZVS0B1O.mjs.map} +1 -1
- package/dist/{contributor-runner-BuMi_eLU.mjs → contributor-runner-fdKy6Tme.mjs} +3 -3
- package/dist/{contributor-runner-BuMi_eLU.mjs.map → contributor-runner-fdKy6Tme.mjs.map} +1 -1
- package/dist/core/adapter.d.mts +1 -1
- package/dist/core/adapter.mjs +1 -1
- package/dist/core/app-module.d.mts +1 -1
- package/dist/core/app-module.mjs +1 -1
- package/dist/core/cache.d.mts +1 -1
- package/dist/core/cache.mjs +1 -1
- package/dist/core/cache.mjs.map +1 -1
- package/dist/core/container.mjs +2 -2
- package/dist/core/cron.d.mts +1 -1
- package/dist/core/cron.mjs +2 -2
- package/dist/core/cron.mjs.map +1 -1
- package/dist/core/decorators.d.mts +1 -1
- package/dist/core/decorators.mjs +2 -2
- package/dist/core/decorators.mjs.map +1 -1
- package/dist/core/errors.d.mts +1 -1
- package/dist/core/errors.mjs +1 -1
- package/dist/core/errors.mjs.map +1 -1
- package/dist/core/interfaces.d.mts +1 -1
- package/dist/core/interfaces.mjs +1 -1
- package/dist/core/interfaces.mjs.map +1 -1
- package/dist/core/logger.d.mts +1 -1
- package/dist/core/logger.mjs +1 -1
- package/dist/core/logger.mjs.map +1 -1
- package/dist/core/path.d.mts +1 -1
- package/dist/core/path.mjs +1 -1
- package/dist/core/path.mjs.map +1 -1
- package/dist/core/plugin.d.mts +1 -1
- package/dist/core/plugin.mjs +1 -1
- package/dist/core/reactivity.d.mts +1 -1
- package/dist/core/reactivity.mjs +2 -2
- package/dist/core/reactivity.mjs.map +1 -1
- package/dist/{core-BziwPF77.mjs → core-CCIpjo6g.mjs} +3 -3
- package/dist/{core-BziwPF77.mjs.map → core-CCIpjo6g.mjs.map} +1 -1
- package/dist/{cors-BlR_b0Qb.d.mts → cors-J-q6PuSU.d.mts} +2 -4
- package/dist/cors-J-q6PuSU.d.mts.map +1 -0
- package/dist/{cron-BTGytNg-.d.mts → cron-DGV1AE0R.d.mts} +1 -3
- package/dist/cron-DGV1AE0R.d.mts.map +1 -0
- package/dist/{csrf-DOAaYozG.d.mts → csrf-DjtJPgA3.d.mts} +4 -6
- package/dist/csrf-DjtJPgA3.d.mts.map +1 -0
- package/dist/decorate-DRbXCNQz.mjs +13 -0
- package/dist/decorate-DRbXCNQz.mjs.map +1 -0
- package/dist/{decorators-DxNb5mWw.d.mts → decorators-BAD8qjuq.d.mts} +1 -5
- package/dist/decorators-BAD8qjuq.d.mts.map +1 -0
- package/dist/{define-adapter-CbVg-Fyh.mjs → define-adapter-DMo6og81.mjs} +2 -2
- package/dist/{define-adapter-CbVg-Fyh.mjs.map → define-adapter-DMo6og81.mjs.map} +1 -1
- package/dist/{di-hooks-DN_UC8Nc.mjs → di-hooks-DCqt2yJ9.mjs} +2 -2
- package/dist/{di-hooks-DN_UC8Nc.mjs.map → di-hooks-DCqt2yJ9.mjs.map} +1 -1
- package/dist/{disposables-C4BLa-Pc.mjs → disposables-BsdVu69-.mjs} +1 -1
- package/dist/{driver-DyWsGdcD.mjs → driver-oZBQDJZz.mjs} +3 -3
- package/dist/{driver-DyWsGdcD.mjs.map → driver-oZBQDJZz.mjs.map} +1 -1
- package/dist/{error-handler-D7DLWe1Q.d.mts → error-handler-Dl_gZRNK.d.mts} +2 -4
- package/dist/error-handler-Dl_gZRNK.d.mts.map +1 -0
- package/dist/{errors-By6UueCm.d.mts → errors-DZGuPLoZ.d.mts} +1 -3
- package/dist/errors-DZGuPLoZ.d.mts.map +1 -0
- package/dist/{express-FnNSFECr.mjs → express-f9CTA8qO.mjs} +3 -3
- package/dist/{express-FnNSFECr.mjs.map → express-f9CTA8qO.mjs.map} +1 -1
- package/dist/{express-lazy-B8AFaCA-.mjs → express-lazy-DMxcLBpT.mjs} +3 -3
- package/dist/{express-lazy-B8AFaCA-.mjs.map → express-lazy-DMxcLBpT.mjs.map} +1 -1
- package/dist/{handler--lTqJdpj.mjs → handler-B66laQY0.mjs} +3 -3
- package/dist/{handler--lTqJdpj.mjs.map → handler-B66laQY0.mjs.map} +1 -1
- package/dist/{helmet-BVuVBl-D.d.mts → helmet-Rwkbp9IS.d.mts} +2 -4
- package/dist/helmet-Rwkbp9IS.d.mts.map +1 -0
- package/dist/{host-Dn2rI7s7.mjs → host-DalMsn5Z.mjs} +2 -2
- package/dist/{host-Dn2rI7s7.mjs.map → host-DalMsn5Z.mjs.map} +1 -1
- package/dist/http/application.d.mts +1 -1
- package/dist/http/application.mjs +2 -2
- package/dist/http/bootstrap.d.mts +1 -1
- package/dist/http/bootstrap.mjs +2 -2
- package/dist/http/context.d.mts +2 -2
- package/dist/http/context.mjs +2 -2
- package/dist/http/middleware/allowed-hosts.d.mts +1 -1
- package/dist/http/middleware/allowed-hosts.mjs +2 -2
- package/dist/http/middleware/allowed-hosts.mjs.map +1 -1
- package/dist/http/middleware/breach-padding.d.mts +1 -1
- package/dist/http/middleware/breach-padding.mjs +1 -1
- package/dist/http/middleware/breach-padding.mjs.map +1 -1
- package/dist/http/middleware/cors.d.mts +1 -1
- package/dist/http/middleware/cors.mjs +1 -1
- package/dist/http/middleware/cors.mjs.map +1 -1
- package/dist/http/middleware/csrf.d.mts +1 -1
- package/dist/http/middleware/csrf.mjs +2 -2
- package/dist/http/middleware/csrf.mjs.map +1 -1
- package/dist/http/middleware/error-handler.d.mts +1 -1
- package/dist/http/middleware/error-handler.mjs +2 -2
- package/dist/http/middleware/error-handler.mjs.map +1 -1
- package/dist/http/middleware/helmet.d.mts +1 -1
- package/dist/http/middleware/helmet.mjs +1 -1
- package/dist/http/middleware/helmet.mjs.map +1 -1
- package/dist/http/middleware/rate-limit.d.mts +1 -1
- package/dist/http/middleware/rate-limit.mjs +2 -2
- package/dist/http/middleware/rate-limit.mjs.map +1 -1
- package/dist/http/middleware/request-id.d.mts +1 -1
- package/dist/http/middleware/request-id.mjs +1 -1
- package/dist/http/middleware/request-id.mjs.map +1 -1
- package/dist/http/middleware/request-logger.d.mts +1 -1
- package/dist/http/middleware/request-logger.mjs +2 -2
- package/dist/http/middleware/request-logger.mjs.map +1 -1
- package/dist/http/middleware/session.d.mts +1 -1
- package/dist/http/middleware/session.mjs +2 -2
- package/dist/http/middleware/session.mjs.map +1 -1
- package/dist/http/middleware/spa.d.mts +1 -1
- package/dist/http/middleware/spa.mjs +2 -2
- package/dist/http/middleware/spa.mjs.map +1 -1
- package/dist/http/middleware/upload.d.mts +2 -2
- package/dist/http/middleware/upload.mjs +2 -2
- package/dist/http/middleware/upload.mjs.map +1 -1
- package/dist/http/middleware/validate.d.mts +1 -1
- package/dist/http/middleware/validate.mjs +1 -1
- package/dist/http/middleware/validate.mjs.map +1 -1
- package/dist/http/middleware/views.d.mts +1 -1
- package/dist/http/middleware/views.mjs +2 -2
- package/dist/http/middleware/views.mjs.map +1 -1
- package/dist/http/query/index.d.mts +1 -1
- package/dist/http/query/index.mjs +2 -2
- package/dist/http/router-builder.d.mts +1 -1
- package/dist/http/router-builder.mjs +2 -2
- package/dist/http/runtimes/express.d.mts +3 -7
- package/dist/http/runtimes/express.d.mts.map +1 -1
- package/dist/http/runtimes/express.mjs +2 -2
- package/dist/http/runtimes/fastify.d.mts +1 -3
- package/dist/http/runtimes/fastify.d.mts.map +1 -1
- package/dist/http/runtimes/fastify.mjs +2 -2
- package/dist/http/runtimes/fastify.mjs.map +1 -1
- package/dist/http/runtimes/h3-web.mjs +1 -1
- package/dist/http/runtimes/h3.d.mts +1 -3
- package/dist/http/runtimes/h3.d.mts.map +1 -1
- package/dist/http/runtimes/h3.mjs +2 -2
- package/dist/http/runtimes/h3.mjs.map +1 -1
- package/dist/{index-DP_I4puv.d.mts → index-CFTwnev9.d.mts} +3 -7
- package/dist/index-CFTwnev9.d.mts.map +1 -0
- package/dist/{index-Blgka75E.d.mts → index-ZbCnCyQx.d.mts} +1 -5
- package/dist/index-ZbCnCyQx.d.mts.map +1 -0
- package/dist/index.d.mts +30 -30
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/{interfaces-C6LHcYsg.d.mts → interfaces-BQhYh3lL.d.mts} +1 -3
- package/dist/interfaces-BQhYh3lL.d.mts.map +1 -0
- package/dist/{is-production-Cx4PGne9.mjs → is-production-9QzMIRuO.mjs} +2 -2
- package/dist/{is-production-Cx4PGne9.mjs.map → is-production-9QzMIRuO.mjs.map} +1 -1
- package/dist/{jobs-Bgtz3Hlq.mjs → jobs-CuZqVDDG.mjs} +3 -3
- package/dist/{jobs-Bgtz3Hlq.mjs.map → jobs-CuZqVDDG.mjs.map} +1 -1
- package/dist/{kv-stores-LBIBEueO.mjs → kv-stores-C9CJ3xCB.mjs} +3 -3
- package/dist/{kv-stores-LBIBEueO.mjs.map → kv-stores-C9CJ3xCB.mjs.map} +1 -1
- package/dist/{kv-stores-CwJdsMln.d.mts → kv-stores-wTD3VDPB.d.mts} +6 -18
- package/dist/kv-stores-wTD3VDPB.d.mts.map +1 -0
- package/dist/{lazy-serve-static-B9xQ0OE1.mjs → lazy-serve-static-DVWmKM7Z.mjs} +3 -3
- package/dist/{lazy-serve-static-B9xQ0OE1.mjs.map → lazy-serve-static-DVWmKM7Z.mjs.map} +1 -1
- package/dist/{logger-xE9qI_FS.d.mts → logger-BL8MiSrm.d.mts} +1 -3
- package/dist/logger-BL8MiSrm.d.mts.map +1 -0
- package/dist/{metadata-DS4TBMoC.mjs → metadata-BZRtQog3.mjs} +1 -1
- package/dist/{observers-Dokycjj0.mjs → observers-B4VnKAHK.mjs} +2 -2
- package/dist/{observers-Dokycjj0.mjs.map → observers-B4VnKAHK.mjs.map} +1 -1
- package/dist/{path-CMwIHsdv.d.mts → path-DsenzqJ7.d.mts} +1 -3
- package/dist/path-DsenzqJ7.d.mts.map +1 -0
- package/dist/{precompressed-BLYcqIAM.mjs → precompressed-AxF66Ls0.mjs} +2 -2
- package/dist/{precompressed-BLYcqIAM.mjs.map → precompressed-AxF66Ls0.mjs.map} +1 -1
- package/dist/{query-Cmtgo_-P.mjs → query-BwUR-ssX.mjs} +2 -2
- package/dist/{query-Cmtgo_-P.mjs.map → query-BwUR-ssX.mjs.map} +1 -1
- package/dist/{rate-limit-DQDk6bAH.d.mts → rate-limit-DMiV6bAq.d.mts} +3 -5
- package/dist/rate-limit-DMiV6bAq.d.mts.map +1 -0
- package/dist/{reactivity-DZrc3Yhu.d.mts → reactivity-Dski64km.d.mts} +1 -3
- package/dist/reactivity-Dski64km.d.mts.map +1 -0
- package/dist/{reply-Dcm0NAr0.mjs → reply-B5kZ6VGv.mjs} +3 -3
- package/dist/{reply-Dcm0NAr0.mjs.map → reply-B5kZ6VGv.mjs.map} +1 -1
- package/dist/{request-id-Dn64nEHK.d.mts → request-id-B_n-3A16.d.mts} +2 -4
- package/dist/request-id-B_n-3A16.d.mts.map +1 -0
- package/dist/{request-logger-TgcKRNDD.d.mts → request-logger-BV1C5r5q.d.mts} +1 -3
- package/dist/request-logger-BV1C5r5q.d.mts.map +1 -0
- package/dist/{request-scope-BmhPPGPk.mjs → request-scope-D2WQwatk.mjs} +3 -3
- package/dist/{request-scope-BmhPPGPk.mjs.map → request-scope-D2WQwatk.mjs.map} +1 -1
- package/dist/{respond-NCvYMEwC.mjs → respond-C6ohI69y.mjs} +2 -2
- package/dist/{respond-NCvYMEwC.mjs.map → respond-C6ohI69y.mjs.map} +1 -1
- package/dist/{rolldown-runtime-DKvcoND8.mjs → rolldown-runtime-DuhQYUab.mjs} +1 -1
- package/dist/{route-flag-DRM2yEZT.mjs → route-flag-CHiMvgar.mjs} +3 -3
- package/dist/{route-flag-DRM2yEZT.mjs.map → route-flag-CHiMvgar.mjs.map} +1 -1
- package/dist/{route-flag-B1lQht6v.d.mts → route-flag-CjXQl-oX.d.mts} +1 -3
- package/dist/route-flag-CjXQl-oX.d.mts.map +1 -0
- package/dist/{route-policy-T8RavXEx.mjs → route-policy-ckK7N1eN.mjs} +2 -2
- package/dist/{route-policy-T8RavXEx.mjs.map → route-policy-ckK7N1eN.mjs.map} +1 -1
- package/dist/{router-builder-iEHiFSZh.mjs → router-builder-D2cly8Wt.mjs} +3 -3
- package/dist/{router-builder-iEHiFSZh.mjs.map → router-builder-D2cly8Wt.mjs.map} +1 -1
- package/dist/{router-builder-C5EtcFSL.d.mts → router-builder-Dtyya4qP.d.mts} +3 -5
- package/dist/router-builder-Dtyya4qP.d.mts.map +1 -0
- package/dist/{runtime-D9KW2aLY.mjs → runtime-D9TN6CpL.mjs} +3 -3
- package/dist/{runtime-D9KW2aLY.mjs.map → runtime-D9TN6CpL.mjs.map} +1 -1
- package/dist/{session-DQG72vCf.d.mts → session-CXWu2rXW.d.mts} +2 -4
- package/dist/session-CXWu2rXW.d.mts.map +1 -0
- package/dist/{settings-DgZLgcNU.d.mts → settings-CB6lh6_s.d.mts} +1 -3
- package/dist/settings-CB6lh6_s.d.mts.map +1 -0
- package/dist/{settings-hG4DH8hQ.mjs → settings-v2N3V8Bl.mjs} +4 -4
- package/dist/settings-v2N3V8Bl.mjs.map +1 -0
- package/dist/{token-i5RynFrd.mjs → token-DtW16tw3.mjs} +1 -1
- package/dist/{upload-config-CTwzXhph.mjs → upload-config-BXjBiNjC.mjs} +2 -2
- package/dist/{upload-config-CTwzXhph.mjs.map → upload-config-BXjBiNjC.mjs.map} +1 -1
- package/dist/{upload-DnwvZQyi.d.mts → upload-eNNueUxR.d.mts} +4 -6
- package/dist/upload-eNNueUxR.d.mts.map +1 -0
- package/dist/{url-for-CQNJYjRH.mjs → url-for-C4Eomib7.mjs} +3 -3
- package/dist/{url-for-CQNJYjRH.mjs.map → url-for-C4Eomib7.mjs.map} +1 -1
- package/dist/{validate-D4Poe2EE.d.mts → validate-BbthfLBb.d.mts} +3 -5
- package/dist/validate-BbthfLBb.d.mts.map +1 -0
- package/dist/{view-renderer-BV2rwEUI.mjs → view-renderer-C4sMEruA.mjs} +3 -3
- package/dist/{view-renderer-BV2rwEUI.mjs.map → view-renderer-C4sMEruA.mjs.map} +1 -1
- package/dist/{web-crypto-hpIdycSO.mjs → web-crypto-SXVOPDxW.mjs} +2 -2
- package/dist/{web-crypto-hpIdycSO.mjs.map → web-crypto-SXVOPDxW.mjs.map} +1 -1
- package/dist/web.d.mts +7 -13
- package/dist/web.d.mts.map +1 -1
- package/dist/web.mjs +2 -2
- package/dist/web.mjs.map +1 -1
- package/package.json +4 -4
- package/dist/adapter-DL9JPcvC.d.mts.map +0 -1
- package/dist/allowed-hosts-BpKwviq5.d.mts.map +0 -1
- package/dist/app-module-Dk2Wenqx.d.mts.map +0 -1
- package/dist/application-CHBdxwF5.mjs +0 -14
- package/dist/application-CHBdxwF5.mjs.map +0 -1
- package/dist/application-D921r4MW.d.mts.map +0 -1
- package/dist/breach-padding-FBVGmcBb.d.mts.map +0 -1
- package/dist/cache-CdRHSXow.d.mts.map +0 -1
- package/dist/connect-BlIamapT.d.mts.map +0 -1
- package/dist/cors-BlR_b0Qb.d.mts.map +0 -1
- package/dist/cron-BTGytNg-.d.mts.map +0 -1
- package/dist/csrf-DOAaYozG.d.mts.map +0 -1
- package/dist/decorate-DgGmrJOP.mjs +0 -13
- package/dist/decorate-DgGmrJOP.mjs.map +0 -1
- package/dist/decorators-DxNb5mWw.d.mts.map +0 -1
- package/dist/error-handler-D7DLWe1Q.d.mts.map +0 -1
- package/dist/errors-By6UueCm.d.mts.map +0 -1
- package/dist/helmet-BVuVBl-D.d.mts.map +0 -1
- package/dist/index-Blgka75E.d.mts.map +0 -1
- package/dist/index-DP_I4puv.d.mts.map +0 -1
- package/dist/interfaces-C6LHcYsg.d.mts.map +0 -1
- package/dist/kv-stores-CwJdsMln.d.mts.map +0 -1
- package/dist/logger-xE9qI_FS.d.mts.map +0 -1
- package/dist/path-CMwIHsdv.d.mts.map +0 -1
- package/dist/rate-limit-DQDk6bAH.d.mts.map +0 -1
- package/dist/reactivity-DZrc3Yhu.d.mts.map +0 -1
- package/dist/request-id-Dn64nEHK.d.mts.map +0 -1
- package/dist/request-logger-TgcKRNDD.d.mts.map +0 -1
- package/dist/route-flag-B1lQht6v.d.mts.map +0 -1
- package/dist/router-builder-C5EtcFSL.d.mts.map +0 -1
- package/dist/session-DQG72vCf.d.mts.map +0 -1
- package/dist/settings-DgZLgcNU.d.mts.map +0 -1
- package/dist/settings-hG4DH8hQ.mjs.map +0 -1
- package/dist/upload-DnwvZQyi.d.mts.map +0 -1
- package/dist/validate-D4Poe2EE.d.mts.map +0 -1
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
import { a as SettingsDeclaration, c as VarOrigin, t as ConfigVar } from "./settings-
|
|
3
|
-
import "./index-
|
|
4
|
-
import { Dt as ModuleFactory, E as RequestContext, Ft as ModuleRegistry, H as RouteName, Pt as KickPlugin, Q as AdapterFactory, W as UrlForArgs, Wt as ResponseInfo, Yt as ConditionOutcome, a as KickServer, b as RuntimeCapabilities, c as ActiveRuntime, d as HttpRuntime, h as RouteEntry, m as RouteContributor, r as AppAdapter, x as RuntimeResponse } from "./adapter-
|
|
5
|
-
import { a as ConnectRequest, i as ConnectNext, n as ConnectHandler, o as ConnectResponse } from "./connect-
|
|
2
|
+
import { a as SettingsDeclaration, c as VarOrigin, t as ConfigVar } from "./settings-CB6lh6_s.mjs";
|
|
3
|
+
import "./index-CFTwnev9.mjs";
|
|
4
|
+
import { Dt as ModuleFactory, E as RequestContext, Ft as ModuleRegistry, H as RouteName, Pt as KickPlugin, Q as AdapterFactory, W as UrlForArgs, Wt as ResponseInfo, Yt as ConditionOutcome, a as KickServer, b as RuntimeCapabilities, c as ActiveRuntime, d as HttpRuntime, h as RouteEntry, m as RouteContributor, r as AppAdapter, x as RuntimeResponse } from "./adapter-B64IOivZ.mjs";
|
|
5
|
+
import { a as ConnectRequest, i as ConnectNext, n as ConnectHandler, o as ConnectResponse } from "./connect-DamOelO8.mjs";
|
|
6
6
|
import { t as Container } from "./container-4iJdDkRH.mjs";
|
|
7
|
-
import { p as RouteFlags, s as RouteFlagDeclarations } from "./route-flag-
|
|
8
|
-
import { C as MetaValue, c as ContextDecorator, h as DepValue, m as ContributorRegistrations, r as AppModuleEntry, u as ContextDecoratorSpec, x as ContextMetaKey } from "./app-module-
|
|
9
|
-
import { l as PlatformContext, m as Reply } from "./kv-stores-
|
|
10
|
-
import { t as ComputedRef } from "./reactivity-
|
|
11
|
-
import { t as ValidationErrorFactory } from "./validate-
|
|
12
|
-
import { t as AllowedHostsOptions } from "./allowed-hosts-
|
|
13
|
-
import { t as BuildRoutesOptions } from "./router-builder-
|
|
14
|
-
import "./error-handler-
|
|
15
|
-
import "./csrf-
|
|
16
|
-
import "./upload-
|
|
7
|
+
import { p as RouteFlags, s as RouteFlagDeclarations } from "./route-flag-CjXQl-oX.mjs";
|
|
8
|
+
import { C as MetaValue, c as ContextDecorator, h as DepValue, m as ContributorRegistrations, r as AppModuleEntry, u as ContextDecoratorSpec, x as ContextMetaKey } from "./app-module-EmIojM4d.mjs";
|
|
9
|
+
import { l as PlatformContext, m as Reply } from "./kv-stores-wTD3VDPB.mjs";
|
|
10
|
+
import { t as ComputedRef } from "./reactivity-Dski64km.mjs";
|
|
11
|
+
import { t as ValidationErrorFactory } from "./validate-BbthfLBb.mjs";
|
|
12
|
+
import { t as AllowedHostsOptions } from "./allowed-hosts-U12_gESr.mjs";
|
|
13
|
+
import { t as BuildRoutesOptions } from "./router-builder-Dtyya4qP.mjs";
|
|
14
|
+
import "./error-handler-Dl_gZRNK.mjs";
|
|
15
|
+
import "./csrf-DjtJPgA3.mjs";
|
|
16
|
+
import "./upload-eNNueUxR.mjs";
|
|
17
17
|
import http, { IncomingMessage, ServerResponse } from "node:http";
|
|
18
18
|
import https from "node:https";
|
|
19
19
|
import tls from "node:tls";
|
|
20
20
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
21
|
-
//#region src/core/kick-error.d.ts
|
|
22
21
|
/**
|
|
23
22
|
* Structured framework error with code, cause, and actionable fix hint.
|
|
24
23
|
*
|
|
@@ -73,8 +72,6 @@ interface FormatKickErrorOptions {
|
|
|
73
72
|
* colour — the colour flag only toggles ANSI codes.
|
|
74
73
|
*/
|
|
75
74
|
declare function formatKickError(err: KickErrorInit | KickError, options?: FormatKickErrorOptions): string;
|
|
76
|
-
//#endregion
|
|
77
|
-
//#region src/core/circuit-breaker.d.ts
|
|
78
75
|
/**
|
|
79
76
|
* Circuit Breaker pattern for external service calls.
|
|
80
77
|
*
|
|
@@ -141,8 +138,6 @@ declare class CircuitBreaker {
|
|
|
141
138
|
private onFailure;
|
|
142
139
|
private maybeTransitionToHalfOpen;
|
|
143
140
|
}
|
|
144
|
-
//#endregion
|
|
145
|
-
//#region src/core/context-errors.d.ts
|
|
146
141
|
/**
|
|
147
142
|
* Errors thrown by the Context Contributor pipeline.
|
|
148
143
|
*
|
|
@@ -248,8 +243,6 @@ declare class DuplicateContributorError extends Error {
|
|
|
248
243
|
readonly sources: readonly string[];
|
|
249
244
|
constructor(key: string, sources: readonly string[]);
|
|
250
245
|
}
|
|
251
|
-
//#endregion
|
|
252
|
-
//#region src/core/mount-sort.d.ts
|
|
253
246
|
/**
|
|
254
247
|
* Topological sort for plugins and adapters with `dependsOn` declarations.
|
|
255
248
|
*
|
|
@@ -325,8 +318,6 @@ declare class MountCycleError extends Error {
|
|
|
325
318
|
* @throws {MountCycleError} the dep graph contains a cycle
|
|
326
319
|
*/
|
|
327
320
|
declare function mountSort<T extends MountSortItem>(items: readonly T[], kind: MountKind): T[];
|
|
328
|
-
//#endregion
|
|
329
|
-
//#region src/core/asset-keys.d.ts
|
|
330
321
|
type AssetKeyStrategy = 'auto' | 'strip' | 'with-extension';
|
|
331
322
|
interface AssetKeyPair {
|
|
332
323
|
/** Source-relative path the file was discovered at. */
|
|
@@ -368,8 +359,6 @@ interface GroupAssetKeysResult {
|
|
|
368
359
|
declare function groupAssetKeys(namespace: string, paths: readonly string[], opts?: GroupAssetKeysOptions): GroupAssetKeysResult;
|
|
369
360
|
/** Strip the final extension from a path. `'mails/welcome.ejs'` → `'mails/welcome'`. */
|
|
370
361
|
declare function stripExt(path: string): string;
|
|
371
|
-
//#endregion
|
|
372
|
-
//#region src/core/route-policy.d.ts
|
|
373
362
|
declare class RoutePolicyTable {
|
|
374
363
|
/** Bucketed by method: an incoming request only scans its own verb. */
|
|
375
364
|
private readonly byMethod;
|
|
@@ -393,8 +382,6 @@ declare class RoutePolicyTable {
|
|
|
393
382
|
declare function bindRoutePolicy<T extends object>(handler: T, receive: (table: RoutePolicyTable) => void): T;
|
|
394
383
|
/** Hand the table to a middleware if it declared the slot. */
|
|
395
384
|
declare function offerRoutePolicy(handler: unknown, table: RoutePolicyTable): void;
|
|
396
|
-
//#endregion
|
|
397
|
-
//#region src/http/startup-timeline.d.ts
|
|
398
385
|
/**
|
|
399
386
|
* Where startup time goes: each phase of `setup()` / `start()`, and each
|
|
400
387
|
* adapter hook on its own, so "boot got slow" points at a name.
|
|
@@ -411,8 +398,6 @@ interface StartupTimelineSnapshot {
|
|
|
411
398
|
totalMs: number;
|
|
412
399
|
steps: readonly StartupStep[];
|
|
413
400
|
}
|
|
414
|
-
//#endregion
|
|
415
|
-
//#region src/http/startup-checks.d.ts
|
|
416
401
|
/** One finding. `error` fails startup; `warning` is logged. */
|
|
417
402
|
interface CheckMessage {
|
|
418
403
|
/** Stable ID, e.g. `'KICK-SEC-W001'` — what `silenceChecks` matches. */
|
|
@@ -447,8 +432,6 @@ declare class StartupCheckError extends Error {
|
|
|
447
432
|
readonly messages: CheckMessage[];
|
|
448
433
|
constructor(messages: CheckMessage[]);
|
|
449
434
|
}
|
|
450
|
-
//#endregion
|
|
451
|
-
//#region src/http/cache-response.d.ts
|
|
452
435
|
interface CacheResponseOptions {
|
|
453
436
|
/** Seconds a stored response is served as fresh. */
|
|
454
437
|
maxAge: number;
|
|
@@ -480,8 +463,6 @@ interface CacheResponseOptions {
|
|
|
480
463
|
key?: string | ((ctx: RequestContext) => string | null);
|
|
481
464
|
}
|
|
482
465
|
declare function CacheResponse(options: CacheResponseOptions): MethodDecorator;
|
|
483
|
-
//#endregion
|
|
484
|
-
//#region src/http/metrics.d.ts
|
|
485
466
|
interface MetricsOptions {
|
|
486
467
|
/** Where to serve the metrics. Default `/metrics`. */
|
|
487
468
|
path?: string;
|
|
@@ -522,8 +503,6 @@ declare class RequestHistogram {
|
|
|
522
503
|
* ```
|
|
523
504
|
*/
|
|
524
505
|
declare function metricsAdapter(options?: MetricsOptions): AppAdapter;
|
|
525
|
-
//#endregion
|
|
526
|
-
//#region src/http/body-policy.d.ts
|
|
527
506
|
/**
|
|
528
507
|
* Set to `true` on a request (`req[RAW_BODY] = true`) by middleware that will
|
|
529
508
|
* read the body stream itself — a tus endpoint, a proxy — so the 415 below
|
|
@@ -531,8 +510,6 @@ declare function metricsAdapter(options?: MetricsOptions): AppAdapter;
|
|
|
531
510
|
* consume it later.
|
|
532
511
|
*/
|
|
533
512
|
declare const RAW_BODY: unique symbol;
|
|
534
|
-
//#endregion
|
|
535
|
-
//#region src/http/cron-adapter.d.ts
|
|
536
513
|
/** Set by the cluster primary on the one worker that runs `KickCronAdapter` jobs. */
|
|
537
514
|
declare const CRON_WORKER_ENV = "KICK_CRON_WORKER";
|
|
538
515
|
/** A running schedule, as {@link CronScheduler} returns it. */
|
|
@@ -567,8 +544,6 @@ interface CronAdapterOptions {
|
|
|
567
544
|
schedule?: CronScheduler;
|
|
568
545
|
}
|
|
569
546
|
declare const KickCronAdapter: AdapterFactory<CronAdapterOptions, unknown>;
|
|
570
|
-
//#endregion
|
|
571
|
-
//#region src/http/tracing.d.ts
|
|
572
547
|
declare const HANDLER_CHANNEL = "kickjs:handler";
|
|
573
548
|
declare const ERROR_CHANNEL = "kickjs:error";
|
|
574
549
|
declare const RESPONSE_CHANNEL = "kickjs:response";
|
|
@@ -582,8 +557,6 @@ interface HandlerTraceContext {
|
|
|
582
557
|
requestId?: string;
|
|
583
558
|
ctx: RequestContext;
|
|
584
559
|
}
|
|
585
|
-
//#endregion
|
|
586
|
-
//#region src/http/bootstrap.d.ts
|
|
587
560
|
/**
|
|
588
561
|
* Bootstrap a KickJS application.
|
|
589
562
|
*
|
|
@@ -605,8 +578,6 @@ interface HandlerTraceContext {
|
|
|
605
578
|
* ```
|
|
606
579
|
*/
|
|
607
580
|
declare function bootstrap(options: ApplicationOptions): Promise<Application>;
|
|
608
|
-
//#endregion
|
|
609
|
-
//#region src/http/handler.d.ts
|
|
610
581
|
/** A KickJS app exposed as request handlers. See {@link createHandler}. */
|
|
611
582
|
interface KickHandler {
|
|
612
583
|
/**
|
|
@@ -670,8 +641,6 @@ interface KickHandler {
|
|
|
670
641
|
* ```
|
|
671
642
|
*/
|
|
672
643
|
declare function createHandler(options: ApplicationOptions | (() => Promise<unknown>)): KickHandler;
|
|
673
|
-
//#endregion
|
|
674
|
-
//#region src/http/cluster.d.ts
|
|
675
644
|
interface ClusterOptions {
|
|
676
645
|
/** Number of worker processes (default: os.cpus().length) */
|
|
677
646
|
workers?: number;
|
|
@@ -686,8 +655,6 @@ interface ClusterOptions {
|
|
|
686
655
|
}
|
|
687
656
|
/** Returns true if the current process is the cluster primary */
|
|
688
657
|
declare function isClusterPrimary(): boolean;
|
|
689
|
-
//#endregion
|
|
690
|
-
//#region src/http/define-http-context-decorator.d.ts
|
|
691
658
|
/**
|
|
692
659
|
* Curried form returned by {@link DefineHttpContextDecoratorFn.withParams}.
|
|
693
660
|
* Spell only the per-call params shape `P`; `K` and `D` are inferred
|
|
@@ -721,8 +688,6 @@ interface DefineHttpContextDecoratorFn {
|
|
|
721
688
|
withParams<P extends Record<string, unknown>>(): DefineHttpContextDecoratorWithParams<P>;
|
|
722
689
|
}
|
|
723
690
|
declare const defineHttpContextDecorator: DefineHttpContextDecoratorFn;
|
|
724
|
-
//#endregion
|
|
725
|
-
//#region src/core/password.d.ts
|
|
726
691
|
/** scrypt cost. Memory per hash is `128 * N * r` bytes. */
|
|
727
692
|
interface PasswordHashOptions {
|
|
728
693
|
/** CPU/memory cost, a power of two. Default `2 ** 14`. */
|
|
@@ -792,8 +757,6 @@ interface VerifyPasswordOptions extends PasswordHashOptions {
|
|
|
792
757
|
* `options.legacy` reads it.
|
|
793
758
|
*/
|
|
794
759
|
declare function verifyPassword(password: string, stored: string | null | undefined, options?: VerifyPasswordOptions): Promise<PasswordCheck>;
|
|
795
|
-
//#endregion
|
|
796
|
-
//#region src/core/signing.d.ts
|
|
797
760
|
interface SignerOptions {
|
|
798
761
|
/**
|
|
799
762
|
* The signing secret. Pass a list to rotate: the first signs, every one
|
|
@@ -828,8 +791,6 @@ interface Signer {
|
|
|
828
791
|
}
|
|
829
792
|
/** Create a signer for one purpose. */
|
|
830
793
|
declare function createSigner(options: SignerOptions): Signer;
|
|
831
|
-
//#endregion
|
|
832
|
-
//#region src/http/form.d.ts
|
|
833
794
|
/**
|
|
834
795
|
* Form state that outlives a redirect: flash messages, field errors and the
|
|
835
796
|
* values a failed submit sent, kept in the session for the next page. The
|
|
@@ -868,8 +829,6 @@ declare function oldInput(body: unknown, limits?: {
|
|
|
868
829
|
field?: number;
|
|
869
830
|
total?: number;
|
|
870
831
|
}): Record<string, string | string[]> | undefined;
|
|
871
|
-
//#endregion
|
|
872
|
-
//#region src/http/middleware/form-errors.d.ts
|
|
873
832
|
type FormErrorHandler = (err: any, req: any, res: RuntimeResponse, next: (err?: unknown) => void) => unknown;
|
|
874
833
|
interface FormErrorHandlerOptions {
|
|
875
834
|
/** Where to go back to when the `Referer` is missing or another site's. Default `'/'`. */
|
|
@@ -881,8 +840,6 @@ interface FormErrorHandlerOptions {
|
|
|
881
840
|
* to carry the errors; without it, a failed form post gets the fallback's 422.
|
|
882
841
|
*/
|
|
883
842
|
declare function formErrorHandler(fallback?: FormErrorHandler, options?: FormErrorHandlerOptions): FormErrorHandler;
|
|
884
|
-
//#endregion
|
|
885
|
-
//#region src/http/runtimes/express-lazy.d.ts
|
|
886
843
|
/** The default HTTP runtime; Express loads on the Application's first setup. */
|
|
887
844
|
declare function expressRuntime(): HttpRuntime;
|
|
888
845
|
/**
|
|
@@ -896,8 +853,6 @@ declare function materializeRouter(entries: RouteEntry[]): ConnectHandler;
|
|
|
896
853
|
* router on the first request.
|
|
897
854
|
*/
|
|
898
855
|
declare function buildRoutes(controllerClass: any, options?: BuildRoutesOptions): ConnectHandler;
|
|
899
|
-
//#endregion
|
|
900
|
-
//#region src/http/request-store.d.ts
|
|
901
856
|
/** Per-request storage for REQUEST-scoped DI and request context propagation */
|
|
902
857
|
interface RequestStore {
|
|
903
858
|
/** Unique request identifier */
|
|
@@ -966,8 +921,6 @@ declare function getRequestStore(): RequestStore;
|
|
|
966
921
|
* ```
|
|
967
922
|
*/
|
|
968
923
|
declare function getRequestValue<K extends ContextMetaKey>(key: K): MetaValue<K> | undefined;
|
|
969
|
-
//#endregion
|
|
970
|
-
//#region src/http/middleware/request-scope.d.ts
|
|
971
924
|
/**
|
|
972
925
|
* Wraps each request in an AsyncLocalStorage context.
|
|
973
926
|
* Enables REQUEST-scoped DI and automatic requestId propagation to logs.
|
|
@@ -977,8 +930,6 @@ declare function getRequestValue<K extends ContextMetaKey>(key: K): MetaValue<K>
|
|
|
977
930
|
* or the user already includes one in their middleware list.
|
|
978
931
|
*/
|
|
979
932
|
declare function requestScopeMiddleware(): (req: ConnectRequest, res: ConnectResponse, next: ConnectNext) => void;
|
|
980
|
-
//#endregion
|
|
981
|
-
//#region src/http/middleware/trace-context.d.ts
|
|
982
933
|
/**
|
|
983
934
|
* W3C Trace Context header name.
|
|
984
935
|
* @see https://www.w3.org/TR/trace-context/#traceparent-header
|
|
@@ -1031,8 +982,6 @@ declare function parseTraceparent(header: string): TraceContext | null;
|
|
|
1031
982
|
* ```
|
|
1032
983
|
*/
|
|
1033
984
|
declare function traceContext(options?: TraceContextOptions): (req: ConnectRequest, res: ConnectResponse, next: ConnectNext) => void;
|
|
1034
|
-
//#endregion
|
|
1035
|
-
//#region src/http/middleware/views.d.ts
|
|
1036
985
|
interface ViewAdapterOptions {
|
|
1037
986
|
/**
|
|
1038
987
|
* Template engine — pass the engine module or a render function.
|
|
@@ -1099,8 +1048,6 @@ declare const ViewAdapter: AdapterFactory<ViewAdapterOptions, unknown>;
|
|
|
1099
1048
|
* `copyDirs` copies it). Express tries them in order.
|
|
1100
1049
|
*/
|
|
1101
1050
|
declare function viewDirs(viewsDir: string): string[];
|
|
1102
|
-
//#endregion
|
|
1103
|
-
//#region src/http/middleware/spa.d.ts
|
|
1104
1051
|
interface SpaAdapterOptions {
|
|
1105
1052
|
/**
|
|
1106
1053
|
* Directory containing the built SPA files (index.html, assets, etc.)
|
|
@@ -1226,8 +1173,6 @@ declare function resolveClientDir(clientDir: string, cwd?: string, entry?: strin
|
|
|
1226
1173
|
* ```
|
|
1227
1174
|
*/
|
|
1228
1175
|
declare const SpaAdapter: AdapterFactory<SpaAdapterOptions, unknown>;
|
|
1229
|
-
//#endregion
|
|
1230
|
-
//#region src/http/health-module.d.ts
|
|
1231
1176
|
/** One adapter's answer to `onHealthCheck()`. */
|
|
1232
1177
|
interface HealthCheckResult {
|
|
1233
1178
|
name: string;
|
|
@@ -1307,8 +1252,6 @@ declare class HealthController {
|
|
|
1307
1252
|
* both probes — see {@link HealthModuleConfig}.
|
|
1308
1253
|
*/
|
|
1309
1254
|
declare const healthModule: ModuleFactory<HealthModuleConfig, unknown>;
|
|
1310
|
-
//#endregion
|
|
1311
|
-
//#region src/http/application.d.ts
|
|
1312
1255
|
/**
|
|
1313
1256
|
* A middleware entry in the declarative pipeline.
|
|
1314
1257
|
* Can be a bare handler or an object with path scoping.
|
|
@@ -1385,9 +1328,13 @@ interface ConfigDescription {
|
|
|
1385
1328
|
interface ConfigOrigins {
|
|
1386
1329
|
/** The app's env schema. */
|
|
1387
1330
|
env: VarOrigin[];
|
|
1388
|
-
/**
|
|
1331
|
+
/**
|
|
1332
|
+
* The settings sections the app bound, in binding order, then the ones it
|
|
1333
|
+
* declared optional and didn't bind (`optional: true`).
|
|
1334
|
+
*/
|
|
1389
1335
|
sections: Array<{
|
|
1390
1336
|
prefix: string;
|
|
1337
|
+
optional?: true;
|
|
1391
1338
|
vars: VarOrigin[];
|
|
1392
1339
|
}>;
|
|
1393
1340
|
}
|
|
@@ -1879,6 +1826,8 @@ declare class Application {
|
|
|
1879
1826
|
/** Settings prefixes bound in this setup, across its two binding phases. */
|
|
1880
1827
|
private settingsPrefixes;
|
|
1881
1828
|
private settingsProvided;
|
|
1829
|
+
/** Sections declared with `.optional()`: listed by configOrigins(), never bound. */
|
|
1830
|
+
private settingsOptional;
|
|
1882
1831
|
private handlerFor?;
|
|
1883
1832
|
private readonly adapters;
|
|
1884
1833
|
/**
|
|
@@ -2190,6 +2139,5 @@ declare class Application {
|
|
|
2190
2139
|
* how many there are under their common prefix, so `/_debug`'s dozens stay one line.
|
|
2191
2140
|
*/
|
|
2192
2141
|
declare function describeRoutes(routes: readonly MountedRouteInfo[]): string[];
|
|
2193
|
-
//#endregion
|
|
2194
2142
|
export { createSigner as $, CircuitBreaker as $t, requestScopeMiddleware as A, StartupCheckError as At, formErrorHandler as B, GroupAssetKeysResult as Bt, ViewAdapterOptions as C, RequestHistogram as Ct, TraceContextOptions as D, CheckContext as Dt, TraceContext as E, CacheResponseOptions as Et, buildRoutes as F, bindRoutePolicy as Ft, SECRET_FIELD as G, MountCycleError as Gt, FORM_ERRORS_KEY as H, stripExt as Ht, expressRuntime as I, offerRoutePolicy as It, oldInput as J, mountSort as Jt, fieldErrors as K, MountKind as Kt, materializeRouter as L, AssetKeyPair as Lt, getRequestStore as M, StartupStep as Mt, getRequestValue as N, StartupTimelineSnapshot as Nt, parseTraceparent as O, CheckMessage as Ot, requestStore as P, RoutePolicyTable as Pt, VerifyOptions as Q, MissingContributorError as Qt, FormErrorHandler as R, AssetKeyStrategy as Rt, ViewAdapter as S, MetricsOptions as St, TRACEPARENT_HEADER as T, CacheResponse as Tt, OLD_INPUT_KEY as U, DuplicateMountNameError as Ut, FLASH_KEY as V, groupAssetKeys as Vt, PREVIOUS_URL_KEY as W, MissingMountDepError as Wt, Signer as X, DuplicateContributorError as Xt, SignedCheck as Y, ContributorCycleError as Yt, SignerOptions as Z, MissingContextValueError as Zt, HealthProbe as _, CronAdapterOptions as _t, ConfigDescription as a, KickError as an, verifyPassword as at, SpaAdapterOptions as b, KickCronAdapter as bt, MiddlewareEntry as c, isClusterPrimary as ct, ShutdownOptions as d, bootstrap as dt, CircuitBreakerOptions as en, LegacyHasher as et, describeRoutes as f, ERROR_CHANNEL as ft, HealthModuleConfig as g, CRON_WORKER_ENV as gt, HealthController as h, RESPONSE_CHANNEL as ht, ApplicationOptions as i, FormatKickErrorOptions as in, hashPassword as it, RequestStore as j, defineCheck as jt, traceContext as k, StartupCheck as kt, MountedRouteInfo as l, KickHandler as lt, HealthCheckResult as m, HandlerTraceContext as mt, AppStatus as n, CircuitBreakerStats as nn, PasswordHashOptions as nt, ConfigOrigins as o, KickErrorInit as on, defineHttpContextDecorator as ot, HEALTH_PROBE as p, HANDLER_CHANNEL as pt, flash as q, MountSortItem as qt, Application as r, CircuitOpenError as rn, VerifyPasswordOptions as rt, ManagementOptions as s, formatKickError as sn, ClusterOptions as st, APPLICATION as t, CircuitBreakerState as tn, PasswordCheck as tt, ServerOptions as u, createHandler as ut, healthModule as v, CronSchedule as vt, viewDirs as w, metricsAdapter as wt, resolveClientDir as x, RAW_BODY as xt, SpaAdapter as y, CronScheduler as yt, FormErrorHandlerOptions as z, GroupAssetKeysOptions as zt };
|
|
2195
|
-
//# sourceMappingURL=application-
|
|
2143
|
+
//# sourceMappingURL=application-CGcY8SZZ.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"application-CGcY8SZZ.d.mts","names":["_$__0.AdapterFactory","Request","Response","NextFunction","Request","Response","NextFunction","_$_____0.AdapterFactory","_$_____0.AdapterFactory","_$__reply0.Reply","_$__0.ModuleFactory"],"sources":["../src/core/kick-error.ts","../src/core/circuit-breaker.ts","../src/core/context-errors.ts","../src/core/mount-sort.ts","../src/core/asset-keys.ts","../src/core/route-policy.ts","../src/http/startup-timeline.ts","../src/http/startup-checks.ts","../src/http/cache-response.ts","../src/http/metrics.ts","../src/http/body-policy.ts","../src/http/cron-adapter.ts","../src/http/tracing.ts","../src/http/bootstrap.ts","../src/http/handler.ts","../src/http/cluster.ts","../src/http/define-http-context-decorator.ts","../src/core/password.ts","../src/core/signing.ts","../src/http/form.ts","../src/http/middleware/form-errors.ts","../src/http/runtimes/express-lazy.ts","../src/http/request-store.ts","../src/http/middleware/request-scope.ts","../src/http/middleware/trace-context.ts","../src/http/middleware/views.ts","../src/http/middleware/spa.ts","../src/http/health-module.ts","../src/http/application.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAiBiB;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA,UAAU;;cAGC,kBAAkB;WACb;WACA;WACA;WACA;WACA;WACA,UAAU;EAE1B,YAAY,MAAM;;UAiDH;;;;;;EAMf;;;;;;;iBAQc,gBACd,KAAK,gBAAgB,WACrB,UAAS;;;;;;;;;;;;;;;;;;KCvFC;UAEK;;EAEf;;EAEA;;EAEA;;UAGe;EACf;EACA;EACA,OAAO;EACP,cAAc;;;;;cAMH,yBAAyB;WACR;EAA5B,YAA4B;;cAMjB;WAaO;UAZV;UACA;UACA;UACA;UACA;UACA;mBAES;mBACA;mBACA;EAEjB,YACkB,cAChB,SAAS;;;;;EAWL,QAAQ,GAAG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gB;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+BhB,MAAM,SAAS,UAAU,QAAQ;;UAiBzB;EAQR,OAAO,KAAK,KAAK,iBAAiB,KAAK,KAAK,gBAAgB,QAAQ;;;;;;;;;;;;;;;;UAmC5D;;;;;;UA2BA;;;;;;;;;;UAoDM;;;;;;UAuBN;;;;;EAgBR,sBAAsB;;;;;;;;;;EAatB,OAAO,UAAU,WAAW,MAAM,MAAM,MAAM,WAAW;;UAMjD;;;;;;;;EAkBR,kBAAkB;;;;;;;EAyClB,iBAAiB;;UAuBT;;UAeA;;UAUA;EAUF,SAAS;;EAkgBT,gBAAgB;;;;;;;;;EAYhB,sBAAsB;;;;;UAQd;UASA;;;;;;;;;;EAmCR,SAAS;UAID;;UA0FA;UA6CA;;UAWA;;UAwBN;UAeA;;EAsBF,WAAW;;;;;;;;;;;EAyDjB,SAAS,UAAS,kBAAuB;UAW3B;;;;;;;EA4Ld,iBAAiB;;;;;;;;EAWjB;IAAsB;IAAc,cAAc;;;EAKlD,iBAAiB;;EAKjB,eAAe;;;;;;EASf,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;EA2BvB,sBAAsB;EAItB,mBAAmB;IACjB;IACA;IACA;IACA;;EA+DF,iBAAiB;;;;;;EASjB,uBAAuB,KAAK,SAAS,MAAM;;;;;;;;;;;;;;UAmBnC;UAWA;UAmBA;UAUA;;;;;;;;UAeA;;UAoBA;;;;;;iBAgDM,eAAe,iBAAiB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs v10.14.
|
|
2
|
+
* @forinda/kickjs v10.14.2
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
import{HttpException}from"./core/errors.mjs";function normalizeMediaType(contentType){return((Array.isArray(contentType)?contentType[0]:contentType)??``).split(`;`)[0].trim().toLowerCase()}function isJsonMediaType(mediaType){return mediaType===`application/json`||/^application\/[\w.+-]+\+json$/.test(mediaType)}function classifyMediaType(contentType){let mediaType=normalizeMediaType(contentType);return mediaType?isJsonMediaType(mediaType)?`json`:mediaType===`application/x-www-form-urlencoded`?`urlencoded`:mediaType.startsWith(`multipart/`)?`multipart`:mediaType.startsWith(`text/`)?`text`:`unsupported`:`unsupported`}const EXPRESS_JSON_TYPES=[`application/json`,`application/*+json`],SUPPORTED_BODY_TYPES=[`application/json`,`application/*+json`,`application/x-www-form-urlencoded`,`text/*`,`multipart/form-data`];function unsupportedMediaTypeError(contentType){let mediaType=normalizeMediaType(contentType);return new HttpException(415,mediaType?`Unsupported Media Type: ${mediaType}`:`Unsupported Media Type: request has a body but no Content-Type`,void 0,{Accept:SUPPORTED_BODY_TYPES.join(`, `)})}const BODY_METHODS=/* @__PURE__ */ new Set([`POST`,`PUT`,`PATCH`,`DELETE`]),RAW_BODY=Symbol.for(`kick/http/raw-body`);function rejectUnsupportedBody(){return(req,_res,next)=>{if(!BODY_METHODS.has((req.method??`GET`).toUpperCase())||req[RAW_BODY]||classifyMediaType(req.headers?.[`content-type`])!==`unsupported`)return next();let reject=()=>next(unsupportedMediaTypeError(req.headers?.[`content-type`])),length=req.headers?.[`content-length`];if(length!==void 0)return length===`0`?next():reject();if(req.headers?.[`transfer-encoding`]===void 0)return next();let decided=!1,settle=fn=>()=>{decided||(decided=!0,req.off?.(`data`,onData),req.off?.(`end`,onEnd),fn())},onData=settle(reject),onEnd=settle(()=>next());req.on?.(`data`,onData),req.on?.(`end`,onEnd)}}const BYTE_UNITS={b:1,kb:1024,mb:1024**2,gb:1024**3};function parseByteSize(value){if(typeof value==`number`)return value;let match=/^\s*(\d+(?:\.\d+)?)\s*(b|kb|mb|gb)?\s*$/i.exec(value);if(!match)throw Error(`Invalid body size limit: '${value}'`);return Math.floor(Number(match[1])*BYTE_UNITS[(match[2]??`b`).toLowerCase()])}function tooLarge(limit){return new HttpException(413,`Request body is larger than the ${limit}-byte limit`)}async function readBodyBytes(request,limit){if(Number(request.headers.get(`content-length`))>limit)throw tooLarge(limit);if(!request.body)return/* @__PURE__ */ new Uint8Array;let reader=request.body.getReader(),chunks=[],size=0;for(;;){let{done,value}=await reader.read();if(done)break;if(size+=value.byteLength,size>limit)throw await reader.cancel().catch(()=>{}),tooLarge(limit);chunks.push(value)}let bytes=new Uint8Array(size),offset=0;for(let chunk of chunks)bytes.set(chunk,offset),offset+=chunk.byteLength;return bytes}async function readBodyText(request,limit){return new TextDecoder().decode(await readBodyBytes(request,limit))}function parseForm(raw){return formFields(new URLSearchParams(raw))}function formFields(pairs){let fields=/* @__PURE__ */ new Map;for(let[key,value]of pairs){let prev=fields.get(key);prev===void 0?fields.set(key,value):Array.isArray(prev)?prev.push(value):fields.set(key,[prev,value])}return Object.fromEntries(fields)}function hasPrototypeKey(value){let pending=[value],seen=/* @__PURE__ */ new Set;for(;pending.length>0;){let current=pending.pop();if(typeof current!=`object`||!current||seen.has(current)||ArrayBuffer.isView(current))continue;if(seen.add(current),Object.hasOwn(current,`__proto__`))return!0;let ctor=Object.hasOwn(current,`constructor`)?current.constructor:void 0;if(typeof ctor==`object`&&ctor&&Object.hasOwn(ctor,`prototype`))return!0;for(let key of Object.keys(current))pending.push(current[key])}return!1}function prototypeKeyError(){return HttpException.badRequest(`A body key that sets a prototype (__proto__, constructor.prototype) is not allowed`)}export{hasPrototypeKey as a,prototypeKeyError as c,rejectUnsupportedBody as d,tooLarge as f,formFields as i,readBodyBytes as l,RAW_BODY as n,parseByteSize as o,unsupportedMediaTypeError as p,classifyMediaType as r,parseForm as s,EXPRESS_JSON_TYPES as t,readBodyText as u};
|
|
12
|
-
//# sourceMappingURL=body-policy-
|
|
12
|
+
//# sourceMappingURL=body-policy-Be3Y0hjq.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body-policy-CaerQ_lu.mjs","names":[],"sources":["../src/http/body-policy.ts"],"sourcesContent":["/**\n * How a request body is interpreted, decided in ONE place for every runtime.\n *\n * Before this, each engine brought its own library's opinion: Express parsed\n * only exact `application/json` and silently left everything else `undefined`,\n * Fastify answered 415 for anything it had no parser for, and h3 routed\n * unrecognised types through `destr` — so the same request produced a parsed\n * object, an empty body, or a 415 depending on which engine the app was\n * configured with. The runtime is meant to be swappable; that made it not\n * swappable for any app accepting a body outside `application/json` (#590).\n *\n * @module @forinda/kickjs/http/body-policy\n */\n\nimport { HttpException } from '../core/errors'\n\n/**\n * A header as the runtimes hand it over. Node's `IncomingHttpHeaders` and\n * Fastify's normalised map both allow `string[]`, so take the union here\n * rather than casting at every call site.\n */\nexport type HeaderValue = string | string[] | undefined\n\n/** What the framework does with a body of a given media type. */\nexport type BodyKind =\n /** Parse as JSON, strictly. */\n | 'json'\n /** Parse as `application/x-www-form-urlencoded` into an object. */\n | 'urlencoded'\n /** Hand the handler the raw string. Never JSON — see `classifyMediaType`. */\n | 'text'\n /** Left to the upload path, which consumes the stream itself. */\n | 'multipart'\n /** Not parsed. `ctx.body` stays undefined. */\n | 'unsupported'\n\n/**\n * Strip parameters and normalise: `Application/JSON; charset=utf-8` →\n * `application/json`. h3's own check is `===` against the bare type, which is\n * why `application/json; charset=utf-8` — what most clients actually send —\n * missed it and fell to a non-strict branch.\n */\nexport function normalizeMediaType(contentType: HeaderValue): string {\n const value = Array.isArray(contentType) ? contentType[0] : contentType\n return (value ?? '').split(';')[0].trim().toLowerCase()\n}\n\n/**\n * `application/*+json` is JSON, and this is not a judgement call: RFC 6838\n * §4.2.8 says a media type \"MUST NOT be given names incorporating suffixes for\n * structured syntaxes they do not actually employ\", and RFC 6839 §2 exists so\n * receivers can \"do generic processing of the underlying representation\".\n * Spring, ASP.NET Core and Hono's validator all match the suffix by default.\n *\n * So `application/merge-patch+json` (RFC 7396) and `application/problem+json`\n * (RFC 9457) parse as JSON — which the framework already emits for every\n * problem response, and previously could not read back.\n */\nfunction isJsonMediaType(mediaType: string): boolean {\n return mediaType === 'application/json' || /^application\\/[\\w.+-]+\\+json$/.test(mediaType)\n}\n\n/**\n * Decide how to treat a body, from its declared media type alone.\n *\n * `text/*` deliberately yields the raw string and is NEVER JSON-parsed.\n * `text/plain` is one of three CORS-safelisted content types, so it crosses\n * origins without a preflight; JSON-parsing it would re-open the simple-request\n * CSRF that requiring `application/json` closes. h3's own source carries this\n * warning, and h3 v2 pulled back from `destr` partly because of it.\n */\nexport function classifyMediaType(contentType: HeaderValue): BodyKind {\n const mediaType = normalizeMediaType(contentType)\n if (!mediaType) return 'unsupported'\n if (isJsonMediaType(mediaType)) return 'json'\n if (mediaType === 'application/x-www-form-urlencoded') return 'urlencoded'\n if (mediaType.startsWith('multipart/')) return 'multipart'\n if (mediaType.startsWith('text/')) return 'text'\n return 'unsupported'\n}\n\n/**\n * Media types Express should hand to its JSON body parser. `express.json()`\n * defaults to the exact string `application/json`, and `type-is` will not match\n * `application/json` against a bare wildcard-plus-json pattern (a length guard rejects\n * it), so BOTH entries are required — passing only the wildcard silently stops\n * parsing ordinary JSON.\n */\nexport const EXPRESS_JSON_TYPES = ['application/json', 'application/*+json'] as const\n\n/** Media types the framework claims to parse, for diagnostics and docs. */\nexport const SUPPORTED_BODY_TYPES = [\n 'application/json',\n 'application/*+json',\n 'application/x-www-form-urlencoded',\n 'text/*',\n 'multipart/form-data',\n] as const\n\n/**\n * The 415 for a body whose media type the framework does not parse.\n *\n * Only ever raised when a body was actually SENT. An absent or empty body is\n * treated as absent regardless of its declared type — the same call Spring's\n * `readWithMessageConverters` and ASP.NET's `BodyModelBinder` both make, and\n * the reason neither rejects a bodyless POST. A bare `POST` with no payload is\n * a legitimate request, not an unsupported one.\n *\n * Carries `Accept`, which RFC 9110 §15.5.16 says a 415 \"can\" use to indicate\n * which media types would have been accepted.\n */\nexport function unsupportedMediaTypeError(contentType: HeaderValue): HttpException {\n const mediaType = normalizeMediaType(contentType)\n return new HttpException(\n 415,\n mediaType\n ? `Unsupported Media Type: ${mediaType}`\n : 'Unsupported Media Type: request has a body but no Content-Type',\n undefined,\n { Accept: SUPPORTED_BODY_TYPES.join(', ') },\n )\n}\n\n/** Verbs whose body the framework reads. */\nconst BODY_METHODS = new Set(['POST', 'PUT', 'PATCH', 'DELETE'])\n\n/**\n * Did this request actually carry a body? Decided from the framing headers\n * rather than from whether a parser produced anything — the distinction that\n * separates \"nothing was sent\" from \"something was sent that we could not\n * read\", which is the whole basis for answering 415 on one and 200 on the other.\n */\nexport function hasRequestBody(headers: Record<string, unknown>): boolean {\n const length = headers['content-length'] as string | undefined\n const encoding = headers['transfer-encoding'] as string | undefined\n return encoding !== undefined || (length !== undefined && length !== '0')\n}\n\n/**\n * Set to `true` on a request (`req[RAW_BODY] = true`) by middleware that will\n * read the body stream itself — a tus endpoint, a proxy — so the 415 below\n * leaves it alone. Mark it in an earlier phase (an adapter's `beforeGlobal`),\n * consume it later.\n */\nexport const RAW_BODY = Symbol.for('kick/http/raw-body')\n\n/**\n * Connect middleware that answers 415 for a body Express's parsers left\n * untouched.\n *\n * Express has no concept of an unsupported type: a parser whose `type` does not\n * match simply calls `next()` and leaves `req.body` undefined, indistinguishable\n * from a request that sent nothing. Mounted after the parsers, this restores the\n * distinction so Express agrees with the other runtimes.\n */\nexport function rejectUnsupportedBody() {\n return (req: any, _res: unknown, next: (err?: unknown) => void): void => {\n if (!BODY_METHODS.has((req.method ?? 'GET').toUpperCase())) return next()\n if (req[RAW_BODY]) return next()\n if (classifyMediaType(req.headers?.['content-type']) !== 'unsupported') return next()\n\n const reject = (): void => next(unsupportedMediaTypeError(req.headers?.['content-type']))\n const length = req.headers?.['content-length'] as string | undefined\n if (length !== undefined) return length === '0' ? next() : reject()\n if (req.headers?.['transfer-encoding'] === undefined) return next()\n\n // Chunked: the framing headers say a body MAY follow, but an empty chunked\n // post sends none. Deciding on the headers alone would 415 a request that\n // sent nothing, so wait to see whether a byte actually arrives — the same\n // distinction the other runtimes make by inspecting the read body.\n let decided = false\n const settle = (fn: () => void) => (): void => {\n if (decided) return\n decided = true\n req.off?.('data', onData)\n req.off?.('end', onEnd)\n fn()\n }\n const onData = settle(reject)\n const onEnd = settle(() => next())\n req.on?.('data', onData)\n req.on?.('end', onEnd)\n }\n}\n\n/** Default body size limit — Express's `express.json()` default. */\nexport const DEFAULT_BODY_LIMIT = '1mb'\n\nconst BYTE_UNITS: Record<string, number> = { b: 1, kb: 1024, mb: 1024 ** 2, gb: 1024 ** 3 }\n\n/**\n * `'1mb'` / `'512kb'` / `1048576` → bytes, the forms `express.json({ limit })`\n * accepts (1024-based, like the `bytes` package Express uses), so one\n * `jsonLimit` means the same size on every engine.\n */\nexport function parseByteSize(value: string | number): number {\n if (typeof value === 'number') return value\n const match = /^\\s*(\\d+(?:\\.\\d+)?)\\s*(b|kb|mb|gb)?\\s*$/i.exec(value)\n if (!match) throw new Error(`Invalid body size limit: '${value}'`)\n return Math.floor(Number(match[1]) * BYTE_UNITS[(match[2] ?? 'b').toLowerCase()])\n}\n\n/** The 413 for a body past `limit` bytes. */\nexport function tooLarge(limit: number): HttpException {\n return new HttpException(413, `Request body is larger than the ${limit}-byte limit`)\n}\n\n/**\n * Read a web `Request` body, refusing more than `limit` bytes with a 413 —\n * from `Content-Length` before reading, and while streaming for a body that\n * doesn't declare one (or declares less than it sends).\n */\nexport async function readBodyBytes(request: Request, limit: number): Promise<Uint8Array> {\n const declared = Number(request.headers.get('content-length'))\n if (declared > limit) throw tooLarge(limit)\n if (!request.body) return new Uint8Array(0)\n\n const reader = request.body.getReader()\n const chunks: Uint8Array[] = []\n let size = 0\n for (;;) {\n const { done, value } = await reader.read()\n if (done) break\n size += value.byteLength\n if (size > limit) {\n await reader.cancel().catch(() => {})\n throw tooLarge(limit)\n }\n chunks.push(value)\n }\n const bytes = new Uint8Array(size)\n let offset = 0\n for (const chunk of chunks) {\n bytes.set(chunk, offset)\n offset += chunk.byteLength\n }\n return bytes\n}\n\n/** {@link readBodyBytes}, decoded as UTF-8. */\nexport async function readBodyText(request: Request, limit: number): Promise<string> {\n return new TextDecoder().decode(await readBodyBytes(request, limit))\n}\n\n/**\n * `application/x-www-form-urlencoded` → object, with a repeated key becoming\n * an array — the same rule the query string follows on every engine, and\n * what Express's form parser does.\n */\nexport function parseForm(raw: string): Record<string, string | string[]> {\n return formFields(new URLSearchParams(raw))\n}\n\n/**\n * Form fields → object, a repeated name becoming an array — urlencoded bodies\n * and multipart fields alike. A Map, then fromEntries: assigning keys onto a\n * plain object would let a `__proto__` field set the result's prototype, or\n * vanish; this way it is an own key, which {@link hasPrototypeKey} refuses.\n */\nexport function formFields(\n pairs: Iterable<readonly [string, string]>,\n): Record<string, string | string[]> {\n const fields = new Map<string, string | string[]>()\n for (const [key, value] of pairs) {\n const prev = fields.get(key)\n if (prev === undefined) fields.set(key, value)\n else if (Array.isArray(prev)) prev.push(value)\n else fields.set(key, [prev, value])\n }\n return Object.fromEntries(fields)\n}\n\n/**\n * Whether parsed input carries a key that can rewrite a prototype: `__proto__`\n * anywhere, or `constructor.prototype`. A body with one is refused on every\n * engine, as Fastify's parsers already do. Harmless while it sits in the body,\n * it turns `Object.assign(target, ctx.body)` or a naive deep merge into\n * prototype pollution.\n */\nexport function hasPrototypeKey(value: unknown): boolean {\n const pending: unknown[] = [value]\n const seen = new Set<object>()\n while (pending.length > 0) {\n const current = pending.pop()\n if (current === null || typeof current !== 'object' || seen.has(current)) continue\n // Bytes (a raw body) have no keys worth walking.\n if (ArrayBuffer.isView(current)) continue\n seen.add(current)\n if (Object.hasOwn(current, '__proto__')) return true\n const ctor: unknown = Object.hasOwn(current, 'constructor')\n ? (current as { constructor: unknown }).constructor\n : undefined\n if (ctor !== null && typeof ctor === 'object' && Object.hasOwn(ctor, 'prototype')) return true\n for (const key of Object.keys(current)) pending.push((current as Record<string, unknown>)[key])\n }\n return false\n}\n\n/** The 400 for a body {@link hasPrototypeKey} refuses. */\nexport function prototypeKeyError(): HttpException {\n return HttpException.badRequest(\n 'A body key that sets a prototype (__proto__, constructor.prototype) is not allow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"sources":["../src/http/body-policy.ts"],"sourcesContent":["/**\n * How a request body is interpreted, decided in ONE place for every runtime.\n *\n * Before this, each engine brought its own library's opinion: Express parsed\n * only exact `application/json` and silently left everything else `undefined`,\n * Fastify answered 415 for anything it had no parser for, and h3 routed\n * unrecognised types through `destr` — so the same request produced a parsed\n * object, an empty body, or a 415 depending on which engine the app was\n * configured with. The runtime is meant to be swappable; that made it not\n * swappable for any app accepting a body outside `application/json` (#590).\n *\n * @module @forinda/kickjs/http/body-policy\n */\n\nimport { HttpException } from '../core/errors'\n\n/**\n * A header as the runtimes hand it over. Node's `IncomingHttpHeaders` and\n * Fastify's normalised map both allow `string[]`, so take the union here\n * rather than casting at every call site.\n */\nexport type HeaderValue = string | string[] | undefined\n\n/** What the framework does with a body of a given media type. */\nexport type BodyKind =\n /** Parse as JSON, strictly. */\n | 'json'\n /** Parse as `application/x-www-form-urlencoded` into an object. */\n | 'urlencoded'\n /** Hand the handler the raw string. Never JSON — see `classifyMediaType`. */\n | 'text'\n /** Left to the upload path, which consumes the stream itself. */\n | 'multipart'\n /** Not parsed. `ctx.body` stays undefined. */\n | 'unsupported'\n\n/**\n * Strip parameters and normalise: `Application/JSON; charset=utf-8` →\n * `application/json`. h3's own check is `===` against the bare type, which is\n * why `application/json; charset=utf-8` — what most clients actually send —\n * missed it and fell to a non-strict branch.\n */\nexport function normalizeMediaType(contentType: HeaderValue): string {\n const value = Array.isArray(contentType) ? contentType[0] : contentType\n return (value ?? '').split(';')[0].trim().toLowerCase()\n}\n\n/**\n * `application/*+json` is JSON, and this is not a judgement call: RFC 6838\n * §4.2.8 says a media type \"MUST NOT be given names incorporating suffixes for\n * structured syntaxes they do not actually employ\", and RFC 6839 §2 exists so\n * receivers can \"do generic processing of the underlying representation\".\n * Spring, ASP.NET Core and Hono's validator all match the suffix by default.\n *\n * So `application/merge-patch+json` (RFC 7396) and `application/problem+json`\n * (RFC 9457) parse as JSON — which the framework already emits for every\n * problem response, and previously could not read back.\n */\nfunction isJsonMediaType(mediaType: string): boolean {\n return mediaType === 'application/json' || /^application\\/[\\w.+-]+\\+json$/.test(mediaType)\n}\n\n/**\n * Decide how to treat a body, from its declared media type alone.\n *\n * `text/*` deliberately yields the raw string and is NEVER JSON-parsed.\n * `text/plain` is one of three CORS-safelisted content types, so it crosses\n * origins without a preflight; JSON-parsing it would re-open the simple-request\n * CSRF that requiring `application/json` closes. h3's own source carries this\n * warning, and h3 v2 pulled back from `destr` partly because of it.\n */\nexport function classifyMediaType(contentType: HeaderValue): BodyKind {\n const mediaType = normalizeMediaType(contentType)\n if (!mediaType) return 'unsupported'\n if (isJsonMediaType(mediaType)) return 'json'\n if (mediaType === 'application/x-www-form-urlencoded') return 'urlencoded'\n if (mediaType.startsWith('multipart/')) return 'multipart'\n if (mediaType.startsWith('text/')) return 'text'\n return 'unsupported'\n}\n\n/**\n * Media types Express should hand to its JSON body parser. `express.json()`\n * defaults to the exact string `application/json`, and `type-is` will not match\n * `application/json` against a bare wildcard-plus-json pattern (a length guard rejects\n * it), so BOTH entries are required — passing only the wildcard silently stops\n * parsing ordinary JSON.\n */\nexport const EXPRESS_JSON_TYPES = ['application/json', 'application/*+json'] as const\n\n/** Media types the framework claims to parse, for diagnostics and docs. */\nexport const SUPPORTED_BODY_TYPES = [\n 'application/json',\n 'application/*+json',\n 'application/x-www-form-urlencoded',\n 'text/*',\n 'multipart/form-data',\n] as const\n\n/**\n * The 415 for a body whose media type the framework does not parse.\n *\n * Only ever raised when a body was actually SENT. An absent or empty body is\n * treated as absent regardless of its declared type — the same call Spring's\n * `readWithMessageConverters` and ASP.NET's `BodyModelBinder` both make, and\n * the reason neither rejects a bodyless POST. A bare `POST` with no payload is\n * a legitimate request, not an unsupported one.\n *\n * Carries `Accept`, which RFC 9110 §15.5.16 says a 415 \"can\" use to indicate\n * which media types would have been accepted.\n */\nexport function unsupportedMediaTypeError(contentType: HeaderValue): HttpException {\n const mediaType = normalizeMediaType(contentType)\n return new HttpException(\n 415,\n mediaType\n ? `Unsupported Media Type: ${mediaType}`\n : 'Unsupported Media Type: request has a body but no Content-Type',\n undefined,\n { Accept: SUPPORTED_BODY_TYPES.join(', ') },\n )\n}\n\n/** Verbs whose body the framework reads. */\nconst BODY_METHODS = new Set(['POST', 'PUT', 'PATCH', 'DELETE'])\n\n/**\n * Did this request actually carry a body? Decided from the framing headers\n * rather than from whether a parser produced anything — the distinction that\n * separates \"nothing was sent\" from \"something was sent that we could not\n * read\", which is the whole basis for answering 415 on one and 200 on the other.\n */\nexport function hasRequestBody(headers: Record<string, unknown>): boolean {\n const length = headers['content-length'] as string | undefined\n const encoding = headers['transfer-encoding'] as string | undefined\n return encoding !== undefined || (length !== undefined && length !== '0')\n}\n\n/**\n * Set to `true` on a request (`req[RAW_BODY] = true`) by middleware that will\n * read the body stream itself — a tus endpoint, a proxy — so the 415 below\n * leaves it alone. Mark it in an earlier phase (an adapter's `beforeGlobal`),\n * consume it later.\n */\nexport const RAW_BODY = Symbol.for('kick/http/raw-body')\n\n/**\n * Connect middleware that answers 415 for a body Express's parsers left\n * untouched.\n *\n * Express has no concept of an unsupported type: a parser whose `type` does not\n * match simply calls `next()` and leaves `req.body` undefined, indistinguishable\n * from a request that sent nothing. Mounted after the parsers, this restores the\n * distinction so Express agrees with the other runtimes.\n */\nexport function rejectUnsupportedBody() {\n return (req: any, _res: unknown, next: (err?: unknown) => void): void => {\n if (!BODY_METHODS.has((req.method ?? 'GET').toUpperCase())) return next()\n if (req[RAW_BODY]) return next()\n if (classifyMediaType(req.headers?.['content-type']) !== 'unsupported') return next()\n\n const reject = (): void => next(unsupportedMediaTypeError(req.headers?.['content-type']))\n const length = req.headers?.['content-length'] as string | undefined\n if (length !== undefined) return length === '0' ? next() : reject()\n if (req.headers?.['transfer-encoding'] === undefined) return next()\n\n // Chunked: the framing headers say a body MAY follow, but an empty chunked\n // post sends none. Deciding on the headers alone would 415 a request that\n // sent nothing, so wait to see whether a byte actually arrives — the same\n // distinction the other runtimes make by inspecting the read body.\n let decided = false\n const settle = (fn: () => void) => (): void => {\n if (decided) return\n decided = true\n req.off?.('data', onData)\n req.off?.('end', onEnd)\n fn()\n }\n const onData = settle(reject)\n const onEnd = settle(() => next())\n req.on?.('data', onData)\n req.on?.('end', onEnd)\n }\n}\n\n/** Default body size limit — Express's `express.json()` default. */\nexport const DEFAULT_BODY_LIMIT = '1mb'\n\nconst BYTE_UNITS: Record<string, number> = { b: 1, kb: 1024, mb: 1024 ** 2, gb: 1024 ** 3 }\n\n/**\n * `'1mb'` / `'512kb'` / `1048576` → bytes, the forms `express.json({ limit })`\n * accepts (1024-based, like the `bytes` package Express uses), so one\n * `jsonLimit` means the same size on every engine.\n */\nexport function parseByteSize(value: string | number): number {\n if (typeof value === 'number') return value\n const match = /^\\s*(\\d+(?:\\.\\d+)?)\\s*(b|kb|mb|gb)?\\s*$/i.exec(value)\n if (!match) throw new Error(`Invalid body size limit: '${value}'`)\n return Math.floor(Number(match[1]) * BYTE_UNITS[(match[2] ?? 'b').toLowerCase()])\n}\n\n/** The 413 for a body past `limit` bytes. */\nexport function tooLarge(limit: number): HttpException {\n return new HttpException(413, `Request body is larger than the ${limit}-byte limit`)\n}\n\n/**\n * Read a web `Request` body, refusing more than `limit` bytes with a 413 —\n * from `Content-Length` before reading, and while streaming for a body that\n * doesn't declare one (or declares less than it sends).\n */\nexport async function readBodyBytes(request: Request, limit: number): Promise<Uint8Array> {\n const declared = Number(request.headers.get('content-length'))\n if (declared > limit) throw tooLarge(limit)\n if (!request.body) return new Uint8Array(0)\n\n const reader = request.body.getReader()\n const chunks: Uint8Array[] = []\n let size = 0\n for (;;) {\n const { done, value } = await reader.read()\n if (done) break\n size += value.byteLength\n if (size > limit) {\n await reader.cancel().catch(() => {})\n throw tooLarge(limit)\n }\n chunks.push(value)\n }\n const bytes = new Uint8Array(size)\n let offset = 0\n for (const chunk of chunks) {\n bytes.set(chunk, offset)\n offset += chunk.byteLength\n }\n return bytes\n}\n\n/** {@link readBodyBytes}, decoded as UTF-8. */\nexport async function readBodyText(request: Request, limit: number): Promise<string> {\n return new TextDecoder().decode(await readBodyBytes(request, limit))\n}\n\n/**\n * `application/x-www-form-urlencoded` → object, with a repeated key becoming\n * an array — the same rule the query string follows on every engine, and\n * what Express's form parser does.\n */\nexport function parseForm(raw: string): Record<string, string | string[]> {\n return formFields(new URLSearchParams(raw))\n}\n\n/**\n * Form fields → object, a repeated name becoming an array — urlencoded bodies\n * and multipart fields alike. A Map, then fromEntries: assigning keys onto a\n * plain object would let a `__proto__` field set the result's prototype, or\n * vanish; this way it is an own key, which {@link hasPrototypeKey} refuses.\n */\nexport function formFields(\n pairs: Iterable<readonly [string, string]>,\n): Record<string, string | string[]> {\n const fields = new Map<string, string | string[]>()\n for (const [key, value] of pairs) {\n const prev = fields.get(key)\n if (prev === undefined) fields.set(key, value)\n else if (Array.isArray(prev)) prev.push(value)\n else fields.set(key, [prev, value])\n }\n return Object.fromEntries(fields)\n}\n\n/**\n * Whether parsed input carries a key that can rewrite a prototype: `__proto__`\n * anywhere, or `constructor.prototype`. A body with one is refused on every\n * engine, as Fastify's parsers already do. Harmless while it sits in the body,\n * it turns `Object.assign(target, ctx.body)` or a naive deep merge into\n * prototype pollution.\n */\nexport function hasPrototypeKey(value: unknown): boolean {\n const pending: unknown[] = [value]\n const seen = new Set<object>()\n while (pending.length > 0) {\n const current = pending.pop()\n if (current === null || typeof current !== 'object' || seen.has(current)) continue\n // Bytes (a raw body) have no keys worth walking.\n if (ArrayBuffer.isView(current)) continue\n seen.add(current)\n if (Object.hasOwn(current, '__proto__')) return true\n const ctor: unknown = Object.hasOwn(current, 'constructor')\n ? (current as { constructor: unknown }).constructor\n : undefined\n if (ctor !== null && typeof ctor === 'object' && Object.hasOwn(ctor, 'prototype')) return true\n for (const key of Object.keys(current)) pending.push((current as Record<string, unknown>)[key])\n }\n return false\n}\n\n/** The 400 for a body {@link hasPrototypeKey} refuses. */\nexport function prototypeKeyError(): HttpException {\n return HttpException.badRequest(\n 'A body key that sets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@@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs v10.14.
|
|
2
|
+
* @forinda/kickjs v10.14.2
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{
|
|
12
|
-
//# sourceMappingURL=bootstrap-
|
|
11
|
+
import{r as reportError}from"./observers-B4VnKAHK.mjs";import{Container}from"./core/container.mjs";import"./core-CCIpjo6g.mjs";import{c as reloadEnv}from"./decorate-DRbXCNQz.mjs";import{n as Application}from"./application-BzimU62Q.mjs";import{t as defineAdapter}from"./define-adapter-DMo6og81.mjs";import{createLogger}from"./core/logger.mjs";import{listCronJobs,runCronJob}from"./core/cron.mjs";import{reactive,ref}from"./core/reactivity.mjs";import{c as settleBackgroundWork,o as forwardBackgroundWork}from"./view-renderer-C4sMEruA.mjs";import{createRequire}from"node:module";import cluster from"node:cluster";import os from"node:os";const log$2=createLogger(`KickCronAdapter`),peerRequire=createRequire(import.meta.url),CRON_WORKER_ENV=`KICK_CRON_WORKER`;function croner(){try{let Croner=peerRequire(`croner`).Cron;return(expression,{timezone},tick)=>new Croner(expression,timezone?{timezone}:{},tick)}catch{return}}function isCronProcess(){return!cluster.isWorker||process.env.KICK_CRON_WORKER===`1`}const KickCronAdapter=defineAdapter({name:`KickCronAdapter`,defaults:{enabled:!0},build(options){let schedules=[],inFlight=/* @__PURE__ */ new Set,jobs=[];return{afterStart({container}){if(options.enabled===!1||!isCronProcess()||(jobs=listCronJobs(container),jobs.length===0))return;let schedule=options.schedule??croner();if(!schedule){log$2.warn(`${jobs.length} @Cron job(s) found but "croner" is not installed, so none will run. Install it (pnpm add croner), or pass KickCronAdapter({ schedule }).`);return}let run=(job,trigger)=>{let p=runCronJob(job,container,trigger).catch(()=>{});inFlight.add(p),p.finally(()=>inFlight.delete(p))};for(let job of jobs)schedules.push(schedule(job.expression,job.timezone?{timezone:job.timezone}:{},()=>run(job,`schedule`))),job.runOnInit&&run(job,`init`);log$2.info(`Scheduled ${jobs.length} @Cron job(s): ${jobs.map(j=>j.name).join(`, `)}`)},async shutdown(){for(let schedule of schedules.splice(0))schedule.stop();await Promise.all(inFlight)},introspect(){return{protocolVersion:1,name:`KickCronAdapter`,kind:`adapter`,state:{jobs:jobs.map(j=>({name:j.name,expression:j.expression,timezone:j.timezone,description:j.description}))}}}}}}),log$1=createLogger(`Cluster`);function isClusterPrimary(){return cluster.isPrimary}function setupClusterPrimary(opts){let numWorkers=opts.workers??os.cpus().length,gracefulTimeout=opts.gracefulShutdownTimeout??5e3,restartDelay=opts.restartDelay??1e3,maxFailures=opts.maxFailures??5,restartWindow=opts.restartWindow??3e4,startupTimeouts=/* @__PURE__ */ new Map,state=reactive({failureTimestamps:[],shuttingDown:!1}),activeWorkers=ref(0);log$1.info(`Primary ${process.pid} starting ${numWorkers} worker(s)`);let cronWorkerId,forkWorker=()=>{let takesCron=cronWorkerId===void 0,worker=cluster.fork(takesCron?{[CRON_WORKER_ENV]:`1`}:void 0);takesCron&&(cronWorkerId=worker.id)};for(let i=0;i<numWorkers;i++)forkWorker();cluster.on(`fork`,worker=>{let timeout=setTimeout(()=>{log$1.error(`Worker ${worker.process.pid} did not respond within 10s, killing...`),worker.kill()},1e4);startupTimeouts.set(worker.id,timeout),activeWorkers.value++,log$1.debug(`Worker ${worker.process.pid} forked (id=${worker.id})`)}),cluster.on(`listening`,(worker,address)=>{let timeout=startupTimeouts.get(worker.id);timeout&&(clearTimeout(timeout),startupTimeouts.delete(worker.id)),log$1.info(`Worker ${worker.process.pid} listening on ${address.address}:${address.port}`)}),cluster.on(`online`,worker=>{log$1.debug(`Worker ${worker.process.pid} online (id=${worker.id})`)}),cluster.on(`exit`,(worker,code,signal)=>{let timeout=startupTimeouts.get(worker.id);if(timeout&&(clearTimeout(timeout),startupTimeouts.delete(worker.id)),activeWorkers.value--,worker.id===cronWorkerId&&(cronWorkerId=void 0),worker.exitedAfterDisconnect){log$1.info(`Worker ${worker.process.pid} exited gracefully (id=${worker.id})`);return}let now=Date.now();for(;state.failureTimestamps.length>0&&now-state.failureTimestamps[0]>=restartWindow;)state.failureTimestamps.shift();state.failureTimestamps.push(now),state.failureTimestamps.length>maxFailures?(log$1.error(`${state.failureTimestamps.length} worker failures in ${restartWindow}ms, giving up`),activeWorkers.value===0&&(log$1.error(`All workers have crashed, exiting primary`),process.exit(1))):(log$1.warn(`Worker ${worker.process.pid} died (code=${code}, signal=${signal}), restarting in ${restartDelay}ms... (failures: ${state.failureTimestamps.length}/${maxFailures})`),setTimeout(()=>{activeWorkers.value<numWorkers&&forkWorker()},restartDelay))}),cluster.on(`disconnect`,worker=>{log$1.debug(`Worker ${worker.process.pid} disconnected (id=${worker.id})`)});for(let signal of[`SIGTERM`,`SIGINT`])process.on(signal,()=>{state.shuttingDown||(state.shuttingDown=!0,log$1.info(`Primary received ${signal}, disconnecting workers...`),cluster.disconnect(()=>{log$1.info(`All workers disconnected, exiting primary`),process.exit(0)}),setTimeout(()=>{log$1.warn(`Graceful shutdown timed out, forcing exit`),process.exit(1)},gracefulTimeout).unref())})}const ENTRY_CAPTURE=Symbol.for(`kickjs.handler.entryCapture`);function captureEntry(load){let pending;return()=>pending??=(async()=>{let captured,g=globalThis,capture=(first,options)=>{captured??={first,options}};g[ENTRY_CAPTURE]=capture;try{await load()}finally{g[ENTRY_CAPTURE]===capture&&delete g[ENTRY_CAPTURE]}if(!captured)throw Error(`createHandler(): the entry finished loading without calling bootstrap(). Pass the module that calls it — createHandler(() => import('./index')) — or pass the options.`);return captured})().catch(err=>{throw pending=void 0,err})}function createHandler(options){let app,entry=typeof options==`function`?captureEntry(options):async()=>({first:void 0,options}),firstUsed=!1,ready=()=>(app??=(async()=>{let loaded;try{loaded=await entry()}catch(err){throw app=void 0,err}let instance=loaded.first&&!firstUsed?loaded.first:new Application(loaded.options);firstUsed=!0;try{await instance.startWithoutServer()}catch(err){throw app=void 0,await instance.shutdown().catch(()=>{}),err}return instance})(),app);return{ready,async fetch(request,platform){let response=await(await ready()).fetch(request);return forwardBackgroundWork(platform),response},async node(req,res,platform){if((await ready()).handle(req,res),platform?.waitUntil){let sent=new Promise(resolve=>res.once(`close`,()=>resolve()));platform.waitUntil(sent.then(settleBackgroundWork))}},async close(){let current=app;app=void 0,current&&await(await current).shutdown()}}}function tryReloadEnv(){try{reloadEnv()}catch{}}const log=createLogger(`Process`);async function bootstrap(options){let capture=globalThis[ENTRY_CAPTURE];if(typeof capture==`function`){let app=new Application(options);return capture(app,options),app}let isViteDev=!!globalThis.__kickjs_httpServer;if(options.cluster&&isViteDev&&log.warn(`Cluster mode is ignored in dev — Vite owns the server. Cluster applies in production (kick start).`),options.cluster&&cluster.isPrimary&&!isViteDev)return setupClusterPrimary(typeof options.cluster==`object`?options.cluster:{}),new Application(options);let g=globalThis,processHooks=options.processHooks??`auto`;if(!g.__kickBootstrapped){if(processHooks!==`manual`&&(process.on(`uncaughtException`,err=>{log.error(err,`Uncaught exception`),reportError(err,{source:`uncaught`}),process.exitCode=1}),process.on(`unhandledRejection`,reason=>{log.error(reason,`Unhandled rejection`),reportError(reason,{source:`unhandled-rejection`}),process.exitCode=1})),processHooks===`auto`&&!g.__kickjs_httpServer)for(let signal of[`SIGINT`,`SIGTERM`])process.on(signal,async()=>{log.info(`Received ${signal}, shutting down...`),g.__app&&await g.__app.shutdown(),process.exit(0)});g.__kickBootstrapped=!0}let run=(g.__kickBoot??Promise.resolve()).then(()=>boot(options,g));return g.__kickBoot=run.catch(()=>{}),run}async function boot(options,g){if(g.__app){log.debug(`HMR rebuild triggered`);try{await g.__app.shutdown({closeServer:!1})}catch(err){log.error(err,`HMR teardown of the previous app failed`)}tryReloadEnv(),Container.reset();let freshApp=new Application(options);return g.__app=freshApp,g.__kickjs_container=freshApp.getContainer(),await freshApp.start(),log.debug(`HMR rebuild complete`),freshApp}let app=new Application(options);return g.__app=app,g.__kickjs_container=app.getContainer(),process.env.KICK_TINKER?(await app.registerOnly(),app):(await app.start(),app)}export{KickCronAdapter as a,CRON_WORKER_ENV as i,createHandler as n,isClusterPrimary as r,bootstrap as t};
|
|
12
|
+
//# sourceMappingURL=bootstrap-Bvk3BWJX.mjs.map
|