@fluojs/runtime 1.0.0-beta.3 → 1.0.0-beta.4

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.
@@ -1,11 +1,17 @@
1
1
  import type { Scope } from '@fluojs/di';
2
2
  import type { CompiledModule, ModuleType } from '../types.js';
3
+ /**
4
+ * Describes the runtime diagnostics graph contract.
5
+ */
3
6
  export interface RuntimeDiagnosticsGraph {
4
7
  version: 1;
5
8
  rootModule: string;
6
9
  modules: RuntimeDiagnosticsModule[];
7
10
  relationships: RuntimeDiagnosticsRelationships;
8
11
  }
12
+ /**
13
+ * Describes the runtime diagnostics module contract.
14
+ */
9
15
  export interface RuntimeDiagnosticsModule {
10
16
  name: string;
11
17
  global: boolean;
@@ -14,12 +20,18 @@ export interface RuntimeDiagnosticsModule {
14
20
  providers: RuntimeDiagnosticsProvider[];
15
21
  exports: string[];
16
22
  }
23
+ /**
24
+ * Describes the runtime diagnostics provider contract.
25
+ */
17
26
  export interface RuntimeDiagnosticsProvider {
18
27
  token: string;
19
28
  type: 'class' | 'factory' | 'value' | 'existing';
20
29
  scope: Scope;
21
30
  multi: boolean;
22
31
  }
32
+ /**
33
+ * Describes the runtime diagnostics relationships contract.
34
+ */
23
35
  export interface RuntimeDiagnosticsRelationships {
24
36
  moduleImports: Array<{
25
37
  from: string;
@@ -41,16 +53,42 @@ export interface RuntimeDiagnosticsRelationships {
41
53
  module: string;
42
54
  }>;
43
55
  }
56
+ /**
57
+ * Describes the bootstrap timing phase contract.
58
+ */
44
59
  export interface BootstrapTimingPhase {
45
60
  durationMs: number;
46
61
  name: 'bootstrap_module' | 'register_runtime_tokens' | 'resolve_lifecycle_instances' | 'run_bootstrap_lifecycle' | 'create_dispatcher';
47
62
  }
63
+ /**
64
+ * Describes the bootstrap timing diagnostics contract.
65
+ */
48
66
  export interface BootstrapTimingDiagnostics {
49
67
  phases: BootstrapTimingPhase[];
50
68
  totalMs: number;
51
69
  version: 1;
52
70
  }
71
+ /**
72
+ * Create runtime diagnostics graph.
73
+ *
74
+ * @param modules The modules.
75
+ * @param rootModule The root module.
76
+ * @returns The create runtime diagnostics graph result.
77
+ */
53
78
  export declare function createRuntimeDiagnosticsGraph(modules: readonly CompiledModule[], rootModule: ModuleType): RuntimeDiagnosticsGraph;
79
+ /**
80
+ * Render runtime diagnostics mermaid.
81
+ *
82
+ * @param graph The graph.
83
+ * @returns The render runtime diagnostics mermaid result.
84
+ */
54
85
  export declare function renderRuntimeDiagnosticsMermaid(graph: RuntimeDiagnosticsGraph): string;
86
+ /**
87
+ * Create bootstrap timing diagnostics.
88
+ *
89
+ * @param phases The phases.
90
+ * @param totalMs The total ms.
91
+ * @returns The create bootstrap timing diagnostics result.
92
+ */
55
93
  export declare function createBootstrapTimingDiagnostics(phases: BootstrapTimingPhase[], totalMs: number): BootstrapTimingDiagnostics;
56
94
  //# sourceMappingURL=diagnostics.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../src/health/diagnostics.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAY,KAAK,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9D,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,CAAC,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,wBAAwB,EAAE,CAAC;IACpC,aAAa,EAAE,+BAA+B,CAAC;CAChD;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,SAAS,EAAE,0BAA0B,EAAE,CAAC;IACxC,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE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AAM,CAAC,CAAC;QACjD,KAAK,EAAE,KAAK,CAAC;QACb,KAAK,EAAE,OAAO,CAAC;KAChB,CAAC,CAAC;IACH,iBAAiB,EAAE,KAAK,CAAC;QACvB,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EACA,kBAAkB,GAClB,yBAAyB,GACzB,6BAA6B,GAC7B,yBAAyB,GACzB,mBAAmB,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,oBAAoB,EAAE,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,CAAC,CAAC;CACZ;AAiFD;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,EAAE,UAAU,EAAE,UAAU,GAAG,uBAAuB,CAkEjI;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,uBAAuB,GAAG,MAAM,CAoCtF;AAED;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,oBAAoB,EAAE,EAC9B,OAAO,EAAE,MAAM,GACd,0BAA0B,CAS5B"}
@@ -1,4 +1,29 @@
1
1
  import { getClassDiMetadata } from '@fluojs/core/internal';
2
+
3
+ /**
4
+ * Describes the runtime diagnostics graph contract.
5
+ */
6
+
7
+ /**
8
+ * Describes the runtime diagnostics module contract.
9
+ */
10
+
11
+ /**
12
+ * Describes the runtime diagnostics provider contract.
13
+ */
14
+
15
+ /**
16
+ * Describes the runtime diagnostics relationships contract.
17
+ */
18
+
19
+ /**
20
+ * Describes the bootstrap timing phase contract.
21
+ */
22
+
23
+ /**
24
+ * Describes the bootstrap timing diagnostics contract.
25
+ */
26
+
2
27
  function roundMs(value) {
3
28
  return Number(value.toFixed(3));
4
29
  }
@@ -59,6 +84,14 @@ function normalizeProvider(provider) {
59
84
  type: providerShape(provider)
60
85
  };
61
86
  }
87
+
88
+ /**
89
+ * Create runtime diagnostics graph.
90
+ *
91
+ * @param modules The modules.
92
+ * @param rootModule The root module.
93
+ * @returns The create runtime diagnostics graph result.
94
+ */
62
95
  export function createRuntimeDiagnosticsGraph(modules, rootModule) {
63
96
  const moduleDiagnostics = [];
64
97
  const moduleImports = [];
@@ -119,6 +152,13 @@ export function createRuntimeDiagnosticsGraph(modules, rootModule) {
119
152
  version: 1
120
153
  };
121
154
  }
155
+
156
+ /**
157
+ * Render runtime diagnostics mermaid.
158
+ *
159
+ * @param graph The graph.
160
+ * @returns The render runtime diagnostics mermaid result.
161
+ */
122
162
  export function renderRuntimeDiagnosticsMermaid(graph) {
123
163
  const lines = ['graph TD'];
124
164
  const nodeByModule = new Map();
@@ -143,6 +183,14 @@ export function renderRuntimeDiagnosticsMermaid(graph) {
143
183
  }
144
184
  return lines.join('\n');
145
185
  }
186
+
187
+ /**
188
+ * Create bootstrap timing diagnostics.
189
+ *
190
+ * @param phases The phases.
191
+ * @param totalMs The total ms.
192
+ * @returns The create bootstrap timing diagnostics result.
193
+ */
146
194
  export function createBootstrapTimingDiagnostics(phases, totalMs) {
147
195
  return {
148
196
  phases: phases.map(phase => ({
@@ -1,18 +1,39 @@
1
1
  import type { ModuleType } from '../types.js';
2
+ /**
3
+ * Describes the health status contract.
4
+ */
2
5
  export interface HealthStatus {
3
6
  status: 'ok' | 'unavailable';
4
7
  }
8
+ /**
9
+ * Describes the health check response contract.
10
+ */
5
11
  export interface HealthCheckResponse {
6
12
  body: unknown;
7
13
  statusCode?: number;
8
14
  }
15
+ /**
16
+ * Describes the readiness status contract.
17
+ */
9
18
  export interface ReadinessStatus {
10
19
  status: 'ready' | 'starting' | 'unavailable';
11
20
  }
21
+ /**
22
+ * Describes the health module options contract.
23
+ */
12
24
  export interface HealthModuleOptions {
13
25
  healthCheck?: (ctx: import('@fluojs/http').RequestContext) => HealthStatus | HealthCheckResponse | Promise<HealthStatus | HealthCheckResponse>;
14
26
  path?: string;
15
27
  }
28
+ /**
29
+ * Defines the readiness check type.
30
+ */
16
31
  export type ReadinessCheck = () => boolean | Promise<boolean>;
32
+ /**
33
+ * Create health module.
34
+ *
35
+ * @param options The options.
36
+ * @returns The create health module result.
37
+ */
17
38
  export declare function createHealthModule(options?: HealthModuleOptions): ModuleType;
18
39
  //# sourceMappingURL=health.d.ts.map
@@ -1 +1 @@
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,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,IAAI,GAAG,aAAa,CAAC;CAC9B;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,OAAO,GAAG,UAAU,GAAG,aAAa,CAAC;CAC9C;AAED,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,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAE9D,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,mBAAwB,GAAG,UAAU,CA0EhF"}
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,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAE9D;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,mBAAwB,GAAG,UAAU,CA0EhF"}
@@ -5,6 +5,33 @@ function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.descrip
5
5
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
6
6
  import { Controller, Get } from '@fluojs/http';
7
7
  import { defineModule } from '../bootstrap.js';
8
+
9
+ /**
10
+ * Describes the health status contract.
11
+ */
12
+
13
+ /**
14
+ * Describes the health check response contract.
15
+ */
16
+
17
+ /**
18
+ * Describes the readiness status contract.
19
+ */
20
+
21
+ /**
22
+ * Describes the health module options contract.
23
+ */
24
+
25
+ /**
26
+ * Defines the readiness check type.
27
+ */
28
+
29
+ /**
30
+ * Create health module.
31
+ *
32
+ * @param options The options.
33
+ * @returns The create health module result.
34
+ */
8
35
  export function createHealthModule(options = {}) {
9
36
  let _initProto, _initClass;
10
37
  const basePath = options.path ?? '';
@@ -1,3 +1,8 @@
1
1
  import type { ApplicationLogger } from '../types.js';
2
+ /**
3
+ * Create json application logger.
4
+ *
5
+ * @returns The create json application logger result.
6
+ */
2
7
  export declare function createJsonApplicationLogger(): ApplicationLogger;
3
8
  //# sourceMappingURL=json-logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"json-logger.d.ts","sourceRoot":"","sources":["../../src/logging/json-logger.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAqCrD,wBAAgB,2BAA2B,IAAI,iBAAiB,CAe/D"}
1
+ {"version":3,"file":"json-logger.d.ts","sourceRoot":"","sources":["../../src/logging/json-logger.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAqCrD;;;;GAIG;AACH,wBAAgB,2BAA2B,IAAI,iBAAiB,CAe/D"}
@@ -21,6 +21,12 @@ function buildEntry(level, message, context, error) {
21
21
  }
22
22
  return entry;
23
23
  }
24
+
25
+ /**
26
+ * Create json application logger.
27
+ *
28
+ * @returns The create json application logger result.
29
+ */
24
30
  export function createJsonApplicationLogger() {
25
31
  return {
26
32
  debug(message, context) {
@@ -1,3 +1,8 @@
1
1
  import type { ApplicationLogger } from '../types.js';
2
+ /**
3
+ * Create console application logger.
4
+ *
5
+ * @returns The create console application logger result.
6
+ */
2
7
  export declare function createConsoleApplicationLogger(): ApplicationLogger;
3
8
  //# sourceMappingURL=logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logging/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAuBrD,wBAAgB,8BAA8B,IAAI,iBAAiB,CAmBlE"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logging/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAuBrD;;;;GAIG;AACH,wBAAgB,8BAA8B,IAAI,iBAAiB,CAmBlE"}
@@ -15,6 +15,12 @@ function formatLog(level, context, message, color) {
15
15
  const contextLabel = colorize(`[${context}]`, BRIGHT_YELLOW, color);
16
16
  return `${prefix} ${pid} - ${timestamp} ${levelLabel} ${contextLabel} ${message}`;
17
17
  }
18
+
19
+ /**
20
+ * Create console application logger.
21
+ *
22
+ * @returns The create console application logger result.
23
+ */
18
24
  export function createConsoleApplicationLogger() {
19
25
  return {
20
26
  debug(message, context = 'fluo') {
@@ -1,7 +1,22 @@
1
1
  import type { ServerResponse } from 'node:http';
2
2
  import type { FrameworkResponseCompression } from '@fluojs/http';
3
3
  type Encoding = 'br' | 'gzip' | 'identity';
4
+ /**
5
+ * Create node response compression.
6
+ *
7
+ * @param response The response.
8
+ * @param acceptEncoding The accept encoding.
9
+ * @returns The create node response compression result.
10
+ */
4
11
  export declare function createNodeResponseCompression(response: ServerResponse, acceptEncoding: string | undefined): FrameworkResponseCompression | undefined;
12
+ /**
13
+ * Compress node response.
14
+ *
15
+ * @param response The response.
16
+ * @param body The body.
17
+ * @param encoding The encoding.
18
+ * @returns The compress node response result.
19
+ */
5
20
  export declare function compressNodeResponse(response: ServerResponse, body: Uint8Array, encoding: Exclude<Encoding, 'identity'>): Promise<void>;
6
21
  export {};
7
22
  //# sourceMappingURL=internal-node-compression.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"internal-node-compression.d.ts","sourceRoot":"","sources":["../../src/node/internal-node-compression.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,KAAK,EACV,4BAA4B,EAE7B,MAAM,cAAc,CAAC;AAiBtB,KAAK,QAAQ,GAAG,IAAI,GAAG,MAAM,GAAG,UAAU,CAAC;AAE3C,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,cAAc,EACxB,cAAc,EAAE,MAAM,GAAG,SAAS,GACjC,4BAA4B,GAAG,SAAS,CAqB1C;AAED,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,GACtC,OAAO,CAAC,IAAI,CAAC,CAcf"}
1
+ {"version":3,"file":"internal-node-compression.d.ts","sourceRoot":"","sources":["../../src/node/internal-node-compression.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,KAAK,EACV,4BAA4B,EAE7B,MAAM,cAAc,CAAC;AAiBtB,KAAK,QAAQ,GAAG,IAAI,GAAG,MAAM,GAAG,UAAU,CAAC;AAE3C;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,cAAc,EACxB,cAAc,EAAE,MAAM,GAAG,SAAS,GACjC,4BAA4B,GAAG,SAAS,CAqB1C;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,GACtC,OAAO,CAAC,IAAI,CAAC,CAcf"}
@@ -1,6 +1,13 @@
1
1
  import { createBrotliCompress, createGzip } from 'node:zlib';
2
2
  const COMPRESS_THRESHOLD = 1024;
3
3
  const SKIP_CONTENT_TYPES = new Set(['image/', 'audio/', 'video/', 'application/zip', 'application/gzip', 'application/x-bzip', 'application/x-bzip2', 'application/x-xz', 'application/zstd', 'application/octet-stream']);
4
+ /**
5
+ * Create node response compression.
6
+ *
7
+ * @param response The response.
8
+ * @param acceptEncoding The accept encoding.
9
+ * @returns The create node response compression result.
10
+ */
4
11
  export function createNodeResponseCompression(response, acceptEncoding) {
5
12
  if (!acceptEncoding) {
6
13
  return undefined;
@@ -19,6 +26,15 @@ export function createNodeResponseCompression(response, acceptEncoding) {
19
26
  }
20
27
  };
21
28
  }
29
+
30
+ /**
31
+ * Compress node response.
32
+ *
33
+ * @param response The response.
34
+ * @param body The body.
35
+ * @param encoding The encoding.
36
+ * @returns The compress node response result.
37
+ */
22
38
  export function compressNodeResponse(response, body, encoding) {
23
39
  const stream = encoding === 'br' ? createBrotliCompress() : createGzip();
24
40
  response.setHeader('Content-Encoding', encoding);
@@ -1 +1 @@
1
- {"version":3,"file":"internal-node-request.d.ts","sourceRoot":"","sources":["../../src/node/internal-node-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,eAAe,EACf,cAAc,EACf,MAAM,WAAW,CAAC;AAInB,OAAO,EAEL,wBAAwB,EACxB,KAAK,gBAAgB,EACtB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAEL,KAAK,gBAAgB,EAEtB,MAAM,iBAAiB,CAAC;AAUzB;;GAEG;AACH,qBAAa,mCAAoC,SAAQ,wBAAwB;IACnE,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,eAAe;IAIrD,eAAe,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;CAahD;AAED;;;;;;;;;GASG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,WAAW,EACnB,gBAAgB,CAAC,EAAE,gBAAgB,EACnC,WAAW,SAAkB,EAC7B,eAAe,UAAQ,GACtB,OAAO,CAAC,gBAAgB,CAAC,CAW3B;AAED;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,WAAW,EACnB,gBAAgB,CAAC,EAAE,gBAAgB,EACnC,WAAW,SAAkB,EAC7B,eAAe,UAAQ,GACtB,gBAAgB,CAsDlB;AAED;;;;;GAKG;AACH,wBAAsB,+BAA+B,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAG9F;AAyBD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,cAAc,GAAG,WAAW,CAezE;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,GAAG,SAAS,CAG5F"}
1
+ {"version":3,"file":"internal-node-request.d.ts","sourceRoot":"","sources":["../../src/node/internal-node-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,eAAe,EACf,cAAc,EACf,MAAM,WAAW,CAAC;AAInB,OAAO,EAEL,wBAAwB,EACxB,KAAK,gBAAgB,EACtB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAEL,KAAK,gBAAgB,EAEtB,MAAM,iBAAiB,CAAC;AAUzB;;GAEG;AACH,qBAAa,mCAAoC,SAAQ,wBAAwB;IACnE,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,eAAe;IAIrD,eAAe,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;CAahD;AAED;;;;;;;;;GASG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,WAAW,EACnB,gBAAgB,CAAC,EAAE,gBAAgB,EACnC,WAAW,SAAkB,EAC7B,eAAe,UAAQ,GACtB,OAAO,CAAC,gBAAgB,CAAC,CAW3B;AAED;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,WAAW,EACnB,gBAAgB,CAAC,EAAE,gBAAgB,EACnC,WAAW,SAAkB,EAC7B,eAAe,UAAQ,GACtB,gBAAgB,CA2DlB;AAoBD;;;;;GAKG;AACH,wBAAsB,+BAA+B,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAG9F;AAyBD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,cAAc,GAAG,WAAW,CAezE;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,GAAG,SAAS,CAG5F"}
@@ -73,6 +73,10 @@ export function createDeferredFrameworkRequest(request, signal, multipartOptions
73
73
  frameworkRequest.files = result.files;
74
74
  return;
75
75
  }
76
+ if (!hasNodeRequestBody(request)) {
77
+ frameworkRequest.body = undefined;
78
+ return;
79
+ }
76
80
  const bodyResult = await readRequestBody(request, headers['content-type'], maxBodySize, preserveRawBody);
77
81
  frameworkRequest.body = bodyResult.body;
78
82
  if (bodyResult.rawBody) {
@@ -97,6 +101,19 @@ export function createDeferredFrameworkRequest(request, signal, multipartOptions
97
101
  };
98
102
  return frameworkRequest;
99
103
  }
104
+ function hasNodeRequestBody(request) {
105
+ const contentLength = request.headers['content-length'];
106
+ const transferEncoding = request.headers['transfer-encoding'];
107
+ const primaryContentLength = Array.isArray(contentLength) ? contentLength[0] : contentLength;
108
+ if (transferEncoding !== undefined) {
109
+ return true;
110
+ }
111
+ if (primaryContentLength === undefined) {
112
+ return true;
113
+ }
114
+ const parsedContentLength = Number(primaryContentLength);
115
+ return !Number.isFinite(parsedContentLength) || parsedContentLength !== 0;
116
+ }
100
117
 
101
118
  /**
102
119
  * Materializes a deferred Node framework request body exactly once.
@@ -1,8 +1,28 @@
1
1
  import type { ServerResponse } from 'node:http';
2
2
  import { type FrameworkResponseCompression, type FrameworkResponse } from '@fluojs/http';
3
+ /**
4
+ * Defines the mutable framework response type.
5
+ */
3
6
  export type MutableFrameworkResponse = FrameworkResponse & {
4
7
  statusSet?: boolean;
5
8
  };
6
- export declare function createFrameworkResponse(response: ServerResponse, compression?: FrameworkResponseCompression): MutableFrameworkResponse;
9
+ type FrameworkResponseCompressionFactory = () => FrameworkResponseCompression | undefined;
10
+ /**
11
+ * Create framework response.
12
+ *
13
+ * @param response The response.
14
+ * @param compression The compression.
15
+ * @returns The create framework response result.
16
+ */
17
+ export declare function createFrameworkResponse(response: ServerResponse, compression?: FrameworkResponseCompression | FrameworkResponseCompressionFactory): MutableFrameworkResponse;
18
+ /**
19
+ * Write node adapter error response.
20
+ *
21
+ * @param error The error.
22
+ * @param response The response.
23
+ * @param requestId The request id.
24
+ * @returns The write node adapter error response result.
25
+ */
7
26
  export declare function writeNodeAdapterErrorResponse(error: unknown, response: FrameworkResponse, requestId?: string): Promise<void>;
27
+ export {};
8
28
  //# sourceMappingURL=internal-node-response.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"internal-node-response.d.ts","sourceRoot":"","sources":["../../src/node/internal-node-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAIL,KAAK,4BAA4B,EACjC,KAAK,iBAAiB,EAEvB,MAAM,cAAc,CAAC;AAEtB,MAAM,MAAM,wBAAwB,GAAG,iBAAiB,GAAG;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AA6CnF,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,cAAc,EACxB,WAAW,CAAC,EAAE,4BAA4B,GACzC,wBAAwB,CA+F1B;AAED,wBAAsB,6BAA6B,CACjD,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,iBAAiB,EAC3B,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAIf"}
1
+ {"version":3,"file":"internal-node-response.d.ts","sourceRoot":"","sources":["../../src/node/internal-node-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAIL,KAAK,4BAA4B,EACjC,KAAK,iBAAiB,EAEvB,MAAM,cAAc,CAAC;AAEtB;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,iBAAiB,GAAG;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEnF,KAAK,mCAAmC,GAAG,MAAM,4BAA4B,GAAG,SAAS,CAAC;AA6C1F;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,cAAc,EACxB,WAAW,CAAC,EAAE,4BAA4B,GAAG,mCAAmC,GAC/E,wBAAwB,CAqH1B;AAED;;;;;;;GAOG;AACH,wBAAsB,6BAA6B,CACjD,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,iBAAiB,EAC3B,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAIf"}
@@ -1,4 +1,9 @@
1
1
  import { createErrorResponse, HttpException, InternalServerErrorException } from '@fluojs/http';
2
+
3
+ /**
4
+ * Defines the mutable framework response type.
5
+ */
6
+
2
7
  function createFrameworkResponseStream(response) {
3
8
  return {
4
9
  close() {
@@ -39,7 +44,28 @@ function createFrameworkResponseStream(response) {
39
44
  }
40
45
  };
41
46
  }
47
+
48
+ /**
49
+ * Create framework response.
50
+ *
51
+ * @param response The response.
52
+ * @param compression The compression.
53
+ * @returns The create framework response result.
54
+ */
42
55
  export function createFrameworkResponse(response, compression) {
56
+ let activeStream;
57
+ const resolveCompression = (() => {
58
+ const factory = typeof compression === 'function' ? compression : () => compression;
59
+ let resolved = false;
60
+ let value;
61
+ return () => {
62
+ if (!resolved) {
63
+ value = factory();
64
+ resolved = true;
65
+ }
66
+ return value;
67
+ };
68
+ })();
43
69
  const mergeSetCookieHeader = (current, incoming) => {
44
70
  const nextValues = Array.isArray(incoming) ? incoming : [incoming];
45
71
  if (current === undefined) {
@@ -56,7 +82,10 @@ export function createFrameworkResponse(response, compression) {
56
82
  committed: response.headersSent || response.writableEnded,
57
83
  headers: {},
58
84
  raw: response,
59
- stream: createFrameworkResponseStream(response),
85
+ get stream() {
86
+ activeStream ??= createFrameworkResponseStream(response);
87
+ return activeStream;
88
+ },
60
89
  redirect(status, location) {
61
90
  this.setStatus(status);
62
91
  this.setHeader('Location', location);
@@ -74,9 +103,10 @@ export function createFrameworkResponse(response, compression) {
74
103
  }
75
104
  const contentType = response.getHeader('Content-Type');
76
105
  const payload = typeof serialized.payload === 'string' ? Buffer.from(serialized.payload, 'utf8') : serialized.payload;
77
- if (compression) {
106
+ const activeCompression = resolveCompression();
107
+ if (activeCompression) {
78
108
  this.committed = true;
79
- return Promise.resolve(compression.write(payload, {
109
+ return Promise.resolve(activeCompression.write(payload, {
80
110
  contentType
81
111
  })).then(handled => {
82
112
  if (!handled && !response.writableEnded) {
@@ -113,6 +143,15 @@ export function createFrameworkResponse(response, compression) {
113
143
  };
114
144
  return frameworkResponse;
115
145
  }
146
+
147
+ /**
148
+ * Write node adapter error response.
149
+ *
150
+ * @param error The error.
151
+ * @param response The response.
152
+ * @param requestId The request id.
153
+ * @returns The write node adapter error response result.
154
+ */
116
155
  export async function writeNodeAdapterErrorResponse(error, response, requestId) {
117
156
  const httpError = toHttpException(error);
118
157
  response.setStatus(httpError.status);
@@ -11,6 +11,9 @@ declare module '@fluojs/http' {
11
11
  rawBody?: Uint8Array;
12
12
  }
13
13
  }
14
+ /**
15
+ * Describes the node http adapter options contract.
16
+ */
14
17
  export interface NodeHttpAdapterOptions {
15
18
  host?: string;
16
19
  https?: HttpsServerOptions;
@@ -21,8 +24,17 @@ export interface NodeHttpAdapterOptions {
21
24
  retryLimit?: number;
22
25
  shutdownTimeoutMs?: number;
23
26
  }
27
+ /**
28
+ * Defines the node application signal type.
29
+ */
24
30
  export type NodeApplicationSignal = 'SIGINT' | 'SIGTERM';
31
+ /**
32
+ * Defines the cors input type.
33
+ */
25
34
  export type CorsInput = false | string | string[] | CorsOptions;
35
+ /**
36
+ * Describes the bootstrap node application options contract.
37
+ */
26
38
  export interface BootstrapNodeApplicationOptions extends Omit<CreateApplicationOptions, 'adapter' | 'logger' | 'middleware'> {
27
39
  compression?: boolean;
28
40
  cors?: CorsInput;
@@ -41,6 +53,9 @@ export interface BootstrapNodeApplicationOptions extends Omit<CreateApplicationO
41
53
  securityHeaders?: false | SecurityHeadersOptions;
42
54
  shutdownTimeoutMs?: number;
43
55
  }
56
+ /**
57
+ * Describes the run node application options contract.
58
+ */
44
59
  export interface RunNodeApplicationOptions extends BootstrapNodeApplicationOptions {
45
60
  forceExitTimeoutMs?: number;
46
61
  shutdownSignals?: false | readonly NodeApplicationSignal[];
@@ -50,6 +65,9 @@ interface NodeListenTarget {
50
65
  url: string;
51
66
  }
52
67
  type NodeServer = ReturnType<typeof createHttpServer> | ReturnType<typeof createHttpsServer>;
68
+ /**
69
+ * Represents the node http application adapter.
70
+ */
53
71
  export declare class NodeHttpApplicationAdapter implements HttpApplicationAdapter {
54
72
  private readonly port;
55
73
  private readonly host;
@@ -73,8 +91,30 @@ export declare class NodeHttpApplicationAdapter implements HttpApplicationAdapte
73
91
  close(): Promise<void>;
74
92
  private handleRequest;
75
93
  }
94
+ /**
95
+ * Create node http adapter.
96
+ *
97
+ * @param options The options.
98
+ * @param compression The compression.
99
+ * @param multipartOptions The multipart options.
100
+ * @returns The create node http adapter result.
101
+ */
76
102
  export declare function createNodeHttpAdapter(options?: NodeHttpAdapterOptions, compression?: boolean, multipartOptions?: MultipartOptions): HttpApplicationAdapter;
103
+ /**
104
+ * Bootstrap node application.
105
+ *
106
+ * @param rootModule The root module.
107
+ * @param options The options.
108
+ * @returns The bootstrap node application result.
109
+ */
77
110
  export declare function bootstrapNodeApplication(rootModule: ModuleType, options: BootstrapNodeApplicationOptions): Promise<Application>;
111
+ /**
112
+ * Run node application.
113
+ *
114
+ * @param rootModule The root module.
115
+ * @param options The options.
116
+ * @returns The run node application result.
117
+ */
78
118
  export declare function runNodeApplication(rootModule: ModuleType, options: RunNodeApplicationOptions): Promise<Application>;
79
119
  export { compressNodeResponse, createNodeResponseCompression, createNodeShutdownSignalRegistration, defaultNodeShutdownSignals, registerShutdownSignals, };
80
120
  //# sourceMappingURL=internal-node.d.ts.map
@@ -1 +1 @@
1
- {"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,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,EAAE,+BAA+B,GACvC,OAAO,CAAC,WAAW,CAAC,CAMtB;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,WAAW,CAAC,CAQtB;AAED,OAAO,EACL,oBAAoB,EACpB,6BAA6B,EAC7B,oCAAoC,EACpC,0BAA0B,EAC1B,uBAAuB,GACxB,CAAC"}
@@ -7,7 +7,32 @@ import { createDeferredFrameworkRequest, NodeRequestPayloadTooLargeException, cr
7
7
  import { createFrameworkResponse, writeNodeAdapterErrorResponse } from './internal-node-response.js';
8
8
  import { createNodeShutdownSignalRegistration, defaultNodeShutdownSignals, registerShutdownSignals } from './internal-node-shutdown.js';
9
9
  import { dispatchWithRequestResponseFactory } from '../adapters/request-response-factory.js';
10
+
11
+ /**
12
+ * Describes the node http adapter options contract.
13
+ */
14
+
15
+ /**
16
+ * Defines the node application signal type.
17
+ */
18
+
19
+ /**
20
+ * Defines the cors input type.
21
+ */
22
+
10
23
  const DEFAULT_SHUTDOWN_TIMEOUT_MS = 10_000;
24
+
25
+ /**
26
+ * Describes the bootstrap node application options contract.
27
+ */
28
+
29
+ /**
30
+ * Describes the run node application options contract.
31
+ */
32
+
33
+ /**
34
+ * Represents the node http application adapter.
35
+ */
11
36
  export class NodeHttpApplicationAdapter {
12
37
  server;
13
38
  dispatcher;
@@ -84,7 +109,7 @@ function createNodeRequestResponseFactory(compression, multipartOptions, maxBody
84
109
  return createRequestSignal(response);
85
110
  },
86
111
  createResponse(response, request) {
87
- return createFrameworkResponse(response, compression ? createNodeResponseCompression(response, request.headers['accept-encoding']) : undefined);
112
+ return createFrameworkResponse(response, compression ? () => createNodeResponseCompression(response, request.headers['accept-encoding']) : undefined);
88
113
  },
89
114
  resolveRequestId(request) {
90
115
  return resolveRequestIdFromHeaders(request.headers);
@@ -97,12 +122,37 @@ function createNodeRequestResponseFactory(compression, multipartOptions, maxBody
97
122
  }
98
123
  };
99
124
  }
125
+
126
+ /**
127
+ * Create node http adapter.
128
+ *
129
+ * @param options The options.
130
+ * @param compression The compression.
131
+ * @param multipartOptions The multipart options.
132
+ * @returns The create node http adapter result.
133
+ */
100
134
  export function createNodeHttpAdapter(options = {}, compression = false, multipartOptions) {
101
135
  return new NodeHttpApplicationAdapter(resolveNodePort(options.port), options.host, options.retryDelayMs, options.retryLimit, compression, options.https, multipartOptions, options.maxBodySize, options.rawBody, options.shutdownTimeoutMs);
102
136
  }
137
+
138
+ /**
139
+ * Bootstrap node application.
140
+ *
141
+ * @param rootModule The root module.
142
+ * @param options The options.
143
+ * @returns The bootstrap node application result.
144
+ */
103
145
  export async function bootstrapNodeApplication(rootModule, options) {
104
146
  return bootstrapHttpAdapterApplication(rootModule, options, createNodeHttpAdapter(options, options.compression ?? false, options.multipart));
105
147
  }
148
+
149
+ /**
150
+ * Run node application.
151
+ *
152
+ * @param rootModule The root module.
153
+ * @param options The options.
154
+ * @returns The run node application result.
155
+ */
106
156
  export async function runNodeApplication(rootModule, options) {
107
157
  const adapter = createNodeHttpAdapter(options, options.compression ?? false, options.multipart);
108
158
  return runHttpAdapterApplication(rootModule, {
@@ -1,17 +1,45 @@
1
+ /**
2
+ * Defines the request abort context type.
3
+ */
1
4
  export type RequestAbortContext = {
2
5
  controller: AbortController;
3
6
  cleanup(): void;
4
7
  signal: AbortSignal;
5
8
  };
9
+ /**
10
+ * Defines the active request transaction type.
11
+ */
6
12
  export type ActiveRequestTransaction = {
7
13
  abort(reason?: unknown): void;
8
14
  settled: Promise<void>;
9
15
  };
16
+ /**
17
+ * Defines the active request transaction handle type.
18
+ */
10
19
  export type ActiveRequestTransactionHandle = {
11
20
  active: ActiveRequestTransaction;
12
21
  settle(): void;
13
22
  };
23
+ /**
24
+ * Create request abort context.
25
+ *
26
+ * @param signal The signal.
27
+ * @returns The create request abort context result.
28
+ */
14
29
  export declare function createRequestAbortContext(signal?: AbortSignal): RequestAbortContext;
30
+ /**
31
+ * Track active request transaction.
32
+ *
33
+ * @param activeRequestTransactions The active request transactions.
34
+ * @param controller The controller.
35
+ * @returns The track active request transaction result.
36
+ */
15
37
  export declare function trackActiveRequestTransaction(activeRequestTransactions: Set<ActiveRequestTransaction>, controller: AbortController): ActiveRequestTransactionHandle;
38
+ /**
39
+ * Untrack active request transaction.
40
+ *
41
+ * @param activeRequestTransactions The active request transactions.
42
+ * @param handle The handle.
43
+ */
16
44
  export declare function untrackActiveRequestTransaction(activeRequestTransactions: Set<ActiveRequestTransaction>, handle: ActiveRequestTransactionHandle): void;
17
45
  //# sourceMappingURL=request-transaction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"request-transaction.d.ts","sourceRoot":"","sources":["../src/request-transaction.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG;IAChC,UAAU,EAAE,eAAe,CAAC;IAC5B,OAAO,IAAI,IAAI,CAAC;IAChB,MAAM,EAAE,WAAW,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9B,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,MAAM,EAAE,wBAAwB,CAAC;IACjC,MAAM,IAAI,IAAI,CAAC;CAChB,CAAC;AAEF,wBAAgB,yBAAyB,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,mBAAmB,CAiBnF;AAED,wBAAgB,6BAA6B,CAC3C,yBAAyB,EAAE,GAAG,CAAC,wBAAwB,CAAC,EACxD,UAAU,EAAE,eAAe,GAC1B,8BAA8B,CAgBhC;AAED,wBAAgB,+BAA+B,CAC7C,yBAAyB,EAAE,GAAG,CAAC,wBAAwB,CAAC,EACxD,MAAM,EAAE,8BAA8B,GACrC,IAAI,CAGN"}
1
+ {"version":3,"file":"request-transaction.d.ts","sourceRoot":"","sources":["../src/request-transaction.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,UAAU,EAAE,eAAe,CAAC;IAC5B,OAAO,IAAI,IAAI,CAAC;IAChB,MAAM,EAAE,WAAW,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9B,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,MAAM,EAAE,wBAAwB,CAAC;IACjC,MAAM,IAAI,IAAI,CAAC;CAChB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,mBAAmB,CAiBnF;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,yBAAyB,EAAE,GAAG,CAAC,wBAAwB,CAAC,EACxD,UAAU,EAAE,eAAe,GAC1B,8BAA8B,CAgBhC;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,yBAAyB,EAAE,GAAG,CAAC,wBAAwB,CAAC,EACxD,MAAM,EAAE,8BAA8B,GACrC,IAAI,CAGN"}
@@ -1,3 +1,21 @@
1
+ /**
2
+ * Defines the request abort context type.
3
+ */
4
+
5
+ /**
6
+ * Defines the active request transaction type.
7
+ */
8
+
9
+ /**
10
+ * Defines the active request transaction handle type.
11
+ */
12
+
13
+ /**
14
+ * Create request abort context.
15
+ *
16
+ * @param signal The signal.
17
+ * @returns The create request abort context result.
18
+ */
1
19
  export function createRequestAbortContext(signal) {
2
20
  const controller = new AbortController();
3
21
  const forwardAbort = () => controller.abort(signal?.reason);
@@ -16,6 +34,14 @@ export function createRequestAbortContext(signal) {
16
34
  signal: controller.signal
17
35
  };
18
36
  }
37
+
38
+ /**
39
+ * Track active request transaction.
40
+ *
41
+ * @param activeRequestTransactions The active request transactions.
42
+ * @param controller The controller.
43
+ * @returns The track active request transaction result.
44
+ */
19
45
  export function trackActiveRequestTransaction(activeRequestTransactions, controller) {
20
46
  let settle;
21
47
  const settled = new Promise(resolve => {
@@ -33,6 +59,13 @@ export function trackActiveRequestTransaction(activeRequestTransactions, control
33
59
  settle
34
60
  };
35
61
  }
62
+
63
+ /**
64
+ * Untrack active request transaction.
65
+ *
66
+ * @param activeRequestTransactions The active request transactions.
67
+ * @param handle The handle.
68
+ */
36
69
  export function untrackActiveRequestTransaction(activeRequestTransactions, handle) {
37
70
  activeRequestTransactions.delete(handle.active);
38
71
  handle.settle();
package/dist/web.d.ts.map CHANGED
@@ -1 +1 @@
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;AAEtB,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,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,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,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,oBAA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M,WAAW,yBAA0B,SAAQ,sCAAsC;IACvF,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,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;AAgMhD;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,GAAE,sCAA2C,GACnD,sBAAsB,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,EAAE,oBAAoB,CAAC,CA6BhF;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,UAAU,EACV,yBAAiG,EACjG,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"}
package/dist/web.js CHANGED
@@ -93,12 +93,12 @@ class MutableWebFrameworkResponse {
93
93
  statusCode;
94
94
  statusSet;
95
95
  finalizedResponse;
96
- responseStream = new WebResponseStream(() => {
97
- this.streamActive = true;
98
- });
96
+ responseStream;
99
97
  responseBody;
100
98
  streamActive = false;
101
- stream = this.responseStream;
99
+ get stream() {
100
+ return this.getOrCreateResponseStream();
101
+ }
102
102
  redirect(status, location) {
103
103
  this.setStatus(status);
104
104
  this.setHeader('Location', location);
@@ -135,12 +135,18 @@ class MutableWebFrameworkResponse {
135
135
  status: this.statusCode ?? 200
136
136
  };
137
137
  const responseBody = this.responseBody instanceof Uint8Array ? this.responseBody.slice().buffer : this.responseBody;
138
- this.finalizedResponse = this.streamActive ? new Response(this.responseStream.readable, init) : new Response(responseBody ?? '', init);
138
+ this.finalizedResponse = this.streamActive ? new Response(this.getOrCreateResponseStream().readable, init) : new Response(responseBody ?? '', init);
139
139
  this.raw = this.finalizedResponse;
140
140
  this.committed = true;
141
141
  }
142
142
  return this.finalizedResponse;
143
143
  }
144
+ getOrCreateResponseStream() {
145
+ this.responseStream ??= new WebResponseStream(() => {
146
+ this.streamActive = true;
147
+ });
148
+ return this.responseStream;
149
+ }
144
150
  }
145
151
 
146
152
  /**
@@ -249,6 +255,11 @@ function createDeferredWebFrameworkRequest(request, signal, multipartOptions, ma
249
255
  frameworkRequest.files = result.files;
250
256
  return;
251
257
  }
258
+ validateWebRequestContentLength(request, maxBodySize);
259
+ if (!request.body) {
260
+ frameworkRequest.body = undefined;
261
+ return;
262
+ }
252
263
  const bodyResult = await readWebRequestBody(request.clone(), contentType, maxBodySize, preserveRawBody);
253
264
  frameworkRequest.body = bodyResult.body;
254
265
  if (bodyResult.rawBody) {
@@ -275,6 +286,16 @@ function createDeferredWebFrameworkRequest(request, signal, multipartOptions, ma
275
286
  };
276
287
  return frameworkRequest;
277
288
  }
289
+ function validateWebRequestContentLength(request, maxBodySize) {
290
+ const contentLength = request.headers.get('content-length');
291
+ if (contentLength === null) {
292
+ return;
293
+ }
294
+ const parsedContentLength = Number(contentLength);
295
+ if (Number.isFinite(parsedContentLength) && parsedContentLength > maxBodySize) {
296
+ throw new PayloadTooLargeException(REQUEST_BODY_LIMIT_MESSAGE);
297
+ }
298
+ }
278
299
 
279
300
  /**
280
301
  * Materializes a deferred Web framework request body exactly once.
@@ -347,13 +368,7 @@ function parseCookieHeader(cookieHeader) {
347
368
  }));
348
369
  }
349
370
  async function readWebRequestBody(request, contentType, maxBodySize = DEFAULT_MAX_BODY_SIZE, preserveRawBody = false) {
350
- const contentLength = request.headers.get('content-length');
351
- if (contentLength !== null) {
352
- const parsedContentLength = Number(contentLength);
353
- if (Number.isFinite(parsedContentLength) && parsedContentLength > maxBodySize) {
354
- throw new PayloadTooLargeException(REQUEST_BODY_LIMIT_MESSAGE);
355
- }
356
- }
371
+ validateWebRequestContentLength(request, maxBodySize);
357
372
  if (!request.body) {
358
373
  return {
359
374
  body: undefined
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "module-graph",
10
10
  "orchestration"
11
11
  ],
12
- "version": "1.0.0-beta.3",
12
+ "version": "1.0.0-beta.4",
13
13
  "private": false,
14
14
  "license": "MIT",
15
15
  "repository": {
@@ -69,8 +69,8 @@
69
69
  "dependencies": {
70
70
  "@fluojs/config": "^1.0.0-beta.3",
71
71
  "@fluojs/core": "^1.0.0-beta.2",
72
- "@fluojs/di": "^1.0.0-beta.3",
73
- "@fluojs/http": "^1.0.0-beta.2"
72
+ "@fluojs/di": "^1.0.0-beta.4",
73
+ "@fluojs/http": "^1.0.0-beta.3"
74
74
  },
75
75
  "devDependencies": {
76
76
  "vitest": "^3.2.4",