@fluojs/runtime
Advanced tools
+6
-1
@@ -6,6 +6,11 @@ /** | ||
| * | ||
| * The abort listener is always removed once `fn` settles, including when | ||
| * `fn` throws synchronously before returning a promise. The synchronous | ||
| * throw is converted into a settled rejection so the cleanup-dependent | ||
| * `finally` flow still runs. | ||
| * | ||
| * @param fn Async operation to execute while observing the abort signal. | ||
| * @param signal Abort signal that can cancel the in-flight operation. | ||
| * @returns The resolved value from `fn` when no abort happens first. | ||
| * @throws {Error} An `AbortError` when the signal is already aborted or aborts before `fn` settles. | ||
| * @throws {Error} An `AbortError` when the signal is already aborted or aborts before `fn` settles. Re-throws the original error when `fn` throws synchronously. | ||
| */ | ||
@@ -12,0 +17,0 @@ export declare function raceWithAbort<T>(fn: () => Promise<T>, signal: AbortSignal): Promise<T>; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"abort.d.ts","sourceRoot":"","sources":["../src/abort.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAgB5F;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,KAAK,CAKvD"} | ||
| {"version":3,"file":"abort.d.ts","sourceRoot":"","sources":["../src/abort.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,aAAa,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CA2B5F;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,KAAK,CAKvD"} |
+18
-2
@@ -6,6 +6,11 @@ /** | ||
| * | ||
| * The abort listener is always removed once `fn` settles, including when | ||
| * `fn` throws synchronously before returning a promise. The synchronous | ||
| * throw is converted into a settled rejection so the cleanup-dependent | ||
| * `finally` flow still runs. | ||
| * | ||
| * @param fn Async operation to execute while observing the abort signal. | ||
| * @param signal Abort signal that can cancel the in-flight operation. | ||
| * @returns The resolved value from `fn` when no abort happens first. | ||
| * @throws {Error} An `AbortError` when the signal is already aborted or aborts before `fn` settles. | ||
| * @throws {Error} An `AbortError` when the signal is already aborted or aborts before `fn` settles. Re-throws the original error when `fn` throws synchronously. | ||
| */ | ||
@@ -23,3 +28,14 @@ export async function raceWithAbort(fn, signal) { | ||
| }); | ||
| Promise.resolve(fn()).then(resolve, reject).finally(() => { | ||
| // Convert `fn()` invocation into a settled promise so a synchronous | ||
| // throw still flows through the `finally` cleanup that removes the | ||
| // abort listener. `Promise.resolve()` only wraps an already-produced | ||
| // value; it does not catch a throw emitted while `fn()` is invoked. | ||
| let fnResultPromise; | ||
| try { | ||
| fnResultPromise = Promise.resolve(fn()); | ||
| } catch (syncError) { | ||
| fnResultPromise = Promise.reject(syncError); | ||
| } | ||
| fnResultPromise.then(resolve, reject).finally(() => { | ||
| signal.removeEventListener('abort', onAbort); | ||
@@ -26,0 +42,0 @@ }); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EACV,kBAAkB,EAClB,WAAW,EAEX,uBAAuB,EAGvB,2BAA2B,EAC3B,sBAAsB,EACtB,eAAe,EAGf,wBAAwB,EACxB,+BAA+B,EAC/B,yBAAyB,EAEzB,gBAAgB,EAChB,UAAU,EAMX,MAAM,YAAY,CAAC;AA6dpB;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,UAAU,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,EAAE,gBAAgB,GAAG,CAAC,CAIjG;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,GA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,WAAW;IACtB;;;;;;;OAOG;WACU,MAAM,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAAC,WAAW,CAAC;IAOzG;;;;;;;OAOG;WACU,wBAAwB,CACnC,UAAU,EAAE,UAAU,EACtB,OAAO,GAAE,+BAAoC,GAC5C,OAAO,CAAC,kBAAkB,CAAC;IAwH9B;;;;;;;;OAQG;WACU,kBAAkB,CAC7B,UAAU,EAAE,UAAU,EACtB,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,uBAAuB,CAAC;CA+BpC;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,oBAAc,CAAC"} |
@@ -866,5 +866,6 @@ import { Container } from '@fluojs/di'; | ||
| function createHandlerSources(modules) { | ||
| const globalModules = modules.filter(compiledModule => compiledModule.definition.global); | ||
| return modules.flatMap(compiledModule => (compiledModule.definition.controllers ?? []).map(controllerToken => ({ | ||
| controllerToken, | ||
| moduleMiddleware: compiledModule.definition.middleware ?? [], | ||
| moduleMiddleware: [...globalModules.filter(globalModule => globalModule !== compiledModule).flatMap(globalModule => globalModule.definition.middleware ?? []), ...(compiledModule.definition.middleware ?? [])], | ||
| moduleType: compiledModule.type | ||
@@ -871,0 +872,0 @@ }))); |
@@ -32,2 +32,12 @@ import type { ModuleType } from '../types.js'; | ||
| export type ReadinessCheck = (ctx: import('@fluojs/http').RequestContext) => boolean | Promise<boolean>; | ||
| /** Runtime-owned health module class returned by `HealthModule.forRoot(...)`. */ | ||
| export interface RuntimeHealthModule extends ModuleType { | ||
| readonly name: string; | ||
| /** Register an additional readiness predicate for the module-owned `/ready` route. */ | ||
| addReadinessCheck(fn: ReadinessCheck): void; | ||
| /** Mark the module-owned `/ready` route as ready after bootstrap completes. */ | ||
| markReady(): void; | ||
| /** Mark the module-owned `/ready` route as starting before or during shutdown. */ | ||
| markStarting(): void; | ||
| } | ||
| /** | ||
@@ -43,3 +53,3 @@ * Runtime health module facade for application module imports. | ||
| */ | ||
| static forRoot(options?: HealthModuleOptions): ModuleType; | ||
| static forRoot(options?: HealthModuleOptions): RuntimeHealthModule; | ||
| } | ||
@@ -53,3 +63,3 @@ /** | ||
| */ | ||
| export declare function createHealthModule(options?: HealthModuleOptions): ModuleType; | ||
| export declare function createHealthModule(options?: HealthModuleOptions): RuntimeHealthModule; | ||
| //# sourceMappingURL=health.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/health/health.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,IAAI,GAAG,aAAa,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,OAAO,GAAG,UAAU,GAAG,aAAa,CAAC;CAC9C;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,cAAc,EAAE,cAAc,KACrD,YAAY,GACZ,mBAAmB,GACnB,OAAO,CAAC,YAAY,GAAG,mBAAmB,CAAC,CAAC;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,OAAO,cAAc,EAAE,cAAc,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAkFxG;;GAEG;AACH,qBAAa,YAAY;IACvB;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,OAAO,GAAE,mBAAwB,GAAG,UAAU;CAG9D;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,mBAAwB,GAAG,UAAU,C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G,mBAAmB,CAEzF"} |
@@ -29,2 +29,4 @@ function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; } | ||
| /** Runtime-owned health module class returned by `HealthModule.forRoot(...)`. */ | ||
| function createRuntimeHealthModule(options = {}) { | ||
@@ -31,0 +33,0 @@ let _initProto, _initClass; |
| import type { Token } from '@fluojs/core'; | ||
| import type { Provider } from '@fluojs/di'; | ||
| import { type Provider } from '@fluojs/di/internal'; | ||
| import type { BootstrapModuleOptions, CompiledModule, ModuleType } from './types.js'; | ||
@@ -4,0 +4,0 @@ /** |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"module-graph.d.ts","sourceRoot":"","sources":["../src/module-graph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAY3C,OAAO,KAAK,EACV,sBAAsB,EACtB,cAAc,EAGd,UAAU,EACX,MAAM,YAAY,CAAC;AAEpB;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,KAAK,CAMvD;AAkBD,yFAAyF;AACzF,wBAAgB,sCAAsC,IAAI,IAAI,CAE7D;AAED;;;;GAIG;AACH,wBAAgB,wCAAwC,IAAI,MAAM,CAEjE;AA2FD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,GAAE,sBAA2B,GAAG,MAAM,CAc9G;AAiRD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,GAAE,QAAQ,EAAO,GAAG,GAAG,CAAC,KAAK,CAAC,CAE5E;AAiXD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,GAAE,sBAA2B,GAAG,cAAc,EAAE,CA6BjH"} | ||
| {"version":3,"file":"module-graph.d.ts","sourceRoot":"","sources":["../src/module-graph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,KAAK,QAAQ,EAA0B,MAAM,qBAAqB,CAAC;AAY5E,OAAO,KAAK,EACV,sBAAsB,EACtB,cAAc,EAGd,UAAU,EACX,MAAM,YAAY,CAAC;AAEpB;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,KAAK,CAMvD;AAkBD,yFAAyF;AACzF,wBAAgB,sCAAsC,IAAI,IAAI,CAE7D;AAED;;;;GAIG;AACH,wBAAgB,wCAAwC,IAAI,MAAM,CAEjE;AA2FD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,GAAE,sBAA2B,GAAG,MAAM,CAc9G;AAiRD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,GAAE,QAAQ,EAAO,GAAG,GAAG,CAAC,KAAK,CAAC,CAE5E;AAiXD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,GAAE,sBAA2B,GAAG,cAAc,EAAE,CA6BjH"} |
@@ -0,1 +1,2 @@ | ||
| import { validateProviderInputs } from '@fluojs/di/internal'; | ||
| import { getRuntimeClassDiMetadata, getRuntimeClassDiMetadataVersion, getOwnRuntimeClassDiMetadata, getRuntimeModuleMetadata, getRuntimeModuleMetadataVersion } from './internal/core-metadata.js'; | ||
@@ -106,3 +107,3 @@ import { ModuleGraphError, ModuleInjectionMetadataError, ModuleVisibilityError } from './errors.js'; | ||
| export function createModuleGraphCacheKey(rootModule, options = {}) { | ||
| const runtimeProviders = (options.providers ?? []).map(describeProviderForCacheKey).join('|'); | ||
| const runtimeProviders = validateProviderInputs(options.providers ?? []).map(describeProviderForCacheKey).join('|'); | ||
| const validationTokens = (options.validationTokens ?? []).map(describeTokenForCacheKey).join('|'); | ||
@@ -389,3 +390,3 @@ const moduleReplacements = describeModuleReplacementsForCacheKey(options.moduleReplacements); | ||
| imports: rawDefinition.imports ?? [], | ||
| providers: rawDefinition.providers ?? [], | ||
| providers: validateProviderInputs(rawDefinition.providers ?? []), | ||
| controllers: rawDefinition.controllers ?? [], | ||
@@ -564,3 +565,3 @@ exports: rawDefinition.exports ?? [], | ||
| const ordered = []; | ||
| const runtimeProviders = options.providers ?? []; | ||
| const runtimeProviders = validateProviderInputs(options.providers ?? []); | ||
| const runtimeProviderTokens = mergeRuntimeTokenSets(runtimeProviders, options.validationTokens ?? []); | ||
@@ -567,0 +568,0 @@ const moduleReplacements = options.moduleReplacements ?? EMPTY_MODULE_REPLACEMENTS; |
@@ -8,3 +8,3 @@ /** | ||
| mimetype: string; | ||
| buffer: Buffer; | ||
| buffer: Uint8Array; | ||
| size: number; | ||
@@ -11,0 +11,0 @@ } |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"multipart.d.ts","sourceRoot":"","sources":["../src/multipart.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IAC1C,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,GAAG,QAAQ,GAAG,IAAI,CAAC;IACnD,OAAO,EAAE,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC;IAC3E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,aAAa,CAAC,UAAU,CAAC,CAAC;CACtD;AAOD;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,GAAG,oBAAoB,EACvC,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,eAAe,CAAC,CA8C1B"} | ||
| {"version":3,"file":"multipart.d.ts","sourceRoot":"","sources":["../src/multipart.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IAC1C,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,GAAG,QAAQ,GAAG,IAAI,CAAC;IACnD,OAAO,EAAE,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC;IAC3E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,aAAa,CAAC,UAAU,CAAC,CAAC;CACtD;AAQD;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,GAAG,oBAAoB,EACvC,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,eAAe,CAAC,CA8C1B"} |
@@ -23,2 +23,3 @@ import { PayloadTooLargeException } from '@fluojs/http'; | ||
| const MULTIPART_BODY_LIMIT_MESSAGE = 'Multipart body exceeds the maximum size of'; | ||
| const TEXT_ENCODER = new TextEncoder(); | ||
@@ -43,3 +44,3 @@ /** | ||
| if (typeof value === 'string') { | ||
| totalSize += Buffer.byteLength(value, 'utf8'); | ||
| totalSize += TEXT_ENCODER.encode(value).byteLength; | ||
| if (totalSize > maxTotalSize) { | ||
@@ -62,3 +63,3 @@ throw new PayloadTooLargeException(`${MULTIPART_BODY_LIMIT_MESSAGE} ${String(maxTotalSize)} bytes.`); | ||
| files.push({ | ||
| buffer: Buffer.from(await value.arrayBuffer()), | ||
| buffer: new Uint8Array(await value.arrayBuffer()), | ||
| fieldname, | ||
@@ -65,0 +66,0 @@ mimetype: value.type, |
@@ -76,3 +76,6 @@ import { Readable } from 'node:stream'; | ||
| frameworkRequest.body = result.fields; | ||
| frameworkRequest.files = result.files; | ||
| frameworkRequest.files = result.files.map(file => ({ | ||
| ...file, | ||
| buffer: Buffer.from(file.buffer) | ||
| })); | ||
| return; | ||
@@ -79,0 +82,0 @@ } |
| import { createServer as createHttpServer } from 'node:http'; | ||
| import { createServer as createHttpsServer, type ServerOptions as HttpsServerOptions } from 'node:https'; | ||
| import { type CorsOptions, type Dispatcher, type HttpApplicationAdapter, type MiddlewareLike, type SecurityHeadersOptions } from '@fluojs/http'; | ||
| import type { MultipartOptions, UploadedFile } from '../multipart.js'; | ||
| import type { MultipartOptions } from '../multipart.js'; | ||
| import type { Application, ApplicationLogger, CreateApplicationOptions, ModuleType } from '../types.js'; | ||
@@ -9,8 +9,2 @@ import { compressNodeResponse, createNodeResponseCompression } from './internal-node-compression.js'; | ||
| import { createNodeShutdownSignalRegistration, defaultNodeShutdownSignals, registerShutdownSignals } from './internal-node-shutdown.js'; | ||
| declare module '@fluojs/http' { | ||
| interface FrameworkRequest { | ||
| files?: UploadedFile[]; | ||
| rawBody?: Uint8Array; | ||
| } | ||
| } | ||
| /** | ||
@@ -17,0 +11,0 @@ * Describes the node http adapter options contract. |
@@ -1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AAE,gBAAgB,GAAG,sBAAsB,CAa5J;AAED;;;;;;GAMG;AACH,wBAAsB,wBAAwB,CAC5C,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,WAAW,CAAC,CAStB;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,WAAW,CAAC,CAStB;AAED,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,mCAAmC,EACnC,wBAAwB,EACxB,mBAAmB,EACnB,6BAA6B,EAC7B,oCAAoC,EACpC,mBAAmB,EACnB,0BAA0B,EAC1B,2BAA2B,EAC3B,iBAAiB,EACjB,0BAA0B,EAC1B,sBAAsB,EACtB,uBAAuB,EACvB,yBAAyB,EACzB,2BAA2B,EAC3B,yBAAyB,EACzB,kBAAkB,GACnB,CAAC"} | ||
| {"version":3,"file":"internal-node.d.ts","sourceRoot":"","sources":["../../src/node/internal-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAA6C,MAAM,WAAW,CAAC;AACxG,OAAO,EAAE,YAAY,IAAI,iBAAiB,EAAE,KAAK,aAAa,IAAI,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAGzG,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,UAAU,EACf,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC5B,MAAM,cAAc,CAAC;AAUtB,OAAO,KAAK,EAAE,gBAAgB,EAAgB,MAAM,iBAAiB,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACxG,OAAO,EACL,oBAAoB,EACpB,6BAA6B,EAC9B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EAEnB,mC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kBAAkB,GAAG,SAAS,EAC7D,gBAAgB,CAAC,EAAE,gBAAgB,EACnC,WAAW,SAAkB,EAC7B,eAAe,UAAQ,EACN,iBAAiB,SAA8B;IAwBlE,SAAS,IAAI,UAAU;IAIvB,qBAAqB;IAIrB,eAAe,IAAI,gBAAgB;IAI7B,MAAM,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAU7C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAad,aAAa;CAY5B;AAiDD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,sBAA2B,EAAE,WAAW,UAAQ,EAAE,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,sBAAsB,CAa5J;AAED;;;;;;GAMG;AACH,wBAAsB,wBAAwB,CAC5C,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,WAAW,CAAC,CAStB;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,WAAW,CAAC,CAStB;AAED,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,mCAAmC,EACnC,wBAAwB,EACxB,mBAAmB,EACnB,6BAA6B,EAC7B,oCAAoC,EACpC,mBAAmB,EACnB,0BAA0B,EAC1B,2BAA2B,EAC3B,iBAAiB,EACjB,0BAA0B,EAC1B,sBAAsB,EACtB,uBAAuB,EACvB,yBAAyB,EACzB,2BAA2B,EAC3B,yBAAyB,EACzB,kBAAkB,GACnB,CAAC"} |
+1
-7
| import { type Dispatcher, type FrameworkRequest, type FrameworkResponse } from '@fluojs/http'; | ||
| import { type MultipartOptions, type UploadedFile } from './multipart.js'; | ||
| import { type MultipartOptions } from './multipart.js'; | ||
| import { type RequestResponseFactory } from './adapters/request-response-factory.js'; | ||
| declare module '@fluojs/http' { | ||
| interface FrameworkRequest { | ||
| files?: UploadedFile[]; | ||
| rawBody?: Uint8Array; | ||
| } | ||
| } | ||
| /** | ||
@@ -11,0 +5,0 @@ * Configures Web request parsing, multipart handling, and raw body preservation. |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACvB,MAAM,cAAc,CAAC;AAMtB,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,wCAAwC,CAAC;AAEhD,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,gBAAgB;QACxB,KAAK,CAAC,EAAE,YAAY,EAAE,CAAC;QACvB,OAAO,CAAC,EAAE,UAAU,CAAC;KACtB;CACF;AAOD;;GAEG;AACH,MAAM,WAAW,sCAAsC;IACrD,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,yBAA0B,SAAQ,sCAAsC;IACvF,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC;;;;OAIG;IACH,OAAO,CAAC,EAAE,sBAAsB,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,EAAE,oBAAoB,CAAC,CAAC;IACzF,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;IAC7D,UAAU,IAAI,QAAQ,CAAC;CACxB;AAED,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAgNhD;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AAS,EAAE,oBAAoB,CAAC,CAAC;IACzF,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;IAC7D,UAAU,IAAI,QAAQ,CAAC;CACxB;AAED,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAgNhD;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,GAAE,sCAA2C,GACnD,sBAAsB,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,EAAE,oBAAoB,CAAC,CA+BhF;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,UAAU,EACV,yBAAiG,EACjG,OAAO,EACP,OAAO,EACP,GAAG,OAAO,EACX,EAAE,yBAAyB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAU/C;AAED;;;;;;;;;GASG;AACH,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,WAAW,EACnB,gBAAgB,CAAC,EAAE,gBAAgB,EACnC,WAAW,SAAwB,EACnC,eAAe,UAAQ,GACtB,OAAO,CAAC,gBAAgB,CAAC,CAW3B"} |
+6
-6
@@ -12,3 +12,3 @@ { | ||
| ], | ||
| "version": "1.1.8", | ||
| "version": "2.0.1", | ||
| "private": false, | ||
@@ -71,10 +71,10 @@ "license": "MIT", | ||
| "dependencies": { | ||
| "@fluojs/config": "^1.0.3", | ||
| "@fluojs/core": "^1.0.3", | ||
| "@fluojs/di": "^1.1.0", | ||
| "@fluojs/http": "^1.1.2" | ||
| "@fluojs/config": "^1.0.4", | ||
| "@fluojs/core": "^1.1.0", | ||
| "@fluojs/di": "^2.0.0", | ||
| "@fluojs/http": "^2.0.1" | ||
| }, | ||
| "devDependencies": { | ||
| "vitest": "^3.2.4", | ||
| "@fluojs/serialization": "^1.0.4" | ||
| "@fluojs/serialization": "^1.0.5" | ||
| }, | ||
@@ -81,0 +81,0 @@ "scripts": { |
+14
-1
@@ -111,2 +111,8 @@ # @fluojs/runtime | ||
| ### Framework-managed response와 handler-owned response | ||
| 일반 request path는 framework-managed 방식입니다. Handler가 값을 반환하면 interceptor가 그 값을 변환할 수 있고, runtime response writer가 최종 결과를 commit합니다. `@fluojs/serialization`의 `SerializerInterceptor`가 반환 DTO에 적용되는 경로도 이 경로입니다. | ||
| 고급 handler는 `RequestContext.response.send(...)`, `redirect(...)`, 또는 수동 streaming helper를 호출해 response ownership을 직접 가질 수 있습니다. Response가 commit되면 `SerializerInterceptor`는 등록된 경우 serialization을 우회하고 `next.handle()`에서 받은 값을 그대로 반환합니다. 이 동작이 chain 결과를 고정하지는 않으므로 다른 interceptor는 chain 결과를 계속 변환할 수 있습니다. 이와 별개로 dispatcher는 commit된 response를 확인하고 두 번째 success-response write를 건너뛰므로 최종 interceptor-chain 결과를 쓰지 않습니다. 따라서 직접 응답을 쓰는 코드는 commit 전에 안전한 최종 payload를 만들어야 하며 serializer가 이후에 형태를 바꿀 수 없습니다. | ||
| ### 모듈 구성 | ||
@@ -140,2 +146,3 @@ | ||
| - `duplicateProviderPolicy`가 `warn` 또는 `ignore`일 때 context cache 적격성과 lifecycle hook 실행은 bootstrap이 선택한 effective winning provider를 기준으로 결정됩니다. stale losing provider는 cache entry나 lifecycle hook을 만들지 않습니다. | ||
| - 모듈 그래프 컴파일은 cache key 생성이나 visibility 순회 전에 runtime provider와 `@Module(...)` provider 선언을 DI의 canonical normalization으로 검증합니다. 따라서 잘못된 `inject` 값, dependency wrapper/token, scope는 순회 단계 고유 오류를 노출하지 않고 `InvalidProviderError`로 실패합니다. | ||
| - 애플리케이션 또는 컨텍스트 bootstrap이 런타임 리소스나 lifecycle instance 생성 이후 실패하면 fluo는 readiness를 초기화하고, 등록된 runtime cleanup callback을 실행하며, 그 시점까지 해석된 instance의 shutdown hook을 `bootstrap-failed`로 호출하고, 컨테이너를 dispose하고, cleanup 실패를 로그로 남긴 뒤 원래 bootstrap error를 다시 던집니다. | ||
@@ -149,4 +156,6 @@ - `Application.listen()`과 microservice `listen()`은 shutdown과 직렬화됩니다. 겹치는 startup 호출은 같은 in-flight startup을 공유하고, shutdown은 진행 중인 startup이 끝날 때까지 기다리며, shutdown과 경합한 startup은 close 시작 이후 shell을 다시 `ready`로 전이할 수 없습니다. | ||
| - 멀티파트 파싱은 누적 바디 크기가 설정된 `multipart.maxTotalSize`를 넘으면 즉시 거부되며, 런타임 어댑터는 별도 재정의가 없으면 이 한도를 `maxBodySize`와 동일하게 맞춥니다. | ||
| - `@fluojs/runtime/web` 멀티파트 파싱은 Node.js `Buffer` global 없이 Web 표준 `TextEncoder`와 `Uint8Array` primitive만 사용합니다. 업로드 파일의 `buffer` 값은 `Uint8Array`이며, Node 전용 consumer는 애플리케이션 경계에서 `Buffer.from(file.buffer)`로 명시적으로 변환할 수 있습니다. | ||
| - `createNodeHttpAdapter(...)`, `bootstrapNodeApplication(...)`, `runNodeApplication(...)`는 `maxBodySize`를 0 이상의 정수 바이트 수로만 받으며, 값이 잘못되면 어댑터 생성/부트스트랩 단계에서 즉시 실패합니다. | ||
| - 응답 스트림 백프레셔 헬퍼는 `drain`, `close`, `error` 중 어느 경우에도 `waitForDrain()`을 완료시켜 끊어진 연결에서 스트리밍 작성기가 멈추지 않도록 합니다. | ||
| - HTTP response writing은 단일 owner를 가집니다. Framework-managed handler 결과는 runtime이 commit하기 전에 interceptor가 변환할 수 있습니다. Handler나 response helper가 `RequestContext.response`를 commit한 뒤에는 dispatcher가 두 번째 success-response write를 건너뜁니다. `SerializerInterceptor`는 serialization을 우회하고 `next.handle()`에서 받은 값을 그대로 반환하지만, 다른 interceptor는 chain 결과를 계속 변환할 수 있습니다. | ||
| - 런타임 health 모듈은 bootstrap이 ready로 표시하기 전까지 `/ready`를 HTTP 503과 `starting`으로 보고하며, 애플리케이션/컨텍스트 종료가 시작되는 즉시, 종료 시도가 실패하더라도 다시 `starting`으로 내려갑니다. | ||
@@ -161,2 +170,3 @@ - 런타임 health module readiness check는 현재 `RequestContext`를 받으므로, public integration이 internal runtime token을 import하지 않고도 runtime-exposed status provider를 해석할 수 있습니다. | ||
| - `moduleReplacements`는 `bootstrapModule(...)` / `BootstrapModuleOptions`의 저수준 testing seam입니다. 원래 logical module identity를 보존하면서 replacement module metadata로 컴파일하고, replacement cycle은 일반 module graph validation 경로에서 거부하며, source module metadata를 mutate하지 않습니다. | ||
| - `raceWithAbort(fn, signal)`은 `fn`이 settle된 후 항상 abort listener를 제거합니다. `fn`이 promise를 반환하기 전에 동기적으로 throw하는 경우도 포함합니다. 동기 throw는 settled rejection으로 변환되어 cleanup-dependent `finally` flow가 여전히 실행되고, 반복된 실패 작업에서 listener가 leak되지 않습니다. | ||
@@ -170,4 +180,5 @@ ## 공개 API 개요 | ||
| - `LifecycleHooks`: `OnModuleInit`, `OnApplicationBootstrap`, `OnModuleDestroy`, `OnApplicationShutdown`를 묶는 편의 union 타입입니다. | ||
| - `HealthModule.forRoot(options)`: bootstrap 및 shutdown 라이프사이클 전이에 맞춰 readiness marker를 관리하는 런타임 소유 `/health`, `/ready` 모듈 파사드입니다. | ||
| - `HealthModule.forRoot(options)`: bootstrap 및 shutdown 라이프사이클 전이에 맞춰 readiness marker를 관리하는 런타임 소유 `/health`, `/ready` 모듈 파사드입니다. `RuntimeHealthModule`을 반환하므로 first-party runtime-aware package가 internal runtime seam을 import하지 않고 `ReadinessCheck` function을 등록할 수 있습니다. | ||
| - `createHealthModule(options)`: 같은 런타임 health module 계약을 위한 deprecated compatibility helper입니다. 애플리케이션-facing module import에서는 `HealthModule.forRoot(...)`를 우선 사용하세요. | ||
| - `RuntimeHealthModule`: `HealthModule.forRoot(...)`가 반환하는 module class contract이며 `addReadinessCheck(...)`, `markReady()`, `markStarting()`을 포함합니다. | ||
| - `ReadinessCheck`: runtime health module이 사용하는 function type입니다. Check는 `/ready` request context를 받고 boolean 또는 promise를 반환합니다. | ||
@@ -180,2 +191,3 @@ - `defineModule(cls, metadata)`: 프로그래밍 방식의 모듈 정의 헬퍼입니다. | ||
| - `createRequestAbortContext(...)`, `trackActiveRequestTransaction(...)`, `untrackActiveRequestTransaction(...)`: runtime-aware integration이 사용하는 request abort 및 active transaction helper입니다. | ||
| - `UploadedFile`: 메모리 내 `buffer` payload를 Web 표준 `Uint8Array`로 제공하는 runtime-neutral 멀티파트 파일 descriptor입니다. | ||
@@ -242,2 +254,3 @@ ## 플랫폼 전용 서브경로 | ||
| - [@fluojs/http](../http): HTTP 라우팅, 컨트롤러 및 디스패처. | ||
| - [@fluojs/serialization](../serialization): Framework-managed 상태로 아직 commit되지 않은 HTTP handler 결과를 decorator metadata에 따라 shaping합니다. | ||
| - [@fluojs/platform-nodejs](../platform-nodejs): 공식 Node.js HTTP 어댑터. | ||
@@ -244,0 +257,0 @@ - [@fluojs/studio](../studio): 런타임이 생산한 snapshot과 diagnostic issue를 위한 viewer, filtering, rendering helper. |
+14
-1
@@ -111,2 +111,8 @@ # @fluojs/runtime | ||
| ### Framework-Managed and Handler-Owned Responses | ||
| The normal request path is framework-managed: a handler returns a value, interceptors may transform it, and the runtime response writer commits it. This is the path where `@fluojs/serialization` can apply `SerializerInterceptor` to a returned DTO. | ||
| Advanced handlers can instead take response ownership by calling `RequestContext.response.send(...)`, `redirect(...)`, or a manual streaming helper. Once that response is committed, `SerializerInterceptor`, when present, bypasses serialization and returns the value it received from `next.handle()` unchanged. This does not freeze the chain result: other interceptors may still transform it. Independently, the dispatcher sees the committed response and skips a second success-response write, so it does not write the final interceptor-chain result. Direct response code must therefore produce the final safe payload before committing; a serializer cannot reshape it afterward. | ||
| ### Module Composition | ||
@@ -140,2 +146,3 @@ | ||
| - When `duplicateProviderPolicy` is `warn` or `ignore`, context-cache eligibility and lifecycle hook execution are based on the effective winning provider selected by bootstrap; stale losing providers do not seed cache entries or lifecycle hooks. | ||
| - Module graph compilation validates runtime and `@Module(...)` provider declarations through DI's canonical normalization before cache-key generation or visibility traversal. Malformed `inject` values, dependency wrappers/tokens, and scopes therefore fail with `InvalidProviderError` instead of leaking traversal-specific errors. | ||
| - If application or context bootstrap fails after runtime resources or lifecycle instances have been created, fluo resets readiness, runs registered runtime cleanup callbacks, invokes shutdown hooks for instances resolved so far with `bootstrap-failed`, disposes the container, logs cleanup failures, and rethrows the original bootstrap error. | ||
@@ -149,4 +156,6 @@ - `Application.listen()` and microservice `listen()` are serialized with shutdown: overlapping startup calls share the same in-flight startup, shutdown waits for in-flight startup to settle, and a startup that races with shutdown cannot transition the shell back to `ready` after close begins. | ||
| - Multipart parsing rejects payloads when the cumulative body size exceeds the configured `multipart.maxTotalSize`; runtime adapters default that limit to `maxBodySize` unless you override it. | ||
| - `@fluojs/runtime/web` multipart parsing uses Web-standard `TextEncoder` and `Uint8Array` primitives without requiring the Node.js `Buffer` global. Uploaded file `buffer` values are `Uint8Array`; Node-only consumers can convert them explicitly with `Buffer.from(file.buffer)` at their application boundary. | ||
| - `createNodeHttpAdapter(...)`, `bootstrapNodeApplication(...)`, and `runNodeApplication(...)` accept `maxBodySize` only as a non-negative integer byte count and fail fast during adapter creation/bootstrap when the value is invalid. | ||
| - Response stream backpressure helpers settle `waitForDrain()` on `drain`, `close`, or `error` so streaming writers do not hang on dead connections. | ||
| - HTTP response writing is single-owner: framework-managed handler results may be transformed by interceptors before the runtime commits them. Once a handler or response helper commits `RequestContext.response`, the dispatcher skips a second success-response write. `SerializerInterceptor` bypasses serialization and returns the value it received from `next.handle()` unchanged, while other interceptors may still transform the chain result. | ||
| - Runtime health modules report `/ready` as `starting` with HTTP 503 until bootstrap marks them ready, and they return to `starting` as soon as application/context shutdown begins, including failed shutdown attempts. | ||
@@ -161,2 +170,3 @@ - Runtime health module readiness checks receive the current `RequestContext`, allowing public integrations to resolve runtime-exposed status providers without importing internal runtime tokens. | ||
| - `moduleReplacements` is a low-level testing seam on `bootstrapModule(...)` / `BootstrapModuleOptions`. It compiles replacement module metadata while preserving the original logical module identity, rejects replacement cycles through the normal module graph validation path, and does not mutate source module metadata. | ||
| - `raceWithAbort(fn, signal)` always removes its abort listener once `fn` settles, including when `fn` throws synchronously before returning a promise. The synchronous throw is converted into a settled rejection so the cleanup-dependent `finally` flow still runs and the listener is not leaked across repeated failed operations. | ||
@@ -170,4 +180,5 @@ ## Public API Overview | ||
| - `LifecycleHooks`: Convenience union covering `OnModuleInit`, `OnApplicationBootstrap`, `OnModuleDestroy`, and `OnApplicationShutdown`. | ||
| - `HealthModule.forRoot(options)`: Runtime-owned `/health` and `/ready` module facade whose readiness marker follows bootstrap and shutdown lifecycle transitions. | ||
| - `HealthModule.forRoot(options)`: Runtime-owned `/health` and `/ready` module facade whose readiness marker follows bootstrap and shutdown lifecycle transitions. It returns a `RuntimeHealthModule` so first-party runtime-aware packages can register `ReadinessCheck` functions without importing internal runtime seams. | ||
| - `createHealthModule(options)`: Deprecated compatibility helper for the same runtime health module contract; prefer `HealthModule.forRoot(...)` in application-facing module imports. | ||
| - `RuntimeHealthModule`: Module class contract returned by `HealthModule.forRoot(...)`, including `addReadinessCheck(...)`, `markReady()`, and `markStarting()`. | ||
| - `ReadinessCheck`: Function type used by runtime health modules. Checks receive the `/ready` request context and return a boolean or promise. | ||
@@ -180,2 +191,3 @@ - `defineModule(cls, metadata)`: Programmatic module definition helper. | ||
| - `createRequestAbortContext(...)`, `trackActiveRequestTransaction(...)`, `untrackActiveRequestTransaction(...)`: Request abort and active transaction helpers used by runtime-aware integrations. | ||
| - `UploadedFile`: Runtime-neutral multipart file descriptor whose in-memory `buffer` payload is a Web-standard `Uint8Array`. | ||
@@ -242,2 +254,3 @@ ## Platform-Specific Subpaths | ||
| - [@fluojs/http](../http): HTTP routing, controllers, and dispatcher. | ||
| - [@fluojs/serialization](../serialization): Decorator-aware shaping for framework-managed, uncommitted HTTP handler results. | ||
| - [@fluojs/platform-nodejs](../platform-nodejs): Official Node.js HTTP adapter. | ||
@@ -244,0 +257,0 @@ - [@fluojs/studio](../studio): Viewer, filtering, and rendering helpers for runtime-produced snapshots and diagnostic issues. |
386295
2.18%7608
0.33%257
5.33%+ Added
+ Added
- Removed
- Removed
Updated
Updated
Updated
Updated