@stacksjs/bun-router 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +397 -0
- package/bin/cli.ts +9 -0
- package/dist/auth.d.ts +77 -0
- package/dist/cache/lru-cache.d.ts +88 -0
- package/dist/cache/middleware-memoization.d.ts +101 -0
- package/dist/cache/route-cache-warmer.d.ts +125 -0
- package/dist/cache/sqlite-cache.d.ts +114 -0
- package/dist/cache/streaming-cache.d.ts +86 -0
- package/dist/chunk-r15a48wc.js +25448 -0
- package/dist/cli/colors.d.ts +12 -0
- package/dist/cli/index.d.ts +10 -0
- package/dist/cli/middleware.d.ts +31 -0
- package/dist/cli/openapi.d.ts +17 -0
- package/dist/cli/router.d.ts +15 -0
- package/dist/cli/routes.d.ts +30 -0
- package/dist/cli/utils.d.ts +68 -0
- package/dist/cli.d.ts +0 -0
- package/dist/cli.js +3195 -0
- package/dist/config.d.ts +274 -0
- package/dist/container/container.d.ts +141 -0
- package/dist/container/contextual-binding.d.ts +112 -0
- package/dist/container/decorators.d.ts +114 -0
- package/dist/container/service-provider.d.ts +221 -0
- package/dist/development/hot-reload.d.ts +129 -0
- package/dist/development/index.d.ts +144 -0
- package/dist/development/performance-profiler.d.ts +152 -0
- package/dist/development/route-debugger.d.ts +102 -0
- package/dist/development/route-inspector.d.ts +142 -0
- package/dist/development/typescript-utilities.d.ts +116 -0
- package/dist/docs.d.ts +10 -0
- package/dist/errors/circuit-breaker.d.ts +138 -0
- package/dist/errors/error-handler.d.ts +57 -0
- package/dist/errors/error-reporting.d.ts +135 -0
- package/dist/errors/exceptions.d.ts +178 -0
- package/dist/errors/graceful-degradation.d.ts +130 -0
- package/dist/errors/index.d.ts +6 -0
- package/dist/errors/router-errors.d.ts +97 -0
- package/dist/file-serving/static-files.d.ts +98 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +13417 -0
- package/dist/middleware/auth.d.ts +34 -0
- package/dist/middleware/content_security_policy.d.ts +54 -0
- package/dist/middleware/cors.d.ts +5 -0
- package/dist/middleware/csrf.d.ts +7 -0
- package/dist/middleware/ddos_protection.d.ts +47 -0
- package/dist/middleware/file_security.d.ts +23 -0
- package/dist/middleware/file_upload.d.ts +41 -0
- package/dist/middleware/helmet.d.ts +54 -0
- package/dist/middleware/index.d.ts +55 -0
- package/dist/middleware/input_validation.d.ts +46 -0
- package/dist/middleware/json_body.d.ts +4 -0
- package/dist/middleware/performance_alerting.d.ts +88 -0
- package/dist/middleware/performance_dashboard.d.ts +97 -0
- package/dist/middleware/performance_monitor.d.ts +236 -0
- package/dist/middleware/pipeline.d.ts +90 -0
- package/dist/middleware/rate_limit.d.ts +33 -0
- package/dist/middleware/request_id.d.ts +4 -0
- package/dist/middleware/request_signing.d.ts +96 -0
- package/dist/middleware/request_tracer.d.ts +76 -0
- package/dist/middleware/response_cache.d.ts +90 -0
- package/dist/middleware/security.d.ts +70 -0
- package/dist/middleware/security_suite.d.ts +46 -0
- package/dist/middleware/session.d.ts +7 -0
- package/dist/model-binding/index.d.ts +17 -0
- package/dist/model-binding/model-middleware.d.ts +80 -0
- package/dist/model-binding/model-registry.d.ts +125 -0
- package/dist/model-binding.d.ts +123 -0
- package/dist/model-resolver-factory.d.ts +31 -0
- package/dist/observability/correlation.d.ts +131 -0
- package/dist/observability/health-checks.d.ts +129 -0
- package/dist/observability/index.d.ts +92 -0
- package/dist/observability/integration.d.ts +112 -0
- package/dist/observability/metrics.d.ts +135 -0
- package/dist/observability/tracing.d.ts +112 -0
- package/dist/optimization/bun-utilities.d.ts +106 -0
- package/dist/query-builder-integration.d.ts +24 -0
- package/dist/request/enhanced-request.d.ts +143 -0
- package/dist/request/macros.d.ts +267 -0
- package/dist/response/macros.d.ts +207 -0
- package/dist/response/response-factory.d.ts +93 -0
- package/dist/router/file-based-routing.d.ts +40 -0
- package/dist/router/file-streaming.d.ts +6 -0
- package/dist/router/fluent-router.d.ts +179 -0
- package/dist/router/fluent-routing.d.ts +198 -0
- package/dist/router/group-organization.d.ts +5 -0
- package/dist/router/handler-resolver.d.ts +13 -0
- package/dist/router/http-methods.d.ts +10 -0
- package/dist/router/index.d.ts +114 -0
- package/dist/router/middleware-integration.d.ts +86 -0
- package/dist/router/middleware.d.ts +5 -0
- package/dist/router/model-binding.d.ts +7 -0
- package/dist/router/optimized-route-matching.d.ts +6 -0
- package/dist/router/route-building.d.ts +5 -0
- package/dist/router/route-compiler.d.ts +67 -0
- package/dist/router/route-matching.d.ts +5 -0
- package/dist/router/route-trie.d.ts +69 -0
- package/dist/router/router.d.ts +133 -0
- package/dist/router/server.d.ts +5 -0
- package/dist/router/validation-integration.d.ts +116 -0
- package/dist/router/view-rendering.d.ts +5 -0
- package/dist/router/websocket.d.ts +5 -0
- package/dist/routing/route-caching.d.ts +105 -0
- package/dist/routing/route-throttling.d.ts +112 -0
- package/dist/routing/subdomain-routing.d.ts +159 -0
- package/dist/streaming/index.d.ts +15 -0
- package/dist/streaming/sse-handler.d.ts +81 -0
- package/dist/streaming/stream-handler.d.ts +81 -0
- package/dist/testing/auth-testing.d.ts +107 -0
- package/dist/testing/file-upload-testing.d.ts +139 -0
- package/dist/testing/index.d.ts +10 -0
- package/dist/testing/middleware-testing.d.ts +99 -0
- package/dist/testing/model-binding-testing.d.ts +132 -0
- package/dist/testing/performance-testing.d.ts +202 -0
- package/dist/testing/test-client.d.ts +58 -0
- package/dist/testing/test-request.d.ts +43 -0
- package/dist/testing/test-response.d.ts +45 -0
- package/dist/testing/types.d.ts +206 -0
- package/dist/testing/websocket-testing.d.ts +170 -0
- package/dist/types/controller-types.d.ts +303 -0
- package/dist/types/core.d.ts +526 -0
- package/dist/types/middleware-types.d.ts +315 -0
- package/dist/types/request-response-augmentation.d.ts +373 -0
- package/dist/types/route-inference.d.ts +287 -0
- package/dist/types.d.ts +1620 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/query-preservation.d.ts +31 -0
- package/dist/utils.d.ts +69 -0
- package/dist/validation/validator.d.ts +169 -0
- package/dist/websocket/clustering.d.ts +114 -0
- package/package.json +81 -0
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import type { BindingBuilder, Container, ResolutionContext } from './container';
|
|
2
|
+
// Service provider interfaces
|
|
3
|
+
export declare interface ServiceProvider {
|
|
4
|
+
register: (container: Container) => void | Promise<void>
|
|
5
|
+
boot?: (container: Container) => void | Promise<void>
|
|
6
|
+
shutdown?: (container: Container) => void | Promise<void>
|
|
7
|
+
name: string
|
|
8
|
+
version?: string
|
|
9
|
+
dependencies?: readonly string[]
|
|
10
|
+
environment?: string[]
|
|
11
|
+
priority?: number
|
|
12
|
+
}
|
|
13
|
+
export declare interface DeferredServiceProvider extends ServiceProvider {
|
|
14
|
+
provides: () => (string | symbol | Function)[]
|
|
15
|
+
isDeferred: () => boolean
|
|
16
|
+
}
|
|
17
|
+
export declare interface ConditionalServiceProvider extends ServiceProvider {
|
|
18
|
+
shouldLoad: (container: Container) => boolean | Promise<boolean>
|
|
19
|
+
}
|
|
20
|
+
// Service provider manager
|
|
21
|
+
export declare interface ServiceProviderManager {
|
|
22
|
+
register: (provider: ServiceProvider) => this
|
|
23
|
+
boot: () => Promise<void>
|
|
24
|
+
shutdown: () => Promise<void>
|
|
25
|
+
getProvider: (name: string) => ServiceProvider | undefined
|
|
26
|
+
getProviders: () => ServiceProvider[]
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Base service provider implementation
|
|
30
|
+
*/
|
|
31
|
+
export declare abstract class BaseServiceProvider implements ServiceProvider {
|
|
32
|
+
abstract readonly name: string;
|
|
33
|
+
readonly version?: string;
|
|
34
|
+
readonly dependencies?: readonly string[];
|
|
35
|
+
readonly environment?: string[];
|
|
36
|
+
readonly priority: number;
|
|
37
|
+
abstract register(container: Container): void | Promise<void>;
|
|
38
|
+
boot(_container: Container): void | Promise<void>;
|
|
39
|
+
shutdown(_container: Container): void | Promise<void>;
|
|
40
|
+
protected singleton<T>(container: Container, token: string | symbol | Function, implementation: new (...args: any[]) => T): void;
|
|
41
|
+
protected transient<T>(container: Container, token: string | symbol | Function, implementation: new (...args: any[]) => T): void;
|
|
42
|
+
protected value<T>(container: Container, token: string | symbol | Function, value: T): void;
|
|
43
|
+
protected factory<T>(container: Container, token: string | symbol | Function, factory: (...args: any[]) => T): void;
|
|
44
|
+
protected when(container: Container, condition: (context: ResolutionContext) => boolean): { bind: <T>(token: string | symbol | Function) => BindingBuilder<T> };
|
|
45
|
+
protected forEnvironment(container: Container, environments: string[]): { bind: <T>(token: string | symbol | Function) => BindingBuilder<T> };
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Deferred service provider base class
|
|
49
|
+
*/
|
|
50
|
+
export declare abstract class BaseDeferredServiceProvider extends BaseServiceProvider implements DeferredServiceProvider {
|
|
51
|
+
abstract provides(): (string | symbol | Function)[];
|
|
52
|
+
isDeferred(): boolean;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Service provider manager implementation
|
|
56
|
+
*/
|
|
57
|
+
export declare class DefaultServiceProviderManager implements ServiceProviderManager {
|
|
58
|
+
private providers: any;
|
|
59
|
+
private deferredProviders: any;
|
|
60
|
+
private loadedProviders: any;
|
|
61
|
+
private bootedProviders: any;
|
|
62
|
+
private container: Container;
|
|
63
|
+
constructor(container: Container);
|
|
64
|
+
register(provider: ServiceProvider): this;
|
|
65
|
+
boot(): Promise<void>;
|
|
66
|
+
shutdown(): Promise<void>;
|
|
67
|
+
getProvider(name: string): ServiceProvider | undefined;
|
|
68
|
+
getProviders(): ServiceProvider[];
|
|
69
|
+
loadDeferredProvider(token: string | symbol | Function): Promise<void>;
|
|
70
|
+
private doRegister(provider: ServiceProvider): void;
|
|
71
|
+
private loadProvider(provider: ServiceProvider): Promise<void>;
|
|
72
|
+
private bootProvider(provider: ServiceProvider): Promise<void>;
|
|
73
|
+
private validateDependencies(providers: ServiceProvider[]): void;
|
|
74
|
+
private isDeferredProvider(provider: ServiceProvider): provider is DeferredServiceProvider;
|
|
75
|
+
private isConditionalProvider(provider: ServiceProvider): provider is ConditionalServiceProvider;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Common service providers
|
|
79
|
+
*/
|
|
80
|
+
/**
|
|
81
|
+
* Configuration service provider
|
|
82
|
+
*/
|
|
83
|
+
export declare class ConfigServiceProvider extends BaseServiceProvider {
|
|
84
|
+
readonly name: any;
|
|
85
|
+
readonly priority: any;
|
|
86
|
+
register(container: Container): void;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Logging service provider
|
|
90
|
+
*/
|
|
91
|
+
export declare class LoggingServiceProvider extends BaseServiceProvider {
|
|
92
|
+
readonly name: any;
|
|
93
|
+
readonly priority: any;
|
|
94
|
+
register(container: Container): void;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Database service provider
|
|
98
|
+
*/
|
|
99
|
+
export declare class DatabaseServiceProvider extends BaseServiceProvider {
|
|
100
|
+
readonly name: any;
|
|
101
|
+
readonly dependencies: any;
|
|
102
|
+
register(container: Container): void;
|
|
103
|
+
boot(container: Container): Promise<void>;
|
|
104
|
+
shutdown(container: Container): Promise<void>;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Cache service provider
|
|
108
|
+
*/
|
|
109
|
+
export declare class CacheServiceProvider extends BaseServiceProvider {
|
|
110
|
+
readonly name: any;
|
|
111
|
+
readonly dependencies: any;
|
|
112
|
+
register(container: Container): void;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Authentication service provider
|
|
116
|
+
*/
|
|
117
|
+
export declare class AuthServiceProvider extends BaseServiceProvider {
|
|
118
|
+
readonly name: any;
|
|
119
|
+
readonly dependencies: any;
|
|
120
|
+
register(container: Container): void;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Validation service provider
|
|
124
|
+
*/
|
|
125
|
+
export declare class ValidationServiceProvider extends BaseServiceProvider {
|
|
126
|
+
readonly name: any;
|
|
127
|
+
register(container: Container): void;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Event service provider (deferred)
|
|
131
|
+
*/
|
|
132
|
+
export declare class EventServiceProvider extends BaseDeferredServiceProvider {
|
|
133
|
+
readonly name: any;
|
|
134
|
+
provides(): (string | symbol | Function)[];
|
|
135
|
+
register(container: Container): void;
|
|
136
|
+
}
|
|
137
|
+
// Mock service classes for demonstration
|
|
138
|
+
declare class ConfigService {
|
|
139
|
+
get(key: string, defaultValue?: any): any;
|
|
140
|
+
}
|
|
141
|
+
declare class Logger {
|
|
142
|
+
private config: any;
|
|
143
|
+
constructor(config: any);
|
|
144
|
+
log(message: string): void;
|
|
145
|
+
}
|
|
146
|
+
declare class ConsoleLogger extends Logger {
|
|
147
|
+
constructor();
|
|
148
|
+
}
|
|
149
|
+
declare class FileLogger extends Logger {
|
|
150
|
+
private filePath: string;
|
|
151
|
+
constructor(filePath: string);
|
|
152
|
+
}
|
|
153
|
+
declare class DatabaseConnection {
|
|
154
|
+
connect(): Promise<void>;
|
|
155
|
+
disconnect(): Promise<void>;
|
|
156
|
+
}
|
|
157
|
+
declare class UserRepository {
|
|
158
|
+
private db: DatabaseConnection;
|
|
159
|
+
constructor(db: DatabaseConnection);
|
|
160
|
+
}
|
|
161
|
+
declare class PostRepository {
|
|
162
|
+
private db: DatabaseConnection;
|
|
163
|
+
constructor(db: DatabaseConnection);
|
|
164
|
+
}
|
|
165
|
+
declare class CacheManager {
|
|
166
|
+
private store: any;
|
|
167
|
+
constructor(store: any);
|
|
168
|
+
}
|
|
169
|
+
declare class MemoryCache {
|
|
170
|
+
private cache: any;
|
|
171
|
+
}
|
|
172
|
+
declare class RedisCache {
|
|
173
|
+
private config: any;
|
|
174
|
+
constructor(config: any);
|
|
175
|
+
}
|
|
176
|
+
declare class AuthService {
|
|
177
|
+
private jwt: JwtService;
|
|
178
|
+
private userRepo: UserRepository;
|
|
179
|
+
constructor(jwt: JwtService, userRepo: UserRepository);
|
|
180
|
+
}
|
|
181
|
+
declare class JwtService {
|
|
182
|
+
private config: ConfigService;
|
|
183
|
+
constructor(config: ConfigService);
|
|
184
|
+
}
|
|
185
|
+
declare class AuthGuard {
|
|
186
|
+
private auth: AuthService;
|
|
187
|
+
constructor(auth: AuthService);
|
|
188
|
+
}
|
|
189
|
+
declare class Validator {
|
|
190
|
+
validate(_data: any, _rules: any): boolean;
|
|
191
|
+
}
|
|
192
|
+
declare class ValidationPipe {
|
|
193
|
+
private validator: Validator;
|
|
194
|
+
constructor(validator: Validator);
|
|
195
|
+
}
|
|
196
|
+
declare class EventBus {
|
|
197
|
+
emit(_event: string, _data: any): void;
|
|
198
|
+
}
|
|
199
|
+
declare class EventDispatcher {
|
|
200
|
+
private bus: EventBus;
|
|
201
|
+
constructor(bus: EventBus);
|
|
202
|
+
}
|
|
203
|
+
export {
|
|
204
|
+
AuthGuard,
|
|
205
|
+
AuthService,
|
|
206
|
+
CacheManager,
|
|
207
|
+
ConfigService,
|
|
208
|
+
ConsoleLogger,
|
|
209
|
+
DatabaseConnection,
|
|
210
|
+
EventBus,
|
|
211
|
+
EventDispatcher,
|
|
212
|
+
FileLogger,
|
|
213
|
+
JwtService,
|
|
214
|
+
Logger,
|
|
215
|
+
MemoryCache,
|
|
216
|
+
PostRepository,
|
|
217
|
+
RedisCache,
|
|
218
|
+
UserRepository,
|
|
219
|
+
ValidationPipe,
|
|
220
|
+
Validator,
|
|
221
|
+
};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hot reload middleware for preserving server state
|
|
3
|
+
*/
|
|
4
|
+
export declare function createHotReloadMiddleware(hotReload: HotReloadManager): void;
|
|
5
|
+
/**
|
|
6
|
+
* Initialize global hot reload
|
|
7
|
+
*/
|
|
8
|
+
export declare function initializeHotReload(config?: HotReloadConfig): HotReloadManager;
|
|
9
|
+
/**
|
|
10
|
+
* Get global hot reload instance
|
|
11
|
+
*/
|
|
12
|
+
export declare function getHotReload(): HotReloadManager | null;
|
|
13
|
+
/**
|
|
14
|
+
* Hot reload utilities
|
|
15
|
+
*/
|
|
16
|
+
export declare const HotReloadUtils: {
|
|
17
|
+
/**
|
|
18
|
+
* Check if running in hot reload mode
|
|
19
|
+
*/
|
|
20
|
+
isHotReloadEnabled: () => any;
|
|
21
|
+
/**
|
|
22
|
+
* Get current reload count
|
|
23
|
+
*/
|
|
24
|
+
getReloadCount: () => any;
|
|
25
|
+
/**
|
|
26
|
+
* Create hot-reloadable module cache
|
|
27
|
+
*/
|
|
28
|
+
createModuleCache: <T>() => unknown;
|
|
29
|
+
/**
|
|
30
|
+
* Create hot-reloadable configuration
|
|
31
|
+
*/
|
|
32
|
+
createHotConfig: <T>(initialConfig: T, configPath?: string) => { get: ()
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Hot reload helpers for common patterns
|
|
36
|
+
*/
|
|
37
|
+
export declare const HotReloadHelpers: {
|
|
38
|
+
/**
|
|
39
|
+
* Create hot-reloadable route handlers
|
|
40
|
+
*/
|
|
41
|
+
createHotHandler: (handlerPath: string) => unknown;
|
|
42
|
+
/**
|
|
43
|
+
* Create hot-reloadable middleware
|
|
44
|
+
*/
|
|
45
|
+
createHotMiddleware: (middlewarePath: string) => unknown;
|
|
46
|
+
/**
|
|
47
|
+
* Create development server with hot reload
|
|
48
|
+
*/
|
|
49
|
+
createDevelopmentServer: (config: { port?: number hostname?: string hotReload?: HotReloadConfig onReload?: () => void } = {}) => unknown
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Hot reload decorators for classes and methods
|
|
53
|
+
*/
|
|
54
|
+
export declare const HotReloadDecorators: {
|
|
55
|
+
/**
|
|
56
|
+
* Class decorator for hot-reloadable classes
|
|
57
|
+
*/
|
|
58
|
+
hotReloadable: () => unknown;
|
|
59
|
+
/**
|
|
60
|
+
* Method decorator for hot-reloadable methods
|
|
61
|
+
*/
|
|
62
|
+
hotMethod: (target: any, propertyKey: string, descriptor: PropertyDescriptor) => any
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Hot reload factory functions
|
|
66
|
+
*/
|
|
67
|
+
export declare const HotReloadFactory: {
|
|
68
|
+
/**
|
|
69
|
+
* Create development hot reload
|
|
70
|
+
*/
|
|
71
|
+
createDevelopment: () => any;
|
|
72
|
+
/**
|
|
73
|
+
* Create production hot reload (disabled)
|
|
74
|
+
*/
|
|
75
|
+
createProduction: () => any;
|
|
76
|
+
/**
|
|
77
|
+
* Create testing hot reload
|
|
78
|
+
*/
|
|
79
|
+
createTesting: () => any
|
|
80
|
+
};
|
|
81
|
+
export declare interface HotReloadConfig {
|
|
82
|
+
enabled?: boolean
|
|
83
|
+
watchPaths?: string[]
|
|
84
|
+
ignorePaths?: string[]
|
|
85
|
+
extensions?: string[]
|
|
86
|
+
debounceMs?: number
|
|
87
|
+
preserveState?: boolean
|
|
88
|
+
onReload?: (changedFiles: string[]) => void
|
|
89
|
+
onError?: (error: Error) => void
|
|
90
|
+
verbose?: boolean
|
|
91
|
+
}
|
|
92
|
+
export declare interface HotReloadState {
|
|
93
|
+
reloadCount: number
|
|
94
|
+
lastReload: number
|
|
95
|
+
changedFiles: string[]
|
|
96
|
+
preservedState: Record<string, any>
|
|
97
|
+
watchers: Map<string, any>
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Hot reload manager for development
|
|
101
|
+
*/
|
|
102
|
+
export declare class HotReloadManager {
|
|
103
|
+
private config: Required<HotReloadConfig>;
|
|
104
|
+
private state: HotReloadState;
|
|
105
|
+
private debounceTimer?: Timer;
|
|
106
|
+
private isReloading: any;
|
|
107
|
+
constructor(config?: HotReloadConfig);
|
|
108
|
+
private initializeState(): void;
|
|
109
|
+
private setupWatchers(): void;
|
|
110
|
+
private handleFileChange(eventType: string, filePath: string): void;
|
|
111
|
+
private shouldIgnoreFile(filePath: string): boolean;
|
|
112
|
+
private shouldWatchFile(filePath: string): boolean;
|
|
113
|
+
private triggerReload(): void;
|
|
114
|
+
preserveState<T>(key: string, value: T): void;
|
|
115
|
+
restoreState<T>(key: string, defaultValue?: T): T | undefined;
|
|
116
|
+
clearState(key?: string): void;
|
|
117
|
+
getStats(): {
|
|
118
|
+
reloadCount: number
|
|
119
|
+
lastReload: number
|
|
120
|
+
uptime: number
|
|
121
|
+
watchedPaths: string[]
|
|
122
|
+
preservedKeys: string[]
|
|
123
|
+
};
|
|
124
|
+
stop(): void;
|
|
125
|
+
}
|
|
126
|
+
declare namespace global {
|
|
127
|
+
var __HOT_RELOAD_STATE__: HotReloadState | undefined;
|
|
128
|
+
var __HOT_RELOAD_PRESERVE__: Record<string, any>;
|
|
129
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { PerformanceProfiler, PerformanceProfilingHelpers } from './performance-profiler';
|
|
2
|
+
import { RouteDebugger, RouteDebugHelpers } from './route-debugger';
|
|
3
|
+
import { RouteInspectionHelpers, RouteInspector } from './route-inspector';
|
|
4
|
+
import { TypeScriptHelpers, TypeScriptUtilities } from './typescript-utilities';
|
|
5
|
+
import type { EnhancedRequest } from '../types';
|
|
6
|
+
export type {
|
|
7
|
+
ProfileConfig as ProfilerConfig,
|
|
8
|
+
PerformanceMetrics as ProfilerMetrics,
|
|
9
|
+
RouteProfile as ProfilerRouteProfile,
|
|
10
|
+
} from './performance-profiler';
|
|
11
|
+
export type {
|
|
12
|
+
RouteDebugConfig,
|
|
13
|
+
RouteDebugInfo,
|
|
14
|
+
} from './route-debugger';
|
|
15
|
+
export type {
|
|
16
|
+
RouteAnalysis as InspectorRouteAnalysis,
|
|
17
|
+
RouteMetadata as InspectorRouteMetadata,
|
|
18
|
+
RouteGroup,
|
|
19
|
+
} from './route-inspector';
|
|
20
|
+
export type {
|
|
21
|
+
TypeScriptConfig as TSConfig,
|
|
22
|
+
RouteTypeInfo as TSRouteTypeInfo,
|
|
23
|
+
TypeDefinition as TSTypeDefinition,
|
|
24
|
+
ValidationSchema as TSValidationSchema,
|
|
25
|
+
} from './typescript-utilities';
|
|
26
|
+
/**
|
|
27
|
+
* Development presets for common configurations
|
|
28
|
+
*/
|
|
29
|
+
export declare const DevelopmentPresets: {
|
|
30
|
+
/**
|
|
31
|
+
* Full development mode with all features enabled
|
|
32
|
+
*/
|
|
33
|
+
development: () => any;
|
|
34
|
+
/**
|
|
35
|
+
* Production debugging with minimal overhead
|
|
36
|
+
*/
|
|
37
|
+
production: () => any;
|
|
38
|
+
/**
|
|
39
|
+
* Performance testing configuration
|
|
40
|
+
*/
|
|
41
|
+
performance: () => any;
|
|
42
|
+
/**
|
|
43
|
+
* TypeScript development configuration
|
|
44
|
+
*/
|
|
45
|
+
typescript: () => any
|
|
46
|
+
};
|
|
47
|
+
export declare interface DevelopmentConfig {
|
|
48
|
+
debug?: {
|
|
49
|
+
enabled?: boolean
|
|
50
|
+
logLevel?: 'debug' | 'info' | 'warn' | 'error'
|
|
51
|
+
includeHeaders?: boolean
|
|
52
|
+
includeBody?: boolean
|
|
53
|
+
colorOutput?: boolean
|
|
54
|
+
}
|
|
55
|
+
profiling?: {
|
|
56
|
+
enabled?: boolean
|
|
57
|
+
sampleRate?: number
|
|
58
|
+
includeMemory?: boolean
|
|
59
|
+
includeCpu?: boolean
|
|
60
|
+
}
|
|
61
|
+
inspection?: {
|
|
62
|
+
enabled?: boolean
|
|
63
|
+
trackStats?: boolean
|
|
64
|
+
generateReports?: boolean
|
|
65
|
+
}
|
|
66
|
+
typescript?: {
|
|
67
|
+
generateTypes?: boolean
|
|
68
|
+
validateTypes?: boolean
|
|
69
|
+
generateSchemas?: boolean
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Development tools manager
|
|
74
|
+
*/
|
|
75
|
+
export declare class DevelopmentTools {
|
|
76
|
+
private debugger: RouteDebugger;
|
|
77
|
+
private inspector: RouteInspector;
|
|
78
|
+
private profiler: PerformanceProfiler;
|
|
79
|
+
private tsUtils: TypeScriptUtilities;
|
|
80
|
+
private config: DevelopmentConfig;
|
|
81
|
+
constructor(config?: DevelopmentConfig);
|
|
82
|
+
createMiddleware(): Array<(req: EnhancedRequest, next: () => Promise<Response>) => Promise<Response>>;
|
|
83
|
+
registerRoute(method: string, pattern: string, handler: (...args: any[]) => any, middleware?: ((...args: any[]) => any)[], options?: any): string;
|
|
84
|
+
debug(): {
|
|
85
|
+
listRoutes: typeof RouteInspectionHelpers.listRoutes
|
|
86
|
+
analyzeRoutes: typeof RouteInspectionHelpers.analyzeRoutes
|
|
87
|
+
exportRoutes: typeof RouteInspectionHelpers.exportRoutes
|
|
88
|
+
getDebugSession: (requestId: string) => import('./route-debugger').RouteDebugInfo | undefined
|
|
89
|
+
clearSessions: () => void
|
|
90
|
+
};
|
|
91
|
+
routes(): {
|
|
92
|
+
list: (filter?: any) => import('./route-inspector').RouteMetadata[]
|
|
93
|
+
analyze: () => import('./route-inspector').RouteAnalysis
|
|
94
|
+
export: (format?: 'json' | 'csv' | 'markdown' | 'openapi') => string
|
|
95
|
+
groups: () => import('./route-inspector').RouteGroup[]
|
|
96
|
+
find: (method: string, path: string) => import('./route-inspector').RouteMetadata[]
|
|
97
|
+
};
|
|
98
|
+
profile(): {
|
|
99
|
+
getMetrics: () => import('./performance-profiler').PerformanceMetrics
|
|
100
|
+
getProfiles: (filter?: any) => import('./performance-profiler').RouteProfile[]
|
|
101
|
+
generateReport: () => string
|
|
102
|
+
clear: () => void
|
|
103
|
+
};
|
|
104
|
+
typescript(): {
|
|
105
|
+
generateTypes: () => string
|
|
106
|
+
generateSchemas: () => Record<string, import('./typescript-utilities').ValidationSchema>
|
|
107
|
+
generateOpenAPI: () => any
|
|
108
|
+
generateRouteBuilder: () => string
|
|
109
|
+
validateRequest: (req: EnhancedRequest, routeKey: string) => { valid: boolean, errors: string[], warnings: string[] }
|
|
110
|
+
};
|
|
111
|
+
generateReport(): string;
|
|
112
|
+
clear(): void;
|
|
113
|
+
private createInspectionMiddleware(): void;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Router extension for development tools
|
|
117
|
+
*/
|
|
118
|
+
export declare class DevelopmentRouter {
|
|
119
|
+
private devTools: DevelopmentTools;
|
|
120
|
+
private routes: any;
|
|
121
|
+
constructor(config?: DevelopmentConfig);
|
|
122
|
+
debug(): {
|
|
123
|
+
get: (pattern: string, handler: (...args: any[]) => any) => any
|
|
124
|
+
post: (pattern: string, handler: (...args: any[]) => any) => any
|
|
125
|
+
put: (pattern: string, handler: (...args: any[]) => any) => any
|
|
126
|
+
patch: (pattern: string, handler: (...args: any[]) => any) => any
|
|
127
|
+
delete: (pattern: string, handler: (...args: any[]) => any) => any
|
|
128
|
+
};
|
|
129
|
+
profile(): {
|
|
130
|
+
group: (callback: () => void) => void
|
|
131
|
+
};
|
|
132
|
+
getRoutes(): import('./route-inspector').RouteMetadata[];
|
|
133
|
+
private registerRoute(method: string, pattern: string, handler: (...args: any[]) => any, options?: any): void;
|
|
134
|
+
}
|
|
135
|
+
export {
|
|
136
|
+
PerformanceProfiler,
|
|
137
|
+
PerformanceProfilingHelpers,
|
|
138
|
+
RouteDebugger,
|
|
139
|
+
RouteDebugHelpers,
|
|
140
|
+
RouteInspectionHelpers,
|
|
141
|
+
RouteInspector,
|
|
142
|
+
TypeScriptHelpers,
|
|
143
|
+
TypeScriptUtilities,
|
|
144
|
+
};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type { EnhancedRequest } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Initialize global performance profiler
|
|
4
|
+
*/
|
|
5
|
+
export declare function initializePerformanceProfiler(config?: ProfileConfig): PerformanceProfiler;
|
|
6
|
+
/**
|
|
7
|
+
* Get global performance profiler
|
|
8
|
+
*/
|
|
9
|
+
export declare function getPerformanceProfiler(): PerformanceProfiler | null;
|
|
10
|
+
/**
|
|
11
|
+
* Performance profiling middleware factory
|
|
12
|
+
*/
|
|
13
|
+
export declare function createPerformanceProfilingMiddleware(config?: ProfileConfig): void;
|
|
14
|
+
/**
|
|
15
|
+
* Performance profiling helpers
|
|
16
|
+
*/
|
|
17
|
+
export declare const PerformanceProfilingHelpers: {
|
|
18
|
+
/**
|
|
19
|
+
* Record timing from request context
|
|
20
|
+
*/
|
|
21
|
+
startTiming: (req: EnhancedRequest, phase: keyof RouteProfile['phases'], name: string) => any;
|
|
22
|
+
/**
|
|
23
|
+
* End timing from request context
|
|
24
|
+
*/
|
|
25
|
+
endTiming: (req: EnhancedRequest, phase: keyof RouteProfile['phases'], timingId: string) => any;
|
|
26
|
+
/**
|
|
27
|
+
* Record database query from request context
|
|
28
|
+
*/
|
|
29
|
+
recordQuery: (req: EnhancedRequest, query: string, duration: number) => any;
|
|
30
|
+
/**
|
|
31
|
+
* Record profile point from request context
|
|
32
|
+
*/
|
|
33
|
+
recordPoint: (req: EnhancedRequest, phase: keyof RouteProfile['phases'], name: string, metadata?: Record<string, any>) => any
|
|
34
|
+
};
|
|
35
|
+
export declare interface ProfileConfig {
|
|
36
|
+
enabled?: boolean
|
|
37
|
+
sampleRate?: number
|
|
38
|
+
includeMemory?: boolean
|
|
39
|
+
includeCpu?: boolean
|
|
40
|
+
includeGc?: boolean
|
|
41
|
+
trackSlowQueries?: boolean
|
|
42
|
+
slowQueryThreshold?: number
|
|
43
|
+
maxProfiles?: number
|
|
44
|
+
outputFormat?: 'console' | 'json' | 'flamegraph'
|
|
45
|
+
}
|
|
46
|
+
export declare interface ProfilePoint {
|
|
47
|
+
name: string
|
|
48
|
+
timestamp: number
|
|
49
|
+
duration?: number
|
|
50
|
+
memory?: NodeJS.MemoryUsage
|
|
51
|
+
cpu?: NodeJS.CpuUsage
|
|
52
|
+
metadata?: Record<string, any>
|
|
53
|
+
}
|
|
54
|
+
export declare interface RouteProfile {
|
|
55
|
+
id: string
|
|
56
|
+
requestId: string
|
|
57
|
+
method: string
|
|
58
|
+
path: string
|
|
59
|
+
pattern: string
|
|
60
|
+
startTime: number
|
|
61
|
+
endTime?: number
|
|
62
|
+
totalDuration?: number
|
|
63
|
+
phases: {
|
|
64
|
+
routeMatching: ProfilePoint[]
|
|
65
|
+
middlewareExecution: ProfilePoint[]
|
|
66
|
+
handlerExecution: ProfilePoint[]
|
|
67
|
+
responseGeneration: ProfilePoint[]
|
|
68
|
+
}
|
|
69
|
+
memory: {
|
|
70
|
+
initial: NodeJS.MemoryUsage
|
|
71
|
+
peak: NodeJS.MemoryUsage
|
|
72
|
+
final?: NodeJS.MemoryUsage
|
|
73
|
+
allocations: number
|
|
74
|
+
}
|
|
75
|
+
cpu: {
|
|
76
|
+
initial: NodeJS.CpuUsage
|
|
77
|
+
final?: NodeJS.CpuUsage
|
|
78
|
+
userTime: number
|
|
79
|
+
systemTime: number
|
|
80
|
+
}
|
|
81
|
+
gc?: {
|
|
82
|
+
collections: number
|
|
83
|
+
duration: number
|
|
84
|
+
reclaimedMemory: number
|
|
85
|
+
}
|
|
86
|
+
queries?: Array<{
|
|
87
|
+
query: string
|
|
88
|
+
duration: number
|
|
89
|
+
timestamp: number
|
|
90
|
+
}>
|
|
91
|
+
warnings: string[]
|
|
92
|
+
recommendations: string[]
|
|
93
|
+
}
|
|
94
|
+
export declare interface PerformanceMetrics {
|
|
95
|
+
averageResponseTime: number
|
|
96
|
+
p50ResponseTime: number
|
|
97
|
+
p95ResponseTime: number
|
|
98
|
+
p99ResponseTime: number
|
|
99
|
+
requestsPerSecond: number
|
|
100
|
+
memoryUsageAverage: number
|
|
101
|
+
memoryUsagePeak: number
|
|
102
|
+
cpuUsageAverage: number
|
|
103
|
+
gcPressure: number
|
|
104
|
+
slowestRoutes: Array<{
|
|
105
|
+
pattern: string
|
|
106
|
+
averageTime: number
|
|
107
|
+
count: number
|
|
108
|
+
}>
|
|
109
|
+
memoryLeaks: Array<{
|
|
110
|
+
route: string
|
|
111
|
+
memoryGrowth: number
|
|
112
|
+
requests: number
|
|
113
|
+
}>
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Performance profiler for route analysis
|
|
117
|
+
*/
|
|
118
|
+
export declare class PerformanceProfiler {
|
|
119
|
+
private config: ProfileConfig;
|
|
120
|
+
private profiles: any;
|
|
121
|
+
private activeProfiles: any;
|
|
122
|
+
private metrics: PerformanceMetrics;
|
|
123
|
+
private gcObserver?: PerformanceObserver;
|
|
124
|
+
private memoryBaseline: NodeJS.MemoryUsage;
|
|
125
|
+
constructor(config?: ProfileConfig);
|
|
126
|
+
startProfiling(req: EnhancedRequest, pattern: string): string | null;
|
|
127
|
+
recordPoint(profileId: string, phase: keyof RouteProfile['phases'], name: string, metadata?: Record<string, any>): void;
|
|
128
|
+
startTiming(profileId: string, phase: keyof RouteProfile['phases'], name: string): string;
|
|
129
|
+
endTiming(profileId: string, phase: keyof RouteProfile['phases'], timingId: string): void;
|
|
130
|
+
recordQuery(profileId: string, query: string, duration: number): void;
|
|
131
|
+
finishProfiling(profileId: string, _response?: Response): RouteProfile | null;
|
|
132
|
+
getProfile(profileId: string): RouteProfile | undefined;
|
|
133
|
+
getProfiles(filter?: {
|
|
134
|
+
method?: string
|
|
135
|
+
pattern?: string
|
|
136
|
+
minDuration?: number
|
|
137
|
+
maxDuration?: number
|
|
138
|
+
hasWarnings?: boolean
|
|
139
|
+
}): RouteProfile[];
|
|
140
|
+
getMetrics(): PerformanceMetrics;
|
|
141
|
+
generateReport(): string;
|
|
142
|
+
clear(): void;
|
|
143
|
+
private shouldProfile(): boolean;
|
|
144
|
+
private generateProfileId(): string;
|
|
145
|
+
private extractRequestId(req: EnhancedRequest): string;
|
|
146
|
+
private initializeMetrics(): PerformanceMetrics;
|
|
147
|
+
private setupGcObserver(): void;
|
|
148
|
+
private generateRecommendations(profile: RouteProfile): void;
|
|
149
|
+
private updateMetrics(_profile: RouteProfile): void;
|
|
150
|
+
private cleanupProfiles(): void;
|
|
151
|
+
private logProfile(profile: RouteProfile): void;
|
|
152
|
+
}
|