@forinda/kickjs 10.8.0 → 10.10.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/dist/{adapter-B0Q8PzQ3.d.mts → adapter-DLjn8q0c.d.mts} +2 -2
- package/dist/{adapter-B0Q8PzQ3.d.mts.map → adapter-DLjn8q0c.d.mts.map} +1 -1
- package/dist/{application-BND5VDje.d.mts → application-CdUI5E_3.d.mts} +43 -9
- package/dist/application-CdUI5E_3.d.mts.map +1 -0
- package/dist/{application-CWPS2sst.mjs → application-DLRHEOeg.mjs} +4 -4
- package/dist/{application-CWPS2sst.mjs.map → application-DLRHEOeg.mjs.map} +1 -1
- package/dist/{background-D8VpVDrH.mjs → background-CiKEgaD2.mjs} +3 -3
- package/dist/{background-D8VpVDrH.mjs.map → background-CiKEgaD2.mjs.map} +1 -1
- package/dist/{body-policy-DAoHt4Cr.mjs → body-policy-DIgqprai.mjs} +2 -2
- package/dist/{body-policy-DAoHt4Cr.mjs.map → body-policy-DIgqprai.mjs.map} +1 -1
- package/dist/bootstrap-6ltjueRe.mjs +12 -0
- package/dist/bootstrap-6ltjueRe.mjs.map +1 -0
- package/dist/{bounded-counters-BMHzTpuZ.mjs → bounded-counters-Dxi2jekd.mjs} +2 -2
- package/dist/{bounded-counters-BMHzTpuZ.mjs.map → bounded-counters-Dxi2jekd.mjs.map} +1 -1
- package/dist/{client-ip-COnqHbaF.mjs → client-ip-dLKJKDZL.mjs} +2 -2
- package/dist/{client-ip-COnqHbaF.mjs.map → client-ip-dLKJKDZL.mjs.map} +1 -1
- package/dist/config/index.mjs +2 -2
- package/dist/{config-Cq6_Qr4r.mjs → config-BEoFtveu.mjs} +3 -3
- package/dist/{config-Cq6_Qr4r.mjs.map → config-BEoFtveu.mjs.map} +1 -1
- package/dist/{context-CX0TLa4H.mjs → context-BPszif4a.mjs} +3 -3
- package/dist/{context-CX0TLa4H.mjs.map → context-BPszif4a.mjs.map} +1 -1
- package/dist/{context-errors-Chi6ESHh.mjs → context-errors-B2uJdmkX.mjs} +2 -2
- package/dist/{context-errors-Chi6ESHh.mjs.map → context-errors-B2uJdmkX.mjs.map} +1 -1
- package/dist/{contributor-runner-Da7v9Whk.mjs → contributor-runner-CaZkoZOK.mjs} +3 -3
- package/dist/{contributor-runner-Da7v9Whk.mjs.map → contributor-runner-CaZkoZOK.mjs.map} +1 -1
- package/dist/core/adapter.d.mts +1 -1
- package/dist/core/adapter.mjs +1 -1
- package/dist/core/app-module.mjs +1 -1
- package/dist/core/cache.mjs +1 -1
- package/dist/core/container.mjs +2 -2
- package/dist/core/cron.mjs +2 -2
- package/dist/core/decorators.mjs +2 -2
- package/dist/core/errors.mjs +1 -1
- package/dist/core/interfaces.mjs +1 -1
- package/dist/core/logger.mjs +1 -1
- package/dist/core/path.mjs +1 -1
- package/dist/core/plugin.d.mts +1 -1
- package/dist/core/plugin.mjs +1 -1
- package/dist/core/reactivity.mjs +2 -2
- package/dist/{core-CiwDroJ7.mjs → core-MyOlkejk.mjs} +3 -3
- package/dist/{core-CiwDroJ7.mjs.map → core-MyOlkejk.mjs.map} +1 -1
- package/dist/{decorate-DdzHOAA1.mjs → decorate-CU19-7Fw.mjs} +3 -3
- package/dist/{decorate-DdzHOAA1.mjs.map → decorate-CU19-7Fw.mjs.map} +1 -1
- package/dist/{define-adapter-DJnPaqbo.mjs → define-adapter-1FfgX1AQ.mjs} +2 -2
- package/dist/{define-adapter-DJnPaqbo.mjs.map → define-adapter-1FfgX1AQ.mjs.map} +1 -1
- package/dist/{di-hooks-rXw3zCor.mjs → di-hooks-DX9rJX_0.mjs} +6 -4
- package/dist/{di-hooks-rXw3zCor.mjs.map → di-hooks-DX9rJX_0.mjs.map} +1 -1
- package/dist/{disposables-Cpde_0BE.mjs → disposables-Bq6gIO7N.mjs} +1 -1
- package/dist/{error-handler-C1I8a4wY.d.mts → error-handler-BrihKETE.d.mts} +2 -2
- package/dist/{error-handler-C1I8a4wY.d.mts.map → error-handler-BrihKETE.d.mts.map} +1 -1
- package/dist/{express-fiMFHEPO.mjs → express-BBhisCna.mjs} +3 -3
- package/dist/{express-fiMFHEPO.mjs.map → express-BBhisCna.mjs.map} +1 -1
- package/dist/{express-lazy-DxQzDeza.mjs → express-lazy-Pua2eR0n.mjs} +3 -3
- package/dist/{express-lazy-DxQzDeza.mjs.map → express-lazy-Pua2eR0n.mjs.map} +1 -1
- package/dist/{handler-D5QS_90y.mjs → handler-C_mWEafU.mjs} +3 -3
- package/dist/{handler-D5QS_90y.mjs.map → handler-C_mWEafU.mjs.map} +1 -1
- package/dist/{host-D7vw6t1i.mjs → host-d9X0p13s.mjs} +2 -2
- package/dist/{host-D7vw6t1i.mjs.map → host-d9X0p13s.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 +1 -1
- package/dist/http/context.mjs +2 -2
- package/dist/http/middleware/allowed-hosts.mjs +2 -2
- package/dist/http/middleware/breach-padding.mjs +1 -1
- package/dist/http/middleware/cors.mjs +1 -1
- package/dist/http/middleware/csrf.mjs +2 -2
- package/dist/http/middleware/error-handler.d.mts +1 -1
- package/dist/http/middleware/error-handler.mjs +2 -2
- package/dist/http/middleware/helmet.mjs +1 -1
- package/dist/http/middleware/rate-limit.mjs +2 -2
- package/dist/http/middleware/request-id.mjs +1 -1
- package/dist/http/middleware/request-logger.mjs +2 -2
- package/dist/http/middleware/session.mjs +2 -2
- package/dist/http/middleware/spa.d.mts +1 -1
- package/dist/http/middleware/spa.mjs +2 -2
- package/dist/http/middleware/upload.d.mts +2 -2
- package/dist/http/middleware/upload.mjs +2 -2
- package/dist/http/middleware/validate.mjs +1 -1
- package/dist/http/middleware/views.d.mts +1 -1
- package/dist/http/middleware/views.mjs +2 -2
- 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 +2 -2
- package/dist/http/runtimes/express.mjs +2 -2
- package/dist/http/runtimes/fastify.d.mts +1 -1
- package/dist/http/runtimes/fastify.d.mts.map +1 -1
- package/dist/http/runtimes/fastify.mjs +3 -3
- 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 -1
- 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.d.mts +7 -7
- package/dist/index.mjs +2 -2
- package/dist/{is-production-C7DJ7c5k.mjs → is-production-BYwEumHI.mjs} +2 -2
- package/dist/{is-production-C7DJ7c5k.mjs.map → is-production-BYwEumHI.mjs.map} +1 -1
- package/dist/{jobs-Bdqz5n21.mjs → jobs-bGtYcSgo.mjs} +3 -3
- package/dist/{jobs-Bdqz5n21.mjs.map → jobs-bGtYcSgo.mjs.map} +1 -1
- package/dist/{kv-stores-CISRYh_H.d.mts → kv-stores-DJBnGQsJ.d.mts} +2 -2
- package/dist/{kv-stores-CISRYh_H.d.mts.map → kv-stores-DJBnGQsJ.d.mts.map} +1 -1
- package/dist/{kv-stores-BM5Fcds2.mjs → kv-stores-DbM-V83V.mjs} +3 -3
- package/dist/{kv-stores-BM5Fcds2.mjs.map → kv-stores-DbM-V83V.mjs.map} +1 -1
- package/dist/{lazy-serve-static-D2pf9ODr.mjs → lazy-serve-static-Dp3lqSlT.mjs} +3 -3
- package/dist/{lazy-serve-static-D2pf9ODr.mjs.map → lazy-serve-static-Dp3lqSlT.mjs.map} +1 -1
- package/dist/{metadata-Ck5f9CNm.mjs → metadata-BvNkZphr.mjs} +1 -1
- package/dist/{observers-BV435fEL.mjs → observers-Bjs-1F1Z.mjs} +2 -2
- package/dist/{observers-BV435fEL.mjs.map → observers-Bjs-1F1Z.mjs.map} +1 -1
- package/dist/{precompressed-DPESwDxf.mjs → precompressed-Cydk_Bpr.mjs} +2 -2
- package/dist/{precompressed-DPESwDxf.mjs.map → precompressed-Cydk_Bpr.mjs.map} +1 -1
- package/dist/{query-Bs9mU4bx.mjs → query-BEnIVY7Q.mjs} +2 -2
- package/dist/{query-Bs9mU4bx.mjs.map → query-BEnIVY7Q.mjs.map} +1 -1
- package/dist/{reply-BmNC0SFg.mjs → reply-CGn9BmYj.mjs} +2 -2
- package/dist/{reply-BmNC0SFg.mjs.map → reply-CGn9BmYj.mjs.map} +1 -1
- package/dist/{request-scope-DFf8XH5R.mjs → request-scope-u_VhYe4-.mjs} +3 -3
- package/dist/{request-scope-DFf8XH5R.mjs.map → request-scope-u_VhYe4-.mjs.map} +1 -1
- package/dist/{respond-DbgwV87J.mjs → respond-C0NoT3br.mjs} +2 -2
- package/dist/{respond-DbgwV87J.mjs.map → respond-C0NoT3br.mjs.map} +1 -1
- package/dist/{rolldown-runtime-BIVYCGx6.mjs → rolldown-runtime-D2dh8WuU.mjs} +1 -1
- package/dist/{route-flag-Dm1NxMbJ.mjs → route-flag-xPz2wbyz.mjs} +3 -3
- package/dist/{route-flag-Dm1NxMbJ.mjs.map → route-flag-xPz2wbyz.mjs.map} +1 -1
- package/dist/{route-policy-CdBgPlft.mjs → route-policy-weZwvZYs.mjs} +2 -2
- package/dist/{route-policy-CdBgPlft.mjs.map → route-policy-weZwvZYs.mjs.map} +1 -1
- package/dist/{router-builder-CwPowg4s.d.mts → router-builder-CPJHwoL1.d.mts} +2 -2
- package/dist/{router-builder-CwPowg4s.d.mts.map → router-builder-CPJHwoL1.d.mts.map} +1 -1
- package/dist/{router-builder-BM9t-xGP.mjs → router-builder-CnCNsI87.mjs} +3 -3
- package/dist/{router-builder-BM9t-xGP.mjs.map → router-builder-CnCNsI87.mjs.map} +1 -1
- package/dist/{settings-CPQhWD12.mjs → settings-Ciut2k76.mjs} +3 -3
- package/dist/{settings-CPQhWD12.mjs.map → settings-Ciut2k76.mjs.map} +1 -1
- package/dist/{token-tL_r-ZPP.mjs → token-CBe6OMQK.mjs} +1 -1
- package/dist/{upload-DDDboa_F.d.mts → upload-DtQ1pdQw.d.mts} +2 -2
- package/dist/{upload-DDDboa_F.d.mts.map → upload-DtQ1pdQw.d.mts.map} +1 -1
- package/dist/{upload-config-DCm8AFEW.mjs → upload-config-d_LW2u9b.mjs} +2 -2
- package/dist/{upload-config-DCm8AFEW.mjs.map → upload-config-d_LW2u9b.mjs.map} +1 -1
- package/dist/{url-for-DAVOWiQ_.mjs → url-for-Df_ts-iM.mjs} +3 -3
- package/dist/{url-for-DAVOWiQ_.mjs.map → url-for-Df_ts-iM.mjs.map} +1 -1
- package/dist/{web-crypto-BMaKs6M0.mjs → web-crypto-BNF60ZAh.mjs} +2 -2
- package/dist/{web-crypto-BMaKs6M0.mjs.map → web-crypto-BNF60ZAh.mjs.map} +1 -1
- package/dist/web.d.mts +2 -2
- package/dist/web.mjs +2 -2
- package/package.json +10 -10
- package/dist/application-BND5VDje.d.mts.map +0 -1
- package/dist/bootstrap-BpRQ1_KV.mjs +0 -12
- package/dist/bootstrap-BpRQ1_KV.mjs.map +0 -1
package/dist/web.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
import { i as SettingsDeclaration } from "./settings-BFQisfqG.mjs";
|
|
3
3
|
import { x as MiddlewareHandler } from "./decorators-DxNb5mWw.mjs";
|
|
4
|
-
import { O as SseHandler, h as RouteEntry, x as RuntimeResponse } from "./adapter-
|
|
4
|
+
import { O as SseHandler, h as RouteEntry, x as RuntimeResponse } from "./adapter-DLjn8q0c.mjs";
|
|
5
5
|
import { m as ContributorRegistrations, r as AppModuleEntry } from "./app-module-Bk3glnPP.mjs";
|
|
6
6
|
import { f as runCronJobs, o as CronRun } from "./cron-BTGytNg-.mjs";
|
|
7
|
-
import { E as JobContextCarrier, F as registerJobContext, I as runJob, L as stampJobContext, S as JOB_CONTEXT_FIELD, a as KvSessionStoreOptions, c as matchesBearer, d as waitUntil, f as InferHandlerResponse, g as ReplyOptions, h as ReplyHeaders, i as KvSessionStore, k as JobLike, l as PlatformContext, m as Reply, n as KvRateLimitStore, o as RateLimitGuardOptions, r as KvRateLimitStoreOptions, s as rateLimitGuard, t as KvLike, x as reply, y as isReply } from "./kv-stores-
|
|
7
|
+
import { E as JobContextCarrier, F as registerJobContext, I as runJob, L as stampJobContext, S as JOB_CONTEXT_FIELD, a as KvSessionStoreOptions, c as matchesBearer, d as waitUntil, f as InferHandlerResponse, g as ReplyOptions, h as ReplyHeaders, i as KvSessionStore, k as JobLike, l as PlatformContext, m as Reply, n as KvRateLimitStore, o as RateLimitGuardOptions, r as KvRateLimitStoreOptions, s as rateLimitGuard, t as KvLike, x as reply, y as isReply } from "./kv-stores-DJBnGQsJ.mjs";
|
|
8
8
|
import { t as ValidationErrorFactory } from "./validate-D4Poe2EE.mjs";
|
|
9
9
|
//#region src/http/web/driver.d.ts
|
|
10
10
|
/**
|
package/dist/web.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs v10.
|
|
2
|
+
* @forinda/kickjs v10.10.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{Container}from"./core/container.mjs";import{a as moduleName,n as RouteUrls,r as MutableModuleRegistry,t as ROUTE_URLS}from"./url-for-
|
|
11
|
+
import{Container}from"./core/container.mjs";import{a as moduleName,n as RouteUrls,r as MutableModuleRegistry,t as ROUTE_URLS}from"./url-for-Df_ts-iM.mjs";import{runCronJobs}from"./core/cron.mjs";import{d as stampJobContext,l as registerJobContext,t as JOB_CONTEXT_FIELD,u as runJob}from"./jobs-bGtYcSgo.mjs";import{buildMountPath}from"./core/path.mjs";import{n as assertRouteUnique,r as buildRouteTable,t as _setExternalContributorSources}from"./router-builder-CnCNsI87.mjs";import{t as matchesBearer}from"./web-crypto-BNF60ZAh.mjs";import{o as parseByteSize}from"./body-policy-DIgqprai.mjs";import{i as waitUntil,s as requestStore,t as forwardBackgroundWork}from"./background-CiKEgaD2.mjs";import{notFoundHandler}from"./http/middleware/error-handler.mjs";import{i as loadSettings}from"./settings-Ciut2k76.mjs";import{a as reply,r as isReply}from"./reply-CGn9BmYj.mjs";import{n as KvSessionStore,r as rateLimitGuard,t as KvRateLimitStore}from"./kv-stores-DbM-V83V.mjs";import{i as WebResponseDriver,r as WebRequestShim,t as compileWebRoute}from"./handler-C_mWEafU.mjs";function createWebApp(options){let h3mod=options.h3;if(typeof h3mod?.H3!=`function`)throw Error(`@forinda/kickjs/web: pass the h3 v2 module — \`createWebApp({ h3: await import("h3"), ... })\`. The installed h3 must be v2 (npm dist-tag 'latest'); v1 has no H3 class.`);let container=Container.getInstance(),routeUrls=new RouteUrls;if(container.registerInstance(ROUTE_URLS,routeUrls),options.env){let env=options.env;Container.setEnvResolver(key=>env[key])}Container.setRequestStoreProvider(()=>requestStore.getStore()??null);let registry=new MutableModuleRegistry;for(let m of options.modules)registry.mount(m);let modules=registry.entries.map(entry=>typeof entry==`function`?new entry:entry),settingsEnv=options.env??(typeof process<`u`?process.env:{});for(let[section,value]of loadSettings([...options.settings??[],...modules.flatMap(mod=>mod.settings?.()??[])],settingsEnv))container.registerInstance(section,value);for(let mod of modules)mod.register?.(container);container.bootstrap();let app=new h3mod.H3,apiPrefix=options.apiPrefix??`/api`,defaultVersion=options.defaultVersion??1,globalMiddleware=options.middlewares??[],bodyLimit=parseByteSize(options.jsonLimit??`1mb`),globalSources=(options.contributors??[]).map(registration=>({source:`global`,registration,label:`createWebApp`})),seenRoutes=/* @__PURE__ */ new Map,mounted=[];for(let mod of modules){let moduleLabel=moduleName(mod),moduleSources=(mod.contributors?.()??[]).map(registration=>({source:`module`,registration,label:moduleLabel}));_setExternalContributorSources([...moduleSources,...globalSources]);try{let result=mod.routes();if(!result)continue;let routeSets=Array.isArray(result)?result:[result];for(let route of routeSets){if(!route.controller)throw Error(`@forinda/kickjs/web: module route at '${route.path}' has no controller. Express-style \`router\` mounts are not supported on the web entry.`);let version=route.version??defaultVersion,mountPath=buildMountPath(apiPrefix,version,route.path);for(let entry of buildRouteTable(route.controller,{mountFlags:route.flags})){let url=joinPath(mountPath,entry.path),owner=`${route.controller.name??`controller`}.${String(entry.meta.handlerName??`?`)}`;assertRouteUnique(seenRoutes,entry.method,url,owner),mounted.push({method:entry.method,path:url}),globalMiddleware.length>0&&(entry.middlewares=[...globalMiddleware,...entry.middlewares]),entry.validationError=options.validationError,entry.urls=routeUrls,routeUrls.add(owner,url);let run=compileWebRoute(entry,void 0,{bodyLimit});app.on(entry.method,url,event=>run({request:event.req,url:event.url,params:event.context.params??{}}))}}}finally{_setExternalContributorSources([])}}let notFound=notFoundHandler(mounted);return app.all(`/**`,event=>{let driver=new WebResponseDriver(event.req.signal);return notFound(new WebRequestShim(event.req,event.url),driver,()=>{}),driver.ready}),{fetch:async(request,platform)=>{let response=await app.fetch(request);return forwardBackgroundWork(platform),response},h3:app}}function createFetchHandler(build){let app;return{fetch:(request,env={},ctx)=>(app??=createWebApp(build(env)),app.fetch(request,ctx)),scheduled:async(event,env={},ctx)=>{app??=createWebApp(build(env));let run=runCronJobs(Container.getInstance(),{expression:event.cron},`workers`).then(()=>{});ctx?.waitUntil?.(run),await run},queue:async(batch,env={})=>{app??=createWebApp(build(env));let container=Container.getInstance();await Promise.all(batch.messages.map(async message=>{let body=message.body,named=typeof body==`object`&&!!body&&typeof body.name==`string`;try{await runJob(container,batch.queue,{name:named?body.name:``,data:named?body.data:message.body,id:message.id}),message.ack()}catch{message.retry()}}))}}}function joinPath(mountPath,path){let a=mountPath.endsWith(`/`)?mountPath.slice(0,-1):mountPath;return path===`/`||path===``?a===``?`/`:a:`${a}${path.startsWith(`/`)?path:`/${path}`}`}export{JOB_CONTEXT_FIELD,KvRateLimitStore,KvSessionStore,WebRequestShim,WebResponseDriver,compileWebRoute,createFetchHandler,createWebApp,isReply,matchesBearer,rateLimitGuard,registerJobContext,reply,runCronJobs,runJob,stampJobContext,waitUntil};
|
|
12
12
|
//# sourceMappingURL=web.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forinda/kickjs",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.10.0",
|
|
4
4
|
"description": "Modern type-safe backend framework, powered by Vite. Built for developer experience, pluggable as you need — runs on Express, Fastify or h3.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kickjs",
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
},
|
|
134
134
|
"peerDependencies": {
|
|
135
135
|
"@fastify/middie": "^9.0.0",
|
|
136
|
-
"@fastify/multipart": "^10.1.
|
|
136
|
+
"@fastify/multipart": "^10.1.4",
|
|
137
137
|
"croner": "^10.0.1",
|
|
138
138
|
"dotenv": "^17.0.0",
|
|
139
139
|
"express": "^5.1.0",
|
|
@@ -177,26 +177,26 @@
|
|
|
177
177
|
},
|
|
178
178
|
"devDependencies": {
|
|
179
179
|
"@fastify/middie": "^9.3.5",
|
|
180
|
-
"@fastify/multipart": "^10.1.
|
|
181
|
-
"@swc/core": "^1.16.
|
|
180
|
+
"@fastify/multipart": "^10.1.4",
|
|
181
|
+
"@swc/core": "^1.16.18",
|
|
182
182
|
"@types/compression": "1.8.1",
|
|
183
183
|
"@types/express": "^5.0.6",
|
|
184
184
|
"@types/multer": "^2.3.0",
|
|
185
185
|
"@types/node": "^26.6.5",
|
|
186
186
|
"@types/serve-static": "^2.2.0",
|
|
187
|
-
"@valibot/to-json-schema": "1.
|
|
188
|
-
"compression": "1.8.
|
|
187
|
+
"@valibot/to-json-schema": "1.8.0",
|
|
188
|
+
"compression": "1.8.2",
|
|
189
189
|
"croner": "^10.0.1",
|
|
190
|
-
"fastify": "^5.12.
|
|
190
|
+
"fastify": "^5.12.7",
|
|
191
191
|
"h3": "2.0.2",
|
|
192
192
|
"multer": "^2.4.0",
|
|
193
193
|
"serve-static": "^2.2.0",
|
|
194
194
|
"typescript": "^7.0.2",
|
|
195
|
-
"valibot": "1.
|
|
195
|
+
"valibot": "1.5.0",
|
|
196
196
|
"vite": "^8.3.4",
|
|
197
|
-
"vitest": "^5.0.
|
|
197
|
+
"vitest": "^5.0.5",
|
|
198
198
|
"yup": "1.7.1",
|
|
199
|
-
"zod": "^4.6.
|
|
199
|
+
"zod": "^4.6.7"
|
|
200
200
|
},
|
|
201
201
|
"publishConfig": {
|
|
202
202
|
"access": "public"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"application-BND5VDje.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/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,g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AQR,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;;;;;;;EA4BlB,iBAAiB;;UAaT;;UAYA;;UAUA;EAUF,SAAS;;EA8fT,gBAAgB;;;;;;;;;EAYhB,sBAAsB;;;;;UAQd;UASA;;;;;;;;;;EAmCR,SAAS;UAID;;UAyFA;UAwCA;;UAWA;;UAwBN;UAeA;;EAkBF,WAAW;;;;;;;;;;;EAuDX,SAAS,UAAS,kBAAuB;;;;;;;EAkM/C,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,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @forinda/kickjs v10.8.0
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) Felix Orinda
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
import{createLogger}from"./core/logger.mjs";import{Container}from"./core/container.mjs";import{r as reportError}from"./observers-BV435fEL.mjs";import{listCronJobs,runCronJob}from"./core/cron.mjs";import{reactive,ref}from"./core/reactivity.mjs";import"./core-CiwDroJ7.mjs";import{n as Application}from"./application-CWPS2sst.mjs";import{t as defineAdapter}from"./define-adapter-DJnPaqbo.mjs";import{r as settleBackgroundWork,t as forwardBackgroundWork}from"./background-D8VpVDrH.mjs";import{c as reloadEnv}from"./decorate-DdzHOAA1.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 loadCroner(){try{return peerRequire(`croner`).Cron}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 Croner=loadCroner();if(!Croner){log$2.warn(`${jobs.length} @Cron job(s) found but "croner" is not installed, so none will run. Install it: pnpm add croner`);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(new Croner(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}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-BpRQ1_KV.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap-BpRQ1_KV.mjs","names":["log","log","\"KICK_CRON_WORKER\""],"sources":["../src/http/cron-adapter.ts","../src/http/cluster.ts","../src/http/handler.ts","../src/http/bootstrap.ts"],"sourcesContent":["/**\n * `KickCronAdapter()` — runs `@Cron` jobs on the Node server.\n *\n * Named with the `Kick` prefix (adapter name and logger too) so it never\n * collides with an app's own `CronAdapter` — which is also why it is opt-in.\n *\n * Opt-in: `@Cron` only records metadata, and apps that schedule jobs with\n * their own adapter keep doing so — adding this one to such an app would run\n * every job twice. Register it once:\n *\n * ```ts\n * bootstrap({ modules, adapters: [KickCronAdapter()] })\n * ```\n *\n * Timing comes from the optional peer `croner` (`pnpm add croner`), loaded\n * only when there is a job to schedule. Each tick resolves the job's class\n * from the container (the same singletons a request gets) and calls\n * `runCronJob`, which applies `enabled` / `overlap` and reports failures to\n * the error observers.\n *\n * Several processes: in `bootstrap({ cluster })`, only the worker the primary\n * marks with `KICK_CRON_WORKER=1` schedules, so a job runs once per cluster.\n * Several separate instances (replicas behind a load balancer) each schedule\n * every job — turn it off on all but one (`KickCronAdapter({ enabled: false })`),\n * or have the job take a lock.\n *\n * @module @forinda/kickjs/http/cron-adapter\n */\nimport cluster from 'node:cluster'\nimport { createRequire } from 'node:module'\nimport { defineAdapter } from '../core/define-adapter'\nimport { createLogger } from '../core/logger'\nimport { listCronJobs, runCronJob, type CronJob } from '../core/cron'\nimport type { Container } from '../core/container'\n\nconst log = createLogger('KickCronAdapter')\nconst peerRequire = createRequire(import.meta.url)\n\n/** Set by the cluster primary on the one worker that runs `KickCronAdapter` jobs. */\nexport const CRON_WORKER_ENV = 'KICK_CRON_WORKER'\n\nexport interface CronAdapterOptions {\n /** Off for processes that should run no jobs (replicas, one-off scripts). Default `true`. */\n enabled?: boolean\n}\n\ninterface Schedule {\n stop(): void\n}\n\ntype CronerCtor = new (pattern: string, options: { timezone?: string }, fn: () => void) => Schedule\n\nfunction loadCroner(): CronerCtor | undefined {\n try {\n return (peerRequire('croner') as { Cron: CronerCtor }).Cron\n } catch {\n return undefined\n }\n}\n\n/** Whether this process should schedule jobs — one worker per cluster. */\nfunction isCronProcess(): boolean {\n return !cluster.isWorker || process.env[CRON_WORKER_ENV] === '1'\n}\n\nexport const KickCronAdapter = defineAdapter<CronAdapterOptions>({\n name: 'KickCronAdapter',\n defaults: { enabled: true },\n build(options) {\n const schedules: Schedule[] = []\n const inFlight = new Set<Promise<unknown>>()\n let jobs: CronJob[] = []\n\n return {\n afterStart({ container }) {\n if (options.enabled === false || !isCronProcess()) return\n jobs = listCronJobs(container)\n if (jobs.length === 0) return\n\n const Croner = loadCroner()\n if (!Croner) {\n log.warn(\n `${jobs.length} @Cron job(s) found but \"croner\" is not installed, so none will run. ` +\n 'Install it: pnpm add croner',\n )\n return\n }\n\n const run = (job: CronJob, trigger: 'schedule' | 'init') => {\n // Failures are already logged and reported by runCronJob.\n const p = runCronJob(job, container as Container, trigger).catch(() => {})\n inFlight.add(p)\n void p.finally(() => inFlight.delete(p))\n }\n\n for (const job of jobs) {\n schedules.push(\n new Croner(\n job.expression,\n // No croner `name`: croner keeps names in a process-wide registry\n // and throws on a duplicate.\n job.timezone ? { timezone: job.timezone } : {},\n () => run(job, 'schedule'),\n ),\n )\n if (job.runOnInit) run(job, 'init')\n }\n log.info(`Scheduled ${jobs.length} @Cron job(s): ${jobs.map((j) => j.name).join(', ')}`)\n },\n\n /**\n * Stops the schedules, then waits for running jobs so they don't lose\n * their dependencies mid-run. Also runs on every HMR reload, so a reload\n * never leaves a second copy ticking.\n */\n async shutdown() {\n for (const schedule of schedules.splice(0)) schedule.stop()\n await Promise.all(inFlight)\n },\n\n introspect() {\n return {\n protocolVersion: 1,\n name: 'KickCronAdapter',\n kind: 'adapter',\n state: {\n jobs: jobs.map((j) => ({\n name: j.name,\n expression: j.expression,\n timezone: j.timezone,\n description: j.description,\n })),\n },\n } as never\n },\n }\n },\n})\n","import cluster from 'node:cluster'\nimport { CRON_WORKER_ENV } from './cron-adapter'\nimport os from 'node:os'\nimport { createLogger } from '../core'\nimport { reactive, ref } from '../core/reactivity'\n\nconst log = createLogger('Cluster')\n\nexport interface ClusterOptions {\n /** Number of worker processes (default: os.cpus().length) */\n workers?: number\n /** Delay before forcefully killing a worker during shutdown (ms), default: 5000 */\n gracefulShutdownTimeout?: number\n /** Delay between worker restarts (ms), default: 1000 */\n restartDelay?: number\n /** Max failures in restartWindow before refusing to restart, default: 5 */\n maxFailures?: number\n /** Time window for counting failures (ms), default: 30000 */\n restartWindow?: number\n}\n\n/** Returns true if the current process is the cluster primary */\nexport function isClusterPrimary(): boolean {\n return cluster.isPrimary\n}\n\n/**\n * Fork worker processes and manage the cluster lifecycle.\n *\n * The primary process forks `workers` child processes. Each worker\n * shares the same port via Node's built-in `cluster` module (OS\n * round-robin load balancing).\n *\n * Features:\n * - Graceful shutdown with timeout fallback to forceful kill\n * - Auto-restart dead workers (respects voluntary disconnects)\n * - Startup timeout detection (stuck workers)\n * - Crash loop prevention (backoff on rapid failures)\n * - Comprehensive lifecycle logging\n */\nexport function setupClusterPrimary(opts: ClusterOptions): void {\n const numWorkers = opts.workers ?? os.cpus().length\n const gracefulTimeout = opts.gracefulShutdownTimeout ?? 5000\n const restartDelay = opts.restartDelay ?? 1000\n const maxFailures = opts.maxFailures ?? 5\n const restartWindow = opts.restartWindow ?? 30000\n\n const startupTimeouts = new Map<number, NodeJS.Timeout>()\n const state = reactive({\n failureTimestamps: [] as number[],\n shuttingDown: false,\n })\n const activeWorkers = ref(0)\n\n log.info(`Primary ${process.pid} starting ${numWorkers} worker(s)`)\n\n // Exactly one worker runs `KickCronAdapter` jobs, so a job fires once per\n // cluster rather than once per worker. The primary marks it with\n // KICK_CRON_WORKER=1; when it dies, the next fork inherits the role.\n let cronWorkerId: number | undefined\n const forkWorker = (): void => {\n const takesCron = cronWorkerId === undefined\n const worker = cluster.fork(takesCron ? { [CRON_WORKER_ENV]: '1' } : undefined)\n if (takesCron) cronWorkerId = worker.id\n }\n\n // Initial fork\n for (let i = 0; i < numWorkers; i++) {\n forkWorker()\n }\n\n // Detect stuck workers (no 'listening' event within timeout)\n cluster.on('fork', (worker) => {\n const timeout = setTimeout(() => {\n log.error(`Worker ${worker.process.pid} did not respond within 10s, killing...`)\n worker.kill()\n }, 10000)\n\n startupTimeouts.set(worker.id, timeout)\n activeWorkers.value++\n log.debug(`Worker ${worker.process.pid} forked (id=${worker.id})`)\n })\n\n // Clear startup timeout when worker is ready\n cluster.on('listening', (worker, address) => {\n const timeout = startupTimeouts.get(worker.id)\n if (timeout) {\n clearTimeout(timeout)\n startupTimeouts.delete(worker.id)\n }\n log.info(`Worker ${worker.process.pid} listening on ${address.address}:${address.port}`)\n })\n\n // Log when worker comes online\n cluster.on('online', (worker) => {\n log.debug(`Worker ${worker.process.pid} online (id=${worker.id})`)\n })\n\n // Auto-restart dead workers (unless intentionally disconnected)\n cluster.on('exit', (worker, code, signal) => {\n // Clear startup timeout if still pending\n const timeout = startupTimeouts.get(worker.id)\n if (timeout) {\n clearTimeout(timeout)\n startupTimeouts.delete(worker.id)\n }\n\n // Don't restart if worker was intentionally disconnected\n activeWorkers.value--\n if (worker.id === cronWorkerId) cronWorkerId = undefined\n\n if (worker.exitedAfterDisconnect) {\n log.info(`Worker ${worker.process.pid} exited gracefully (id=${worker.id})`)\n return\n }\n\n // Track crash history globally (worker IDs change on restart)\n const now = Date.now()\n // Remove timestamps outside the window, then add the current failure\n while (\n state.failureTimestamps.length > 0 &&\n now - state.failureTimestamps[0] >= restartWindow\n ) {\n state.failureTimestamps.shift()\n }\n state.failureTimestamps.push(now)\n\n // Prevent restart loops\n if (state.failureTimestamps.length > maxFailures) {\n log.error(\n `${state.failureTimestamps.length} worker failures in ${restartWindow}ms, giving up`,\n )\n // Optionally exit the primary if too many workers are crashing\n if (activeWorkers.value === 0) {\n log.error('All workers have crashed, exiting primary')\n process.exit(1)\n }\n return\n }\n\n log.warn(\n `Worker ${worker.process.pid} died (code=${code}, signal=${signal}), restarting in ${restartDelay}ms... (failures: ${state.failureTimestamps.length}/${maxFailures})`,\n )\n\n setTimeout(() => {\n // Only restart if we still need more workers\n if (activeWorkers.value < numWorkers) {\n forkWorker()\n }\n }, restartDelay)\n })\n\n // Log when worker disconnects (can happen before exit)\n cluster.on('disconnect', (worker) => {\n log.debug(`Worker ${worker.process.pid} disconnected (id=${worker.id})`)\n })\n\n // Forward shutdown signals to workers (disconnect so exitedAfterDisconnect is set)\n for (const signal of ['SIGTERM', 'SIGINT'] as const) {\n process.on(signal, () => {\n if (state.shuttingDown) return\n state.shuttingDown = true\n log.info(`Primary received ${signal}, disconnecting workers...`)\n cluster.disconnect(() => {\n log.info('All workers disconnected, exiting primary')\n process.exit(0)\n })\n // Force kill after graceful timeout\n setTimeout(() => {\n log.warn('Graceful shutdown timed out, forcing exit')\n process.exit(1)\n }, gracefulTimeout).unref()\n })\n }\n}\n","/**\n * The app as a request handler, with no listening server of its own — for\n * platforms that hand you requests instead of a port: Netlify Functions,\n * Vercel Functions, and any other serverless or embedding host.\n *\n * @module @forinda/kickjs/http/handler\n */\nimport type { IncomingMessage, ServerResponse } from 'node:http'\nimport { Application, type ApplicationOptions } from './application'\nimport { forwardBackgroundWork, settleBackgroundWork, type PlatformContext } from './background'\n\n/** A KickJS app exposed as request handlers. See {@link createHandler}. */\nexport interface KickHandler {\n /**\n * Web-standard handler: `fetch(Request) → Response`. Netlify Functions,\n * Vercel's fetch export, and anything else that speaks `Request`.\n *\n * Pass the platform context (Netlify's `context`, `{ waitUntil }` from\n * `@vercel/functions`) so work handed to `ctx.waitUntil()` finishes after\n * the response instead of being frozen with the instance.\n */\n fetch(request: Request, platform?: PlatformContext): Promise<Response>\n /** Node handler: `(req, res)`. Vercel Node functions, `http.createServer`. */\n node(req: IncomingMessage, res: ServerResponse, platform?: PlatformContext): Promise<void>\n /** Set the app up now instead of on the first request (warm-up). */\n ready(): Promise<Application>\n /** Shut adapters down and stop the internal forwarding server, if one started. */\n close(): Promise<void>\n}\n\n/**\n * Set on `globalThis` while `createHandler(() => import('./index'))` loads the\n * app's entry: `bootstrap()` hands its app here instead of starting it.\n * @internal\n */\nexport const ENTRY_CAPTURE = Symbol.for('kickjs.handler.entryCapture')\n\n/** What `bootstrap()` hands to a loading handler. @internal */\nexport type EntryCapture = (app: Application, options: ApplicationOptions) => void\n\n/**\n * Load the app's own entry and keep the app its `bootstrap()` call builds.\n * Retries after a failed setup reuse the captured options.\n */\nfunction captureEntry(\n load: () => Promise<unknown>,\n): () => Promise<{ first: Application; options: ApplicationOptions }> {\n let pending: Promise<{ first: Application; options: ApplicationOptions }> | undefined\n return () =>\n (pending ??= (async () => {\n let captured: { first: Application; options: ApplicationOptions } | undefined\n const g = globalThis as Record<symbol, unknown>\n const capture: EntryCapture = (first, options) => {\n captured ??= { first, options }\n }\n g[ENTRY_CAPTURE] = capture\n try {\n await load()\n } finally {\n if (g[ENTRY_CAPTURE] === capture) delete g[ENTRY_CAPTURE]\n }\n if (!captured) {\n throw new Error(\n 'createHandler(): the entry finished loading without calling bootstrap(). ' +\n \"Pass the module that calls it — createHandler(() => import('./index')) — or pass the options.\",\n )\n }\n return captured\n })().catch((err) => {\n pending = undefined\n throw err\n }))\n}\n\n/**\n * Build a KickJS app as request handlers instead of a listening server.\n *\n * Takes the same options as `bootstrap()`, or a function that imports the\n * app's entry — the file that calls `bootstrap()`. With the entry, the app\n * is built from that one `bootstrap({ ... })` call, so the server and the\n * function never drift apart:\n *\n * ```ts\n * // src/serverless.ts\n * export const handler = createHandler(() => import('./index'))\n * ```\n *\n * While the entry loads, its `bootstrap()` call builds the app without\n * starting it — no port, no process signal handlers, no cluster. The app is set up once per process\n * (per function instance), lazily on the first request, and reused after that.\n * Nothing listens on a port, `afterStart` does not run, and no process signal\n * handlers are registered — the platform owns the process.\n *\n * `fetch` uses the runtime's own fetch when it has one (the h3 v2 runtime).\n * Runtimes built on Node request/response objects — Express, the default —\n * are served through a server bound to `127.0.0.1` on a random port inside the\n * same process, started on first use: the `Request` is forwarded to it and its\n * response returned. Request bodies are buffered on that path; response bodies\n * stream. Adapters that rewrite the `res` prototype (Express does) make a\n * direct Request→`res` bridge unreliable, which is why this forwards instead.\n *\n * One handler per process: the DI container is process-wide.\n *\n * @example\n * ```ts\n * // server/src/serverless.ts\n * import 'reflect-metadata'\n * import './config'\n * import { createHandler } from '@forinda/kickjs'\n * import { modules } from './modules'\n *\n * export const handler = createHandler({ modules })\n *\n * // netlify/functions/api.mjs\n * export default (request, context) => handler.fetch(request, context)\n * export const config = { path: '/api/*' }\n * ```\n */\nexport function createHandler(options: ApplicationOptions | (() => Promise<unknown>)): KickHandler {\n let app: Promise<Application> | undefined\n const entry =\n typeof options === 'function'\n ? captureEntry(options)\n : async () => ({ first: undefined, options })\n // The app the entry's bootstrap() built is used once; a retry builds anew.\n let firstUsed = false\n\n const ready = (): Promise<Application> => {\n app ??= (async () => {\n let loaded: Awaited<ReturnType<typeof entry>>\n try {\n loaded = await entry()\n } catch (err) {\n // The entry failed to load: try again on the next request.\n app = undefined\n throw err\n }\n const instance = loaded.first && !firstUsed ? loaded.first : new Application(loaded.options)\n firstUsed = true\n try {\n await instance.startWithoutServer()\n } catch (err) {\n // A failed setup (a database that was briefly down, say) is retried on\n // the next request. Shut this attempt down first so its adapters don't\n // stay live next to the retry's.\n app = undefined\n await instance.shutdown().catch(() => {})\n throw err\n }\n return instance\n })()\n return app\n }\n\n return {\n ready,\n\n async fetch(request, platform) {\n const response = await (await ready()).fetch(request)\n forwardBackgroundWork(platform)\n return response\n },\n\n async node(req, res, platform) {\n const instance = await ready()\n instance.handle(req, res)\n if (platform?.waitUntil) {\n // The response is written asynchronously: start settling only once it\n // has gone out, so work the handler registered along the way is included.\n const sent = new Promise<void>((resolve) => res.once('close', () => resolve()))\n platform.waitUntil(sent.then(settleBackgroundWork))\n }\n },\n\n async close() {\n const current = app\n app = undefined\n if (current) await (await current).shutdown()\n },\n }\n}\n","import cluster from 'node:cluster'\nimport { reportError } from '../core/observers'\nimport { createLogger, Container } from '../core'\nimport { reloadEnv } from '../config/env'\nimport { Application, type ApplicationOptions } from './application'\nimport { setupClusterPrimary, type ClusterOptions } from './cluster'\nimport { ENTRY_CAPTURE, type EntryCapture } from './handler'\n\n/** Reload env from .env file (HMR rebuild) — config now lives in-tree. */\nfunction tryReloadEnv(): void {\n try {\n reloadEnv()\n } catch {\n // Best-effort: never crash bootstrap because env reload failed.\n }\n}\n\nconst log = createLogger('Process')\n\n/**\n * Bootstrap a KickJS application.\n *\n * Creates the Express app, registers modules and adapters, and starts\n * the HTTP server. In dev mode (`kick dev`), the Vite plugin manages\n * the server and HMR — source changes are picked up instantly without\n * losing database connections or WebSocket state.\n *\n * @returns The {@link Application} instance.\n *\n * @example\n * ```ts\n * // src/index.ts\n * import 'reflect-metadata'\n * import { bootstrap } from '@forinda/kickjs'\n * import { modules } from './modules'\n *\n * export const app = await bootstrap({ modules })\n * ```\n */\nexport async function bootstrap(options: ApplicationOptions): Promise<Application> {\n // ── Loaded by createHandler(() => import('./index')) ────────────────\n // The serverless entry reuses this call's options: build the app and hand\n // it over without listening, forking or registering process hooks.\n const capture = (globalThis as Record<symbol, unknown>)[ENTRY_CAPTURE]\n if (typeof capture === 'function') {\n const app = new Application(options)\n ;(capture as EntryCapture)(app, options)\n return app\n }\n\n // ── Cluster mode ─────────────────────────────────────────────────────\n // In cluster mode the primary process forks workers and never runs the\n // Express application itself. Only workers proceed past this block.\n // Cluster is disabled in Vite dev mode — Vite owns the HTTP server and\n // forked workers would each create their own Vite instance on separate ports.\n const isViteDev = !!(globalThis as any).__kickjs_httpServer\n if (options.cluster && isViteDev) {\n log.warn(\n 'Cluster mode is ignored in dev — Vite owns the server. Cluster applies in production (kick start).',\n )\n }\n if (options.cluster && cluster.isPrimary && !isViteDev) {\n const clusterOpts: ClusterOptions = typeof options.cluster === 'object' ? options.cluster : {}\n setupClusterPrimary(clusterOpts)\n\n // Return a placeholder — the primary never serves HTTP traffic.\n // The Application is created only so callers get a valid reference.\n return new Application(options)\n }\n\n // Internal: globalThis stores the app instance and Vite's HTTP server\n // reference across HMR rebuilds. When __kickjs_httpServer is set, the\n // Vite plugin owns the port and bootstrap() skips server creation.\n // On subsequent calls (HMR), the Express handler is swapped without\n // restarting the server — preserving DB connections and port bindings.\n const g = globalThis as any\n\n // ── Global error handlers + signal hooks ─────────────────────────────\n // `processHooks` controls whether KickJS registers its own\n // process-level handlers. Defaults to `'auto'` — register everything.\n // Adopters that bring their own observability stack (OpenTelemetry SDK,\n // Sentry, custom shutdown choreographer) often register their own\n // SIGINT/SIGTERM handlers and need to opt out of ours so the two don't\n // race to call `process.exit(0)`. Three modes:\n // - 'auto' (default): register uncaughtException/unhandledRejection\n // loggers + SIGINT/SIGTERM → `app.shutdown()` → `process.exit(0)`.\n // - 'errors-only': register the error loggers; skip signal handlers.\n // Use this when you have your own shutdown choreographer that calls\n // `app.shutdown()` itself.\n // - 'manual': skip everything. Adopter is responsible for both error\n // logging and signal-driven shutdown.\n const processHooks = options.processHooks ?? 'auto'\n\n if (!g.__kickBootstrapped) {\n if (processHooks !== 'manual') {\n // A listener here replaces Node's own handling, which exits with code\n // 1. Keep the failure in the exit code: a boot that throws — a top-level\n // `await bootstrap()` rejecting — must not end the process with 0, or a\n // deploy reads the crash as success.\n process.on('uncaughtException', (err) => {\n log.error(err, 'Uncaught exception')\n reportError(err, { source: 'uncaught' })\n process.exitCode = 1\n })\n\n process.on('unhandledRejection', (reason) => {\n log.error(reason as any, 'Unhandled rejection')\n reportError(reason, { source: 'unhandled-rejection' })\n process.exitCode = 1\n })\n }\n\n if (processHooks === 'auto' && !g.__kickjs_httpServer) {\n for (const signal of ['SIGINT', 'SIGTERM'] as const) {\n process.on(signal, async () => {\n log.info(`Received ${signal}, shutting down...`)\n if (g.__app) await g.__app.shutdown()\n process.exit(0)\n })\n }\n }\n\n g.__kickBootstrapped = true\n }\n\n // ── HMR rebuild ──────────────────────────────────────────────────────\n if (g.__app) {\n log.debug('HMR rebuild triggered')\n\n // Tear the PREVIOUS app down before replacing it. Without this the old\n // Application was dropped on the floor still running: its adapters kept\n // their sockets and consumers open, so every save added another set.\n //\n // Observed in the wild as one process holding several consumer-group\n // members — on a single-partition topic only one can hold the assignment,\n // and it was a leaked consumer no longer wired to anything, so jobs\n // stopped being processed. A second socket.io server on the same HTTP\n // server crashed `handleUpgrade()` the same way.\n //\n // `closeServer: false` is load-bearing: the dev HTTP server is shared\n // across rebuilds, so a full shutdown would close the listening socket and\n // kill HMR on the first save.\n //\n // Failures are logged, not thrown — one broken adapter must not leave the\n // dev server wedged with no app at all.\n try {\n await g.__app.shutdown({ closeServer: false })\n } catch (err) {\n log.error(err as Error, 'HMR teardown of the previous app failed')\n }\n\n tryReloadEnv()\n Container.reset()\n\n const freshApp = new Application(options)\n g.__app = freshApp\n g.__kickjs_container = freshApp.getContainer()\n\n await freshApp.start()\n log.debug('HMR rebuild complete')\n return freshApp\n }\n\n // ── First boot ───────────────────────────────────────────────────────\n const app = new Application(options)\n g.__app = app\n g.__kickjs_container = app.getContainer()\n\n if (process.env.KICK_TINKER) {\n await app.registerOnly()\n return app\n }\n\n await app.start()\n\n return app\n}\n"],"mappings":";;;;;;;;;;wnBAmCA,MAAMA,MAAM,aAAa,iBAAiB,EACpC,YAAc,cAAc,YAAY,GAAG,EAGpC,gBAAkB,mBAa/B,SAAS,YAAqC,CAC5C,GAAI,CACF,OAAQ,YAAY,QAAQ,CAAC,CAA0B,IACzD,MAAQ,CACN,MACF,CACF,CAGA,SAAS,eAAyB,CAChC,MAAO,CAAC,QAAQ,UAAY,QAAQ,IAAAE,mBAAyB,GAC/D,CAEA,MAAa,gBAAkB,cAAkC,CAC/D,KAAM,kBACN,SAAU,CAAE,QAAS,EAAK,EAC1B,MAAM,QAAS,CACb,IAAM,UAAwB,CAAC,EACzB,yBAAW,IAAI,IACjB,KAAkB,CAAC,EAEvB,MAAO,CACL,WAAW,CAAE,WAAa,CAGxB,GAFI,QAAQ,UAAY,IAAS,CAAC,cAAc,IAChD,KAAO,aAAa,SAAS,EACzB,KAAK,SAAW,GAAG,OAEvB,IAAM,OAAS,WAAW,EAC1B,GAAI,CAAC,OAAQ,CACX,MAAI,KACF,GAAG,KAAK,OAAO,iGAEjB,EACA,MACF,CAEA,IAAM,KAAO,IAAc,UAAiC,CAE1D,IAAM,EAAI,WAAW,IAAK,UAAwB,OAAO,CAAC,CAAC,UAAY,CAAC,CAAC,EACzE,SAAS,IAAI,CAAC,EACd,EAAO,YAAc,SAAS,OAAO,CAAC,CAAC,CACzC,EAEA,IAAK,IAAM,OAAO,KAChB,UAAU,KACR,IAA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