@gravito/core 3.0.0 → 3.0.1
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/README.md +64 -25
- package/dist/Application.d.ts +2 -9
- package/dist/Container.d.ts +18 -1
- package/dist/GravitoServer.d.ts +8 -8
- package/dist/HookManager.d.ts +36 -34
- package/dist/PlanetCore.d.ts +48 -0
- package/dist/Route.d.ts +5 -0
- package/dist/Router.d.ts +14 -1
- package/dist/adapters/bun/BunContext.d.ts +1 -1
- package/dist/adapters/bun/BunNativeAdapter.d.ts +11 -1
- package/dist/adapters/bun/FastPathRegistry.d.ts +31 -0
- package/dist/adapters/bun/RadixNode.d.ts +4 -3
- package/dist/adapters/bun/RadixRouter.d.ts +2 -2
- package/dist/adapters/bun/types.d.ts +7 -0
- package/dist/adapters/types.d.ts +20 -0
- package/dist/compat/async-local-storage.d.ts +5 -1
- package/dist/compat/async-local-storage.js.map +2 -2
- package/dist/compat/crypto.d.ts +6 -1
- package/dist/compat/crypto.js.map +2 -2
- package/dist/engine/AOTRouter.d.ts +1 -1
- package/dist/engine/FastContext.d.ts +4 -4
- package/dist/engine/MinimalContext.d.ts +3 -3
- package/dist/engine/index.js +29 -8
- package/dist/engine/index.js.map +10 -10
- package/dist/engine/types.d.ts +5 -5
- package/dist/events/MessageQueueBridge.d.ts +2 -1
- package/dist/events/observability/EventMetrics.d.ts +1 -2
- package/dist/events/observability/ObservableHookManager.d.ts +1 -1
- package/dist/exceptions/AuthException.d.ts +11 -2
- package/dist/exceptions/AuthenticationException.d.ts +7 -1
- package/dist/exceptions/ContainerBindingCollisionException.d.ts +10 -0
- package/dist/exceptions/MiddlewareDriftException.d.ts +10 -0
- package/dist/exceptions/index.d.ts +3 -1
- package/dist/ffi/NativeAccelerator.js.map +3 -3
- package/dist/ffi/NativeHasher.d.ts +14 -0
- package/dist/ffi/NativeHasher.js +24 -1
- package/dist/ffi/NativeHasher.js.map +4 -4
- package/dist/ffi/cbor-fallback.js.map +1 -1
- package/dist/ffi/hash-fallback.d.ts +15 -0
- package/dist/ffi/hash-fallback.js +12 -1
- package/dist/ffi/hash-fallback.js.map +3 -3
- package/dist/ffi/types.d.ts +13 -0
- package/dist/ffi/types.js.map +1 -1
- package/dist/hooks/types.d.ts +7 -3
- package/dist/http/types.d.ts +2 -2
- package/dist/index.browser.d.ts +5 -5
- package/dist/index.browser.js +138 -17
- package/dist/index.browser.js.map +44 -42
- package/dist/index.d.ts +17 -7
- package/dist/index.js +588 -295
- package/dist/index.js.map +81 -77
- package/dist/runtime/NativeOrbitDetector.d.ts +59 -0
- package/dist/runtime/index.browser.d.ts +1 -1
- package/dist/runtime/index.d.ts +7 -0
- package/dist/runtime.d.ts +1 -1
- package/dist/testing/HttpTester.d.ts +4 -4
- package/dist/testing/TestResponse.d.ts +4 -4
- package/dist/types.d.ts +3 -3
- package/package.json +4 -3
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/compat/async-local-storage.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * Universal AsyncLocalStorage wrapper.\n * Automatically switches between node:async_hooks and a browser mock.\n */\n\nlet AsyncLocalStorageClass:
|
|
5
|
+
"/**\n * Universal AsyncLocalStorage wrapper.\n * Automatically switches between node:async_hooks and a browser mock.\n */\n\nlet AsyncLocalStorageClass: unknown\n\n// Try to load Node.js AsyncLocalStorage\nconst tryGetNodeAsyncHooks = () => {\n try {\n if (\n typeof window === 'undefined' &&\n typeof process !== 'undefined' &&\n !(process as unknown as { browser?: boolean }).browser\n ) {\n // Try direct import for Bun/Node.js ESM compatibility\n try {\n const module = require('node:async_hooks')\n return module.AsyncLocalStorage\n } catch (_e1) {\n // Fallback to eval for CommonJS require hiding\n try {\n // biome-ignore lint/security/noGlobalEval: specialized case for hiding node built-ins\n return eval('require')('node:async_hooks').AsyncLocalStorage\n } catch (_e2) {\n return null\n }\n }\n }\n } catch (_e) {\n return null\n }\n}\n\nAsyncLocalStorageClass = tryGetNodeAsyncHooks()\n\nif (!AsyncLocalStorageClass) {\n /**\n * Browser-safe AsyncLocalStorage mock.\n * Note: This mock only works with synchronous functions.\n * For proper async support, ensure Node.js AsyncLocalStorage is available.\n */\n AsyncLocalStorageClass = class AsyncLocalStorage<T> {\n private store: T | undefined\n\n run<R>(store: T, fn: () => R): R {\n const prev = this.store\n this.store = store\n try {\n return fn()\n } finally {\n this.store = prev\n }\n }\n\n getStore(): T | undefined {\n return this.store\n }\n\n disable(): void {\n this.store = undefined\n }\n }\n}\n\nexport const AsyncLocalStorage = AsyncLocalStorageClass as { new <T>(): { run<R>(store: T, fn: () => R): R; getStore(): T | undefined; disable(): void } }\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAI;AAGJ,IAAM,uBAAuB,MAAM;AAAA,EACjC,IAAI;AAAA,IACF,IACE,OAAO,WAAW,eAClB,OAAO,YAAY,eACnB,MACA;AAAA,MAEA,IAAI;AAAA,QACF,MAAM;AAAA,QACN,OAAO,OAAO;AAAA,QACd,OAAO,KAAK;AAAA,QAEZ,IAAI;AAAA,UAEF,OAAO,KAAK,SAAS,EAAE,kBAAkB,EAAE;AAAA,UAC3C,OAAO,KAAK;AAAA,UACZ,OAAO;AAAA;AAAA;AAAA,IAGb;AAAA,IACA,OAAO,IAAI;AAAA,IACX,OAAO;AAAA;AAAA;AAIX,yBAAyB,qBAAqB;AAE9C,IAAI,CAAC,wBAAwB;AAAA,EAM3B,yBAAyB,MAAM,kBAAqB;AAAA,IAC1C;AAAA,IAER,GAAM,CAAC,OAAU,IAAgB;AAAA,MAC/B,MAAM,OAAO,KAAK;AAAA,MAClB,KAAK,QAAQ;AAAA,MACb,IAAI;AAAA,QACF,OAAO,GAAG;AAAA,gBACV;AAAA,QACA,KAAK,QAAQ;AAAA;AAAA;AAAA,IAIjB,QAAQ,GAAkB;AAAA,MACxB,OAAO,KAAK;AAAA;AAAA,IAGd,OAAO,GAAS;AAAA,MACd,KAAK,QAAQ;AAAA;AAAA,EAEjB;AACF;
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAI;AAGJ,IAAM,uBAAuB,MAAM;AAAA,EACjC,IAAI;AAAA,IACF,IACE,OAAO,WAAW,eAClB,OAAO,YAAY,eACnB,MACA;AAAA,MAEA,IAAI;AAAA,QACF,MAAM;AAAA,QACN,OAAO,OAAO;AAAA,QACd,OAAO,KAAK;AAAA,QAEZ,IAAI;AAAA,UAEF,OAAO,KAAK,SAAS,EAAE,kBAAkB,EAAE;AAAA,UAC3C,OAAO,KAAK;AAAA,UACZ,OAAO;AAAA;AAAA;AAAA,IAGb;AAAA,IACA,OAAO,IAAI;AAAA,IACX,OAAO;AAAA;AAAA;AAIX,yBAAyB,qBAAqB;AAE9C,IAAI,CAAC,wBAAwB;AAAA,EAM3B,yBAAyB,MAAM,kBAAqB;AAAA,IAC1C;AAAA,IAER,GAAM,CAAC,OAAU,IAAgB;AAAA,MAC/B,MAAM,OAAO,KAAK;AAAA,MAClB,KAAK,QAAQ;AAAA,MACb,IAAI;AAAA,QACF,OAAO,GAAG;AAAA,gBACV;AAAA,QACA,KAAK,QAAQ;AAAA;AAAA;AAAA,IAIjB,QAAQ,GAAkB;AAAA,MACxB,OAAO,KAAK;AAAA;AAAA,IAGd,OAAO,GAAS;AAAA,MACd,KAAK,QAAQ;AAAA;AAAA,EAEjB;AACF;AAEO,IAAM,oBAAoB;",
|
|
8
8
|
"debugId": "AEC51513D62BFF6864756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/dist/compat/crypto.d.ts
CHANGED
|
@@ -2,5 +2,10 @@
|
|
|
2
2
|
* Universal Crypto wrapper.
|
|
3
3
|
* Automatically switches between node:crypto and globalThis.crypto.
|
|
4
4
|
*/
|
|
5
|
+
export interface RandomBytesResult extends Iterable<number> {
|
|
6
|
+
readonly length: number;
|
|
7
|
+
toString(encoding: string): string;
|
|
8
|
+
[index: number]: number | undefined;
|
|
9
|
+
}
|
|
5
10
|
export declare const randomUUID: () => string;
|
|
6
|
-
export declare const randomBytes: (size: number) =>
|
|
11
|
+
export declare const randomBytes: (size: number) => RandomBytesResult;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/compat/crypto.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * Universal Crypto wrapper.\n * Automatically switches between node:crypto and globalThis.crypto.\n */\n\nlet randomUUIDFn: () => string\nlet randomBytesFn: (size: number) =>
|
|
5
|
+
"/**\n * Universal Crypto wrapper.\n * Automatically switches between node:crypto and globalThis.crypto.\n */\n\nexport interface RandomBytesResult extends Iterable<number> {\n readonly length: number\n toString(encoding: string): string\n [index: number]: number | undefined\n}\n\nlet randomUUIDFn: () => string\nlet randomBytesFn: (size: number) => RandomBytesResult\n\nconst tryGetNodeCrypto = () => {\n try {\n if (\n typeof window === 'undefined' &&\n typeof process !== 'undefined' &&\n !(process as unknown as { browser?: boolean }).browser\n ) {\n // biome-ignore lint/security/noGlobalEval: specialized case for hiding node built-ins\n return eval('require')('node:crypto')\n }\n } catch (_e) {\n return null\n }\n}\n\nconst nodeCrypto = tryGetNodeCrypto()\n\nif (nodeCrypto) {\n randomUUIDFn = nodeCrypto.randomUUID\n randomBytesFn = nodeCrypto.randomBytes\n} else {\n // Browser implementations\n randomUUIDFn = () => {\n if (typeof globalThis.crypto?.randomUUID === 'function') {\n return globalThis.crypto.randomUUID()\n }\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0\n const v = c === 'x' ? r : (r & 0x3) | 0x8\n return v.toString(16)\n })\n }\n\n randomBytesFn = (size: number) => {\n const bytes = new Uint8Array(size)\n if (typeof globalThis.crypto?.getRandomValues === 'function') {\n globalThis.crypto.getRandomValues(bytes)\n } else {\n for (let i = 0; i < size; i++) {\n bytes[i] = Math.floor(Math.random() * 256)\n }\n }\n // Return a Buffer-like object\n return {\n ...Array.from(bytes),\n length: size,\n [Symbol.iterator]: () => bytes[Symbol.iterator](),\n toString: (encoding: string) => {\n if (encoding === 'base64') {\n let binary = ''\n for (let i = 0; i < bytes.byteLength; i++) {\n binary += String.fromCharCode(bytes[i])\n }\n return btoa(binary)\n }\n if (encoding === 'hex') {\n return Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('')\n }\n return ''\n },\n }\n }\n}\n\nexport const randomUUID = randomUUIDFn\nexport const randomBytes = randomBytesFn\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,IAAI;AACJ,IAAI;AAEJ,IAAM,mBAAmB,MAAM;AAAA,EAC7B,IAAI;AAAA,IACF,IACE,OAAO,WAAW,eAClB,OAAO,YAAY,eACnB,MACA;AAAA,MAEA,OAAO,KAAK,SAAS,EAAE,aAAa;AAAA,IACtC;AAAA,IACA,OAAO,IAAI;AAAA,IACX,OAAO;AAAA;AAAA;AAIX,IAAM,aAAa,iBAAiB;AAEpC,IAAI,YAAY;AAAA,EACd,eAAe,WAAW;AAAA,EAC1B,gBAAgB,WAAW;AAC7B,EAAO;AAAA,EAEL,eAAe,MAAM;AAAA,IACnB,IAAI,OAAO,WAAW,QAAQ,eAAe,YAAY;AAAA,MACvD,OAAO,WAAW,OAAO,WAAW;AAAA,IACtC;AAAA,IACA,OAAO,uCAAuC,QAAQ,SAAS,CAAC,MAAM;AAAA,MACpE,MAAM,IAAK,KAAK,OAAO,IAAI,KAAM;AAAA,MACjC,MAAM,IAAI,MAAM,MAAM,IAAK,IAAI,IAAO;AAAA,MACtC,OAAO,EAAE,SAAS,EAAE;AAAA,KACrB;AAAA;AAAA,EAGH,gBAAgB,CAAC,SAAiB;AAAA,IAChC,MAAM,QAAQ,IAAI,WAAW,IAAI;AAAA,IACjC,IAAI,OAAO,WAAW,QAAQ,oBAAoB,YAAY;AAAA,MAC5D,WAAW,OAAO,gBAAgB,KAAK;AAAA,IACzC,EAAO;AAAA,MACL,SAAS,IAAI,EAAG,IAAI,MAAM,KAAK;AAAA,QAC7B,MAAM,KAAK,KAAK,MAAM,KAAK,OAAO,IAAI,GAAG;AAAA,MAC3C;AAAA;AAAA,IAGF,OAAO;AAAA,SACF,MAAM,KAAK,KAAK;AAAA,MACnB,QAAQ;AAAA,OACP,OAAO,WAAW,MAAM,MAAM,OAAO,UAAU;AAAA,MAChD,UAAU,CAAC,aAAqB;AAAA,QAC9B,IAAI,aAAa,UAAU;AAAA,UACzB,IAAI,SAAS;AAAA,UACb,SAAS,IAAI,EAAG,IAAI,MAAM,YAAY,KAAK;AAAA,YACzC,UAAU,OAAO,aAAa,MAAM,EAAE;AAAA,UACxC;AAAA,UACA,OAAO,KAAK,MAAM;AAAA,QACpB;AAAA,QACA,IAAI,aAAa,OAAO;AAAA,UACtB,OAAO,MAAM,KAAK,KAAK,EACpB,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAC1C,KAAK,EAAE;AAAA,QACZ;AAAA,QACA,OAAO;AAAA;AAAA,IAEX;AAAA;AAAA;AAIG,IAAM,aAAa;AACnB,IAAM,cAAc;",
|
|
8
8
|
"debugId": "90A5E907AAB9EDB264756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -110,7 +110,7 @@ export declare class AOTRouter {
|
|
|
110
110
|
* @param onMatch - Factory to wrap handler and middleware into a Bun-compatible function
|
|
111
111
|
* @returns Record of path -> Handler (Bun-compatible)
|
|
112
112
|
*/
|
|
113
|
-
getNativeRoutes(onMatch: (handler: Handler, middleware: Middleware[], path: string) => (req: Request) => Response | Promise<Response>): Record<string,
|
|
113
|
+
getNativeRoutes(onMatch: (handler: Handler, middleware: Middleware[], path: string) => (req: Request) => Response | Promise<Response>): Record<string, (req: Request) => Response | Promise<Response>>;
|
|
114
114
|
/**
|
|
115
115
|
* Check if a path is static (no parameters or wildcards)
|
|
116
116
|
*/
|
|
@@ -100,12 +100,12 @@ export declare class FastContext implements IFastContext {
|
|
|
100
100
|
* Utilizing Bun's native ArrayBufferSink for zero-allocation construction.
|
|
101
101
|
*/
|
|
102
102
|
binary(data: Uint8Array | ArrayBuffer, status?: number): Response;
|
|
103
|
-
stream(stream:
|
|
103
|
+
stream(stream: BodyInit, status?: number): Response;
|
|
104
104
|
notFound(message?: string): Response;
|
|
105
105
|
forbidden(message?: string): Response;
|
|
106
106
|
unauthorized(message?: string): Response;
|
|
107
107
|
badRequest(message?: string): Response;
|
|
108
|
-
forward(target: string, _options?:
|
|
108
|
+
forward(target: string, _options?: Record<string, unknown>): Promise<Response>;
|
|
109
109
|
header(name: string): string | undefined;
|
|
110
110
|
header(name: string, value: string): void;
|
|
111
111
|
/**
|
|
@@ -118,7 +118,7 @@ export declare class FastContext implements IFastContext {
|
|
|
118
118
|
status(_code: number): void;
|
|
119
119
|
private _store;
|
|
120
120
|
get<T>(key: string): T;
|
|
121
|
-
set(key: string, value:
|
|
121
|
+
set(key: string, value: unknown): void;
|
|
122
122
|
/**
|
|
123
123
|
* Get the request-scoped service manager for this request.
|
|
124
124
|
*
|
|
@@ -135,7 +135,7 @@ export declare class FastContext implements IFastContext {
|
|
|
135
135
|
* @returns The cached or newly created service instance.
|
|
136
136
|
*/
|
|
137
137
|
scoped<T>(key: string | symbol, factory: () => T): T;
|
|
138
|
-
route: (name: string, params?:
|
|
138
|
+
route: (name: string, params?: Record<string, string | number>, query?: Record<string, string | number | boolean | null | undefined>) => string;
|
|
139
139
|
get native(): this;
|
|
140
140
|
}
|
|
141
141
|
export {};
|
|
@@ -75,10 +75,10 @@ export declare class MinimalContext implements IFastContext {
|
|
|
75
75
|
forbidden(message?: string): Response;
|
|
76
76
|
unauthorized(message?: string): Response;
|
|
77
77
|
badRequest(message?: string): Response;
|
|
78
|
-
forward(target: string, _options?:
|
|
78
|
+
forward(target: string, _options?: Record<string, unknown>): Promise<Response>;
|
|
79
79
|
escape(html: string): string;
|
|
80
80
|
get<T>(_key: string): T;
|
|
81
|
-
set(_key: string, _value:
|
|
81
|
+
set(_key: string, _value: unknown): void;
|
|
82
82
|
/**
|
|
83
83
|
* Get the request-scoped service manager for this request.
|
|
84
84
|
*
|
|
@@ -94,7 +94,7 @@ export declare class MinimalContext implements IFastContext {
|
|
|
94
94
|
* @returns The cached or newly created service instance.
|
|
95
95
|
*/
|
|
96
96
|
scoped<T>(key: string | symbol, factory: () => T): T;
|
|
97
|
-
route: (name: string, params?:
|
|
97
|
+
route: (name: string, params?: Record<string, string | number>, query?: Record<string, string | number | boolean | null | undefined>) => string;
|
|
98
98
|
get native(): this;
|
|
99
99
|
init(_request: Request, _params?: Record<string, string>, _path?: string): this;
|
|
100
100
|
reset(): void;
|
package/dist/engine/index.js
CHANGED
|
@@ -72,6 +72,7 @@ class RadixNode {
|
|
|
72
72
|
paramChild = null;
|
|
73
73
|
wildcardChild = null;
|
|
74
74
|
handlers = new Map;
|
|
75
|
+
options = new Map;
|
|
75
76
|
paramName = null;
|
|
76
77
|
regex = null;
|
|
77
78
|
constructor(segment = "", type = 0 /* STATIC */) {
|
|
@@ -85,13 +86,15 @@ class RadixNode {
|
|
|
85
86
|
children: Array.from(this.children.entries()).map(([k, v]) => [k, v.toJSON()]),
|
|
86
87
|
paramChild: this.paramChild?.toJSON() || null,
|
|
87
88
|
wildcardChild: this.wildcardChild?.toJSON() || null,
|
|
89
|
+
handlers: Array.from(this.handlers.entries()),
|
|
90
|
+
options: Array.from(this.options.entries()),
|
|
88
91
|
paramName: this.paramName,
|
|
89
92
|
regex: this.regex ? this.regex.source : null
|
|
90
93
|
};
|
|
91
94
|
}
|
|
92
95
|
static fromJSON(json) {
|
|
93
96
|
const node = new RadixNode(json.segment, json.type);
|
|
94
|
-
node.paramName = json.paramName;
|
|
97
|
+
node.paramName = json.paramName ?? null;
|
|
95
98
|
if (json.regex) {
|
|
96
99
|
node.regex = new RegExp(json.regex);
|
|
97
100
|
}
|
|
@@ -106,6 +109,16 @@ class RadixNode {
|
|
|
106
109
|
if (json.wildcardChild) {
|
|
107
110
|
node.wildcardChild = RadixNode.fromJSON(json.wildcardChild);
|
|
108
111
|
}
|
|
112
|
+
if (json.handlers) {
|
|
113
|
+
for (const [method, handlers] of json.handlers) {
|
|
114
|
+
node.handlers.set(method, handlers);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (json.options) {
|
|
118
|
+
for (const [method, options] of json.options) {
|
|
119
|
+
node.options.set(method, options);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
109
122
|
return node;
|
|
110
123
|
}
|
|
111
124
|
}
|
|
@@ -141,7 +154,7 @@ class RadixRouter {
|
|
|
141
154
|
where(param, regex) {
|
|
142
155
|
this.globalConstraints.set(param, regex);
|
|
143
156
|
}
|
|
144
|
-
add(method, path, handlers) {
|
|
157
|
+
add(method, path, handlers, options) {
|
|
145
158
|
let node = this.root;
|
|
146
159
|
const segments = this.splitPath(path);
|
|
147
160
|
for (let i = 0;i < segments.length; i++) {
|
|
@@ -171,7 +184,11 @@ class RadixRouter {
|
|
|
171
184
|
node = node.children.get(segment);
|
|
172
185
|
}
|
|
173
186
|
}
|
|
174
|
-
|
|
187
|
+
const normalizedMethod = method.toLowerCase();
|
|
188
|
+
node.handlers.set(normalizedMethod, handlers);
|
|
189
|
+
if (options) {
|
|
190
|
+
node.options.set(normalizedMethod, options);
|
|
191
|
+
}
|
|
175
192
|
this.routeCache.clear();
|
|
176
193
|
}
|
|
177
194
|
match(method, path) {
|
|
@@ -179,7 +196,7 @@ class RadixRouter {
|
|
|
179
196
|
if (path === "/" || path === "") {
|
|
180
197
|
const handlers = this.root.handlers.get(normalizedMethod);
|
|
181
198
|
if (handlers) {
|
|
182
|
-
return { handlers, params: {} };
|
|
199
|
+
return { handlers, params: {}, options: this.root.options.get(normalizedMethod) };
|
|
183
200
|
}
|
|
184
201
|
return null;
|
|
185
202
|
}
|
|
@@ -196,11 +213,13 @@ class RadixRouter {
|
|
|
196
213
|
matchRecursive(node, segments, depth, params, method) {
|
|
197
214
|
if (depth >= segments.length) {
|
|
198
215
|
let handlers = node.handlers.get(method);
|
|
216
|
+
let options = node.options.get(method);
|
|
199
217
|
if (!handlers) {
|
|
200
218
|
handlers = node.handlers.get("all");
|
|
219
|
+
options = node.options.get("all");
|
|
201
220
|
}
|
|
202
221
|
if (handlers) {
|
|
203
|
-
return { handlers, params };
|
|
222
|
+
return { handlers, params, options };
|
|
204
223
|
}
|
|
205
224
|
return null;
|
|
206
225
|
}
|
|
@@ -227,11 +246,13 @@ class RadixRouter {
|
|
|
227
246
|
}
|
|
228
247
|
if (node.wildcardChild) {
|
|
229
248
|
let handlers = node.wildcardChild.handlers.get(method);
|
|
249
|
+
let options = node.wildcardChild.options.get(method);
|
|
230
250
|
if (!handlers) {
|
|
231
251
|
handlers = node.wildcardChild.handlers.get("all");
|
|
252
|
+
options = node.wildcardChild.options.get("all");
|
|
232
253
|
}
|
|
233
254
|
if (handlers) {
|
|
234
|
-
return { handlers, params };
|
|
255
|
+
return { handlers, params, options };
|
|
235
256
|
}
|
|
236
257
|
}
|
|
237
258
|
return null;
|
|
@@ -713,7 +734,7 @@ class RequestScopeManager {
|
|
|
713
734
|
let servicesCleaned = 0;
|
|
714
735
|
for (const [, instance] of this.scoped) {
|
|
715
736
|
if (instance && typeof instance === "object" && "cleanup" in instance) {
|
|
716
|
-
const fn = instance
|
|
737
|
+
const fn = instance["cleanup"];
|
|
717
738
|
if (typeof fn === "function") {
|
|
718
739
|
try {
|
|
719
740
|
await fn.call(instance);
|
|
@@ -1730,4 +1751,4 @@ export {
|
|
|
1730
1751
|
AOTRouter
|
|
1731
1752
|
};
|
|
1732
1753
|
|
|
1733
|
-
//# debugId=
|
|
1754
|
+
//# debugId=970B1CDB4B48B9A964756E2164756E21
|