nextrush 1.5.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,889 +1,258 @@
1
- import { IncomingMessage, ServerResponse } from 'http';
2
- import { ParsedUrlQuery } from 'querystring';
3
- import { Socket } from 'net';
4
- import { Writable } from 'stream';
5
-
6
- type Dict<T = unknown> = Record<string, T>;
1
+ import { IncomingMessage, ServerResponse } from 'node:http';
2
+ import { ParsedUrlQuery } from 'node:querystring';
3
+ import { EventEmitter } from 'node:events';
7
4
 
8
5
  /**
9
- * HTTP-related type definitions
6
+ * Custom error classes for NextRush v2
7
+ *
8
+ * @packageDocumentation
10
9
  */
11
-
12
- type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'ALL';
13
- type ContentType = 'application/json' | 'application/x-www-form-urlencoded' | 'text/plain' | 'text/html' | 'multipart/form-data' | string;
14
- interface ParsedRequest extends IncomingMessage {
15
- query: ParsedUrlQuery;
16
- params: Dict<string>;
17
- body: unknown;
18
- pathname: string;
19
- originalUrl: string;
20
- }
21
- interface ParsedResponse extends ServerResponse {
22
- locals: Dict<unknown>;
23
- }
24
- interface RequestContext {
25
- request: ParsedRequest;
26
- response: ParsedResponse;
27
- params: Dict<string>;
28
- query: ParsedUrlQuery;
29
- body: unknown;
30
- startTime: number;
31
- }
32
- interface BodyParserOptions {
33
- maxSize?: number;
34
- timeout?: number;
35
- allowedContentTypes?: ContentType[];
36
- strict?: boolean;
37
- }
38
-
39
10
  /**
40
- * 🔥 Optimized Error Handler - Simple and Efficient
41
- * - Memory optimized with smart caching
42
- * - Performance-first design
43
- * - Enterprise-grade error classification
11
+ * Base error class for NextRush v2
44
12
  */
45
-
46
- interface ErrorHandlerConfig {
47
- includeStack?: boolean;
48
- logErrors?: boolean;
49
- customErrorHandler?: (error: Error, context: RequestContext) => void;
50
- enableMetrics?: boolean;
51
- sanitizeProductionErrors?: boolean;
52
- }
53
- declare class ErrorHandler {
54
- private config;
55
- private errorCount;
56
- private lastErrorTime;
57
- constructor(config?: ErrorHandlerConfig);
58
- /**
59
- * Handle an error and send appropriate HTTP response
60
- */
61
- handle(error: Error, context: RequestContext): Promise<void>;
62
- /**
63
- * Convert any error to NextRushError with smart classification
64
- */
65
- private normalizeError;
66
- /**
67
- * Intelligent error classification
68
- */
69
- private classifyError;
70
- /**
71
- * Send formatted error response
72
- */
73
- private sendErrorResponse;
74
- /**
75
- * Smart error logging
76
- */
77
- private logError;
78
- /**
79
- * Utility methods
80
- */
81
- private shouldIncludeStack;
82
- private extractCorrelationId;
83
- private handleFallbackError;
13
+ declare class NextRushError extends Error {
14
+ readonly statusCode: number;
15
+ readonly code: string;
16
+ readonly isOperational: boolean;
17
+ readonly timestamp: Date;
18
+ constructor(message: string, statusCode?: number, code?: string, isOperational?: boolean);
84
19
  /**
85
- * Configure the error handler
20
+ * Create error from HTTP status code
86
21
  */
87
- configure(config: Partial<ErrorHandlerConfig>): void;
22
+ static fromStatusCode(statusCode: number, message?: string): NextRushError;
88
23
  /**
89
- * Get basic metrics
24
+ * Get error code from status code
90
25
  */
91
- getMetrics(): {
92
- totalErrors: number;
93
- lastErrorTime: number;
94
- };
26
+ private static getErrorCode;
95
27
  /**
96
- * Reset metrics
28
+ * Convert error to JSON
97
29
  */
98
- resetMetrics(): void;
30
+ toJSON(): Record<string, unknown>;
99
31
  }
100
-
101
32
  /**
102
- * Express-style request and response interfaces
103
- * Making NextRush familiar and easy to use
33
+ * Bad Request Error (400)
104
34
  */
105
-
106
- interface ValidationRule$1 {
107
- required?: boolean;
108
- type?: 'string' | 'number' | 'email' | 'url' | 'boolean';
109
- minLength?: number;
110
- maxLength?: number;
111
- min?: number;
112
- max?: number;
113
- custom?: (value: any) => boolean;
114
- message?: string;
115
- sanitize?: SanitizeOptions;
116
- }
117
- interface ValidationResult$1 {
118
- isValid: boolean;
119
- errors: Record<string, string[]>;
120
- sanitized: Record<string, any>;
121
- }
122
- interface SanitizeOptions {
123
- trim?: boolean;
124
- escape?: boolean;
125
- lowercase?: boolean;
126
- uppercase?: boolean;
127
- removeHtml?: boolean;
128
- removeSpecialChars?: boolean;
129
- }
130
- interface RateLimitInfo {
131
- limit: number;
132
- remaining: number;
133
- reset: number;
134
- retryAfter: number;
135
- }
136
- interface UserAgentInfo {
137
- raw: string;
138
- browser: string;
139
- os: string;
140
- device: string;
141
- isBot: boolean;
142
- isMobile: boolean;
143
- }
144
- interface RequestTiming {
145
- start: number;
146
- duration: number;
147
- timestamp: string;
35
+ declare class BadRequestError extends NextRushError {
36
+ constructor(message?: string);
148
37
  }
149
- interface NextRushRequest extends IncomingMessage {
150
- params: Record<string, string>;
151
- query: ParsedUrlQuery;
152
- body: any;
153
- pathname: string;
154
- originalUrl: string;
155
- path: string;
156
- files: Record<string, any>;
157
- cookies: Record<string, string>;
158
- signedCookies?: Record<string, string>;
159
- session: Record<string, any>;
160
- locals: Record<string, any>;
161
- startTime: number;
162
- id?: string;
163
- middlewareStack?: string[];
164
- param(name: string): string | undefined;
165
- header(name: string): string | undefined;
166
- get(name: string): string | undefined;
167
- ip(): string;
168
- secure(): boolean;
169
- protocol(): string;
170
- hostname(): string;
171
- fullUrl(): string;
172
- is(type: string): boolean;
173
- accepts(types: string | string[]): string | false;
174
- fresh: boolean;
175
- stale: boolean;
176
- parseCookies(): Record<string, string>;
177
- validate(rules: Record<string, ValidationRule$1>): ValidationResult$1;
178
- sanitize(value: any, options?: SanitizeOptions): any;
179
- sanitizeObject(obj: any, options?: any): any;
180
- rateLimit(): RateLimitInfo;
181
- fingerprint(): string;
182
- userAgent(): UserAgentInfo;
183
- timing(): RequestTiming;
184
- getRequestTiming(): any;
185
- isValidEmail(email: string): boolean;
186
- isValidUrl(url: string): boolean;
187
- sanitizeValue(value: any, rule: ValidationRule$1): any;
188
- parseBrowser(ua: string): string;
189
- parseOS(ua: string): string;
190
- parseDevice(ua: string): string;
191
- isBot(ua: string): boolean;
192
- isMobile(ua: string): boolean;
38
+ /**
39
+ * Unauthorized Error (401)
40
+ */
41
+ declare class UnauthorizedError extends NextRushError {
42
+ constructor(message?: string);
193
43
  }
194
- interface NextRushResponse extends ServerResponse {
195
- locals: Record<string, any>;
196
- status(code: number): NextRushResponse;
197
- json(data: any): void;
198
- send(data: string | Buffer | object): void;
199
- html(data: string): void;
200
- text(data: string): void;
201
- xml(data: string): void;
202
- csv(data: any[], filename?: string): void;
203
- stream(stream: NodeJS.ReadableStream, contentType?: string, options?: {
204
- bufferSize?: number;
205
- highWaterMark?: number;
206
- enableCompression?: boolean;
207
- }): void;
208
- sendFile(filePath: string, options?: {
209
- maxAge?: number;
210
- lastModified?: boolean;
211
- etag?: boolean;
212
- dotfiles?: 'allow' | 'deny' | 'ignore';
213
- root?: string;
214
- headers?: Record<string, string>;
215
- acceptRanges?: boolean;
216
- }): void;
217
- download(filePath: string, filename?: string, options?: any): void;
218
- getSmartContentType(filePath: string): string;
219
- generateETag(stats: any): string;
220
- redirect(url: string, status?: number): void;
221
- redirectPermanent(url: string): void;
222
- redirectTemporary(url: string): void;
223
- set(field: string, value: string): NextRushResponse;
224
- set(fields: Record<string, string>): NextRushResponse;
225
- header(field: string, value: string): NextRushResponse;
226
- removeHeader(field: string): NextRushResponse;
227
- get(field: string): string | undefined;
228
- cookie(name: string, value: string, options?: {
229
- maxAge?: number;
230
- expires?: Date;
231
- path?: string;
232
- domain?: string;
233
- secure?: boolean;
234
- httpOnly?: boolean;
235
- sameSite?: 'strict' | 'lax' | 'none';
236
- signed?: boolean;
237
- }): NextRushResponse;
238
- clearCookie(name: string, options?: any): NextRushResponse;
239
- render(template: string, data?: any): void;
240
- getContentTypeFromExtension(ext: string): string;
241
- getNestedValue(obj: any, path: string): any;
242
- isTruthy(value: any): boolean;
243
- cache(seconds: number): NextRushResponse;
244
- noCache(): NextRushResponse;
245
- cors(origin?: string): NextRushResponse;
246
- security(): NextRushResponse;
247
- compress(): NextRushResponse;
248
- success(data: any, message?: string): void;
249
- error(message: string, code?: number, details?: any): void;
250
- paginate(data: any[], page: number, limit: number, total: number): void;
251
- time(label?: string): NextRushResponse;
44
+ /**
45
+ * Forbidden Error (403)
46
+ */
47
+ declare class ForbiddenError extends NextRushError {
48
+ constructor(message?: string);
252
49
  }
253
- type ExpressHandler$1 = (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>;
254
- type ExpressMiddleware$1 = (req: NextRushRequest, res: NextRushResponse, next: () => void) => void | Promise<void>;
255
-
256
50
  /**
257
- * Routing-related type definitions
51
+ * Not Found Error (404)
258
52
  */
259
-
260
- type Path = string | RegExp;
261
-
262
- interface RouteHandler$1 {
263
- (context: RequestContext): Promise<void> | void;
264
- }
265
- interface MiddlewareHandler$1 {
266
- (context: RequestContext, next: () => Promise<void>): Promise<void> | void;
267
- }
268
- interface RouterOptions {
269
- caseSensitive?: boolean;
270
- strict?: boolean;
271
- mergeParams?: boolean;
272
- useOptimizedMatcher?: boolean;
273
- enableCaching?: boolean;
274
- cacheSize?: number;
275
- enablePrefixOptimization?: boolean;
276
- enableMetrics?: boolean;
53
+ declare class NotFoundError extends NextRushError {
54
+ constructor(message?: string);
277
55
  }
278
- interface Route {
279
- id: string;
280
- path: Path;
281
- method: HttpMethod;
282
- handler: RouteHandler$1;
283
- middleware?: MiddlewareHandler$1[];
284
- metadata?: Record<string, any>;
56
+ /**
57
+ * Method Not Allowed Error (405)
58
+ */
59
+ declare class MethodNotAllowedError extends NextRushError {
60
+ constructor(message?: string);
285
61
  }
286
-
287
- declare class Router {
288
- private routeManager;
289
- private globalMiddleware;
290
- private routerOptions;
291
- constructor(options?: RouterOptions);
292
- /**
293
- * Add global middleware that runs for all routes
294
- */
295
- use(middleware: MiddlewareHandler$1 | ExpressMiddleware$1): this;
296
- /**
297
- * Register a GET route
298
- */
299
- get(path: Path, handler: (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>): this;
300
- get(path: Path, handler: (context: RequestContext) => void | Promise<void>): this;
301
- get(path: Path, middleware: ExpressMiddleware$1, handler: (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>): this;
302
- get(path: Path, middleware: ExpressMiddleware$1, handler: (context: RequestContext) => void | Promise<void>): this;
303
- get(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, handler: (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>): this;
304
- get(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, handler: (context: RequestContext) => void | Promise<void>): this;
305
- get(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, middleware3: ExpressMiddleware$1, handler: (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>): this;
306
- get(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, middleware3: ExpressMiddleware$1, handler: (context: RequestContext) => void | Promise<void>): this;
307
- /**
308
- * Register a POST route
309
- */
310
- post(path: Path, handler: (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>): this;
311
- post(path: Path, handler: (context: RequestContext) => void | Promise<void>): this;
312
- post(path: Path, middleware: ExpressMiddleware$1, handler: (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>): this;
313
- post(path: Path, middleware: ExpressMiddleware$1, handler: (context: RequestContext) => void | Promise<void>): this;
314
- post(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, handler: (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>): this;
315
- post(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, handler: (context: RequestContext) => void | Promise<void>): this;
316
- post(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, middleware3: ExpressMiddleware$1, handler: (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>): this;
317
- post(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, middleware3: ExpressMiddleware$1, handler: (context: RequestContext) => void | Promise<void>): this;
318
- post(path: Path, middleware1: MiddlewareHandler$1 | ExpressMiddleware$1, middleware2: MiddlewareHandler$1 | ExpressMiddleware$1, middleware3: MiddlewareHandler$1 | ExpressMiddleware$1, handler: RouteHandler$1): this;
319
- post(path: Path, middleware1: MiddlewareHandler$1 | ExpressMiddleware$1, middleware2: MiddlewareHandler$1 | ExpressMiddleware$1, middleware3: MiddlewareHandler$1 | ExpressMiddleware$1, handler: ExpressHandler$1): this;
320
- /**
321
- * Register a PUT route
322
- */
323
- put(path: Path, handler: (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>): this;
324
- put(path: Path, handler: (context: RequestContext) => void | Promise<void>): this;
325
- put(path: Path, middleware: ExpressMiddleware$1, handler: (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>): this;
326
- put(path: Path, middleware: ExpressMiddleware$1, handler: (context: RequestContext) => void | Promise<void>): this;
327
- put(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, handler: (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>): this;
328
- put(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, handler: (context: RequestContext) => void | Promise<void>): this;
329
- put(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, middleware3: ExpressMiddleware$1, handler: (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>): this;
330
- put(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, middleware3: ExpressMiddleware$1, handler: (context: RequestContext) => void | Promise<void>): this;
331
- /**
332
- * Register a DELETE route
333
- */
334
- delete(path: Path, handler: (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>): this;
335
- delete(path: Path, handler: (context: RequestContext) => void | Promise<void>): this;
336
- delete(path: Path, middleware: ExpressMiddleware$1, handler: (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>): this;
337
- delete(path: Path, middleware: ExpressMiddleware$1, handler: (context: RequestContext) => void | Promise<void>): this;
338
- delete(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, handler: (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>): this;
339
- delete(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, handler: (context: RequestContext) => void | Promise<void>): this;
340
- delete(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, middleware3: ExpressMiddleware$1, handler: (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>): this;
341
- delete(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, middleware3: ExpressMiddleware$1, handler: (context: RequestContext) => void | Promise<void>): this;
342
- /**
343
- * Register a PATCH route
344
- */
345
- patch(path: Path, handler: (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>): this;
346
- patch(path: Path, handler: (context: RequestContext) => void | Promise<void>): this;
347
- patch(path: Path, middleware: ExpressMiddleware$1, handler: (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>): this;
348
- patch(path: Path, middleware: ExpressMiddleware$1, handler: (context: RequestContext) => void | Promise<void>): this;
349
- patch(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, handler: (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>): this;
350
- patch(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, handler: (context: RequestContext) => void | Promise<void>): this;
351
- patch(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, middleware3: ExpressMiddleware$1, handler: (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>): this;
352
- patch(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, middleware3: ExpressMiddleware$1, handler: (context: RequestContext) => void | Promise<void>): this;
353
- /**
354
- * Register a HEAD route
355
- */
356
- head(path: Path, handler: (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>): this;
357
- head(path: Path, handler: (context: RequestContext) => void | Promise<void>): this;
358
- head(path: Path, middleware: ExpressMiddleware$1, handler: (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>): this;
359
- head(path: Path, middleware: ExpressMiddleware$1, handler: (context: RequestContext) => void | Promise<void>): this;
360
- head(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, handler: (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>): this;
361
- head(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, handler: (context: RequestContext) => void | Promise<void>): this;
362
- head(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, middleware3: ExpressMiddleware$1, handler: (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>): this;
363
- head(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, middleware3: ExpressMiddleware$1, handler: (context: RequestContext) => void | Promise<void>): this;
364
- /**
365
- * Register an OPTIONS route
366
- */
367
- options(path: Path, handler: (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>): this;
368
- options(path: Path, handler: (context: RequestContext) => void | Promise<void>): this;
369
- options(path: Path, middleware: ExpressMiddleware$1, handler: (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>): this;
370
- options(path: Path, middleware: ExpressMiddleware$1, handler: (context: RequestContext) => void | Promise<void>): this;
371
- options(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, handler: (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>): this;
372
- options(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, handler: (context: RequestContext) => void | Promise<void>): this;
373
- options(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, middleware3: ExpressMiddleware$1, handler: (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>): this;
374
- options(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, middleware3: ExpressMiddleware$1, handler: (context: RequestContext) => void | Promise<void>): this;
375
- /**
376
- * Handle incoming request
377
- */
378
- handle(context: RequestContext): Promise<void>;
379
- /**
380
- * Execute middleware chain and route handler
381
- */
382
- private executeMiddlewareChain;
383
- /**
384
- * Add a route with the specified method (internal)
385
- */
386
- private registerRoute;
387
- /**
388
- * Add a route to this router (public API for mounting)
389
- */
390
- addRoute(method: HttpMethod, path: Path, handler: RouteHandler$1 | ExpressHandler$1, middleware?: (MiddlewareHandler$1 | ExpressMiddleware$1)[]): this;
391
- /**
392
- * Internal method for Application class - allows spreading middleware
393
- */
394
- private _addRoute;
395
- /**
396
- * Internal GET method for Application class
397
- */
398
- _get(path: Path, handler: RouteHandler$1 | ExpressHandler$1, middleware?: (MiddlewareHandler$1 | ExpressMiddleware$1)[]): this;
399
- /**
400
- * Internal POST method for Application class
401
- */
402
- _post(path: Path, handler: RouteHandler$1 | ExpressHandler$1, middleware?: (MiddlewareHandler$1 | ExpressMiddleware$1)[]): this;
403
- /**
404
- * Internal PUT method for Application class
405
- */
406
- _put(path: Path, handler: RouteHandler$1 | ExpressHandler$1, middleware?: (MiddlewareHandler$1 | ExpressMiddleware$1)[]): this;
407
- /**
408
- * Internal DELETE method for Application class
409
- */
410
- _delete(path: Path, handler: RouteHandler$1 | ExpressHandler$1, middleware?: (MiddlewareHandler$1 | ExpressMiddleware$1)[]): this;
411
- /**
412
- * Internal PATCH method for Application class
413
- */
414
- _patch(path: Path, handler: RouteHandler$1 | ExpressHandler$1, middleware?: (MiddlewareHandler$1 | ExpressMiddleware$1)[]): this;
415
- /**
416
- * Internal HEAD method for Application class
417
- */
418
- _head(path: Path, handler: RouteHandler$1 | ExpressHandler$1, middleware?: (MiddlewareHandler$1 | ExpressMiddleware$1)[]): this;
419
- /**
420
- * Internal OPTIONS method for Application class
421
- */
422
- _options(path: Path, handler: RouteHandler$1 | ExpressHandler$1, middleware?: (MiddlewareHandler$1 | ExpressMiddleware$1)[]): this;
423
- /**
424
- * Get all registered routes
425
- */
426
- getRoutes(method?: HttpMethod): Route[];
427
- /**
428
- * Get router statistics
429
- */
430
- getStats(): {
431
- globalMiddleware: number;
432
- totalRoutes: number;
433
- routesByMethod: Record<HttpMethod, number>;
434
- methods: HttpMethod[];
435
- performanceStats?: any;
436
- };
437
- /**
438
- * Clear all routes and middleware
439
- */
440
- clear(): void;
441
- /**
442
- * Create a sub-router with merged options
443
- */
444
- createSubRouter(options?: Partial<RouterOptions>): Router;
445
- /**
446
- * Mount another router with a path prefix
447
- */
448
- mount(pathPrefix: string, router: Router): this;
449
- private combinePaths;
450
- /**
451
- * Configure the router
452
- */
453
- configure(options: Partial<RouterOptions>): void;
454
- /**
455
- * Check if a handler is an Express-style handler
456
- */
457
- private isExpressHandler;
458
- /**
459
- * Convert Express-style handler to NextRush handler
460
- */
461
- private convertHandler;
462
- /**
463
- * Check if middleware is Express-style
464
- */
465
- private isExpressMiddleware;
466
- /**
467
- * Convert Express-style middleware to NextRush middleware
468
- */
469
- private convertMiddleware;
62
+ /**
63
+ * Conflict Error (409)
64
+ */
65
+ declare class ConflictError extends NextRushError {
66
+ constructor(message?: string);
470
67
  }
471
-
472
68
  /**
473
- * 🚀 NextRush Simple Event System
474
- * Lightweight event-driven architecture for request/response tracking
69
+ * Unprocessable Entity Error (422)
475
70
  */
476
- type EventCallback<T = any> = (data: T) => void | Promise<void>;
71
+ declare class UnprocessableEntityError extends NextRushError {
72
+ constructor(message?: string);
73
+ }
477
74
  /**
478
- * 🎯 Simple Event Emitter
75
+ * Too Many Requests Error (429)
479
76
  */
480
- declare class SimpleEventEmitter {
481
- private events;
482
- private maxListeners;
483
- /**
484
- * Add event listener
485
- */
486
- on<T = any>(event: string, callback: EventCallback<T>): this;
487
- /**
488
- * Add one-time event listener
489
- */
490
- once<T = any>(event: string, callback: EventCallback<T>): this;
491
- /**
492
- * Remove event listener
493
- */
494
- off<T = any>(event: string, callback: EventCallback<T>): this;
495
- /**
496
- * Remove all listeners for event or all events
497
- */
498
- removeAllListeners(event?: string): this;
499
- /**
500
- * Emit event
501
- */
502
- emit<T = any>(event: string, data?: T): boolean;
503
- /**
504
- * Get listener count for event
505
- */
506
- listenerCount(event: string): number;
507
- /**
508
- * Get all event names
509
- */
510
- eventNames(): string[];
511
- /**
512
- * Get listeners for event
513
- */
514
- listeners<T = any>(event: string): EventCallback<T>[];
77
+ declare class TooManyRequestsError extends NextRushError {
78
+ constructor(message?: string);
79
+ }
80
+ /**
81
+ * Internal Server Error (500)
82
+ */
83
+ declare class InternalServerError extends NextRushError {
84
+ constructor(message?: string);
85
+ }
86
+ /**
87
+ * Service Unavailable Error (503)
88
+ */
89
+ declare class ServiceUnavailableError extends NextRushError {
90
+ constructor(message?: string);
91
+ }
92
+ /**
93
+ * Validation Error (400)
94
+ */
95
+ declare class ValidationError extends NextRushError {
96
+ readonly field: string;
97
+ readonly value: unknown;
98
+ constructor(message: string, field?: string, value?: unknown, statusCode?: number);
515
99
  /**
516
- * Set max listeners
100
+ * Create validation error for specific field
517
101
  */
518
- setMaxListeners(max: number): this;
102
+ static forField(field: string, message: string, value?: unknown): ValidationError;
519
103
  /**
520
- * Get max listeners
104
+ * Create validation error for multiple fields
521
105
  */
522
- getMaxListeners(): number;
106
+ static forFields(errors: Array<{
107
+ field: string;
108
+ message: string;
109
+ value?: unknown;
110
+ }>): ValidationError;
523
111
  }
524
-
525
112
  /**
526
- * 🚀 NextRush WebSocket - Type Definitions
527
- * Zero-dependency WebSocket implementation using raw Node.js
528
- * RFC 6455 compliant with advanced room and event management
113
+ * Authentication Error (401)
529
114
  */
530
-
531
- /**
532
- * WebSocket connection states (RFC 6455)
533
- */
534
- declare enum WebSocketReadyState {
535
- CONNECTING = 0,
536
- OPEN = 1,
537
- CLOSING = 2,
538
- CLOSED = 3
115
+ declare class AuthenticationError extends NextRushError {
116
+ constructor(message?: string);
539
117
  }
540
118
  /**
541
- * NextRush WebSocket Connection
542
- * Pure Node.js implementation with advanced features
119
+ * Authorization Error (403)
543
120
  */
544
- interface NextRushWebSocket {
545
- id: string;
546
- socket: Socket;
547
- readyState: WebSocketReadyState;
548
- protocol: string;
549
- extensions: string[];
550
- send(data: string | Buffer | object): void;
551
- ping(data?: Buffer): void;
552
- pong(data?: Buffer): void;
553
- close(code?: number, reason?: string): void;
554
- broadcast(data: string | Buffer | object, room?: string): void;
555
- join(room: string): Promise<void>;
556
- leave(room: string): Promise<void>;
557
- to(room: string): RoomEmitter;
558
- emit(event: string, ...args: any[]): void;
559
- on(event: string, handler: (...args: any[]) => void): void;
560
- off(event: string, handler?: (...args: any[]) => void): void;
561
- once(event: string, handler: (...args: any[]) => void): void;
562
- ip: string;
563
- userAgent: string;
564
- origin: string;
565
- rooms: Set<string>;
566
- isAlive: boolean;
567
- lastPing: number;
568
- metadata: Record<string, any>;
569
- connectedAt: Date;
570
- lastActivity: Date;
121
+ declare class AuthorizationError extends NextRushError {
122
+ constructor(message?: string);
571
123
  }
572
124
  /**
573
- * Room-based messaging interface
125
+ * Database Error (500)
574
126
  */
575
- interface RoomEmitter {
576
- emit(event: string, ...args: any[]): void;
577
- send(data: string | Buffer | object): void;
578
- broadcast(data: string | Buffer | object): void;
579
- except(socketId: string): RoomEmitter;
580
- to(room: string): RoomEmitter;
127
+ declare class DatabaseError extends NextRushError {
128
+ readonly operation: string;
129
+ readonly table: string | undefined;
130
+ constructor(message: string, operation?: string, table?: string, statusCode?: number);
581
131
  }
582
132
  /**
583
- * WebSocket event handlers
133
+ * Network Error (502)
584
134
  */
585
- type WebSocketHandler = (socket: NextRushWebSocket, req: NextRushRequest) => void | Promise<void>;
586
-
135
+ declare class NetworkError extends NextRushError {
136
+ readonly host: string;
137
+ readonly port: number;
138
+ constructor(message: string, host: string, port: number);
139
+ }
587
140
  /**
588
- * Core interfaces for NextRush framework
589
- * Based on old codebase patterns but modernized for new architecture
141
+ * Timeout Error (408)
590
142
  */
591
-
592
- type RouteHandler = (context: RequestContext) => void | Promise<void>;
593
- type ExpressHandler = (req: NextRushRequest, res: NextRushResponse) => void | Promise<void>;
594
- type MiddlewareHandler = (context: RequestContext, next: () => void) => void | Promise<void>;
595
- type ExpressMiddleware = (req: NextRushRequest, res: NextRushResponse, next: () => void) => void | Promise<void>;
596
- /**
597
- * Minimal Application interface - defines core methods that components need
598
- */
599
- interface MinimalApplication$1 {
600
- get(path: Path, handler: ExpressHandler): MinimalApplication$1;
601
- get(path: Path, handler: RouteHandler): MinimalApplication$1;
602
- get(path: Path, middleware: ExpressMiddleware, handler: ExpressHandler): MinimalApplication$1;
603
- get(path: Path, middleware: MiddlewareHandler, handler: RouteHandler): MinimalApplication$1;
604
- get(path: Path, middleware1: ExpressMiddleware, middleware2: ExpressMiddleware, handler: ExpressHandler): MinimalApplication$1;
605
- get(path: Path, middleware1: ExpressMiddleware, middleware2: ExpressMiddleware, middleware3: ExpressMiddleware, handler: ExpressHandler): MinimalApplication$1;
606
- get(path: Path, ...args: (RouteHandler | ExpressHandler | MiddlewareHandler | ExpressMiddleware)[]): MinimalApplication$1;
607
- post(path: Path, handler: ExpressHandler): MinimalApplication$1;
608
- post(path: Path, handler: RouteHandler): MinimalApplication$1;
609
- post(path: Path, middleware: ExpressMiddleware, handler: ExpressHandler): MinimalApplication$1;
610
- post(path: Path, middleware: MiddlewareHandler, handler: RouteHandler): MinimalApplication$1;
611
- post(path: Path, middleware1: ExpressMiddleware, middleware2: ExpressMiddleware, handler: ExpressHandler): MinimalApplication$1;
612
- post(path: Path, middleware1: ExpressMiddleware, middleware2: ExpressMiddleware, middleware3: ExpressMiddleware, handler: ExpressHandler): MinimalApplication$1;
613
- post(path: Path, ...args: (RouteHandler | ExpressHandler | MiddlewareHandler | ExpressMiddleware)[]): MinimalApplication$1;
614
- put(path: Path, handler: ExpressHandler): MinimalApplication$1;
615
- put(path: Path, handler: RouteHandler): MinimalApplication$1;
616
- put(path: Path, middleware: ExpressMiddleware, handler: ExpressHandler): MinimalApplication$1;
617
- put(path: Path, middleware: MiddlewareHandler, handler: RouteHandler): MinimalApplication$1;
618
- put(path: Path, middleware1: ExpressMiddleware, middleware2: ExpressMiddleware, handler: ExpressHandler): MinimalApplication$1;
619
- put(path: Path, middleware1: ExpressMiddleware, middleware2: ExpressMiddleware, middleware3: ExpressMiddleware, handler: ExpressHandler): MinimalApplication$1;
620
- put(path: Path, ...args: (RouteHandler | ExpressHandler | MiddlewareHandler | ExpressMiddleware)[]): MinimalApplication$1;
621
- delete(path: Path, handler: ExpressHandler): MinimalApplication$1;
622
- delete(path: Path, handler: RouteHandler): MinimalApplication$1;
623
- delete(path: Path, middleware: ExpressMiddleware, handler: ExpressHandler): MinimalApplication$1;
624
- delete(path: Path, middleware: MiddlewareHandler, handler: RouteHandler): MinimalApplication$1;
625
- delete(path: Path, middleware1: ExpressMiddleware, middleware2: ExpressMiddleware, handler: ExpressHandler): MinimalApplication$1;
626
- delete(path: Path, middleware1: ExpressMiddleware, middleware2: ExpressMiddleware, middleware3: ExpressMiddleware, handler: ExpressHandler): MinimalApplication$1;
627
- delete(path: Path, ...args: (RouteHandler | ExpressHandler | MiddlewareHandler | ExpressMiddleware)[]): MinimalApplication$1;
628
- patch(path: Path, handler: ExpressHandler): MinimalApplication$1;
629
- patch(path: Path, handler: RouteHandler): MinimalApplication$1;
630
- patch(path: Path, middleware: ExpressMiddleware, handler: ExpressHandler): MinimalApplication$1;
631
- patch(path: Path, middleware: MiddlewareHandler, handler: RouteHandler): MinimalApplication$1;
632
- patch(path: Path, middleware1: ExpressMiddleware, middleware2: ExpressMiddleware, handler: ExpressHandler): MinimalApplication$1;
633
- patch(path: Path, middleware1: ExpressMiddleware, middleware2: ExpressMiddleware, middleware3: ExpressMiddleware, handler: ExpressHandler): MinimalApplication$1;
634
- patch(path: Path, ...args: (RouteHandler | ExpressHandler | MiddlewareHandler | ExpressMiddleware)[]): MinimalApplication$1;
635
- head(path: Path, handler: ExpressHandler): MinimalApplication$1;
636
- head(path: Path, handler: RouteHandler): MinimalApplication$1;
637
- head(path: Path, middleware: ExpressMiddleware, handler: ExpressHandler): MinimalApplication$1;
638
- head(path: Path, middleware: MiddlewareHandler, handler: RouteHandler): MinimalApplication$1;
639
- head(path: Path, middleware1: ExpressMiddleware, middleware2: ExpressMiddleware, handler: ExpressHandler): MinimalApplication$1;
640
- head(path: Path, middleware1: ExpressMiddleware, middleware2: ExpressMiddleware, middleware3: ExpressMiddleware, handler: ExpressHandler): MinimalApplication$1;
641
- head(path: Path, ...args: (RouteHandler | ExpressHandler | MiddlewareHandler | ExpressMiddleware)[]): MinimalApplication$1;
642
- options(path: Path, handler: ExpressHandler): MinimalApplication$1;
643
- options(path: Path, handler: RouteHandler): MinimalApplication$1;
644
- options(path: Path, middleware: ExpressMiddleware, handler: ExpressHandler): MinimalApplication$1;
645
- options(path: Path, middleware: MiddlewareHandler, handler: RouteHandler): MinimalApplication$1;
646
- options(path: Path, middleware1: ExpressMiddleware, middleware2: ExpressMiddleware, handler: ExpressHandler): MinimalApplication$1;
647
- options(path: Path, middleware1: ExpressMiddleware, middleware2: ExpressMiddleware, middleware3: ExpressMiddleware, handler: ExpressHandler): MinimalApplication$1;
648
- options(path: Path, ...args: (RouteHandler | ExpressHandler | MiddlewareHandler | ExpressMiddleware)[]): MinimalApplication$1;
649
- all(path: Path, handler: ExpressHandler): MinimalApplication$1;
650
- all(path: Path, handler: RouteHandler): MinimalApplication$1;
651
- all(path: Path, middleware: ExpressMiddleware, handler: ExpressHandler): MinimalApplication$1;
652
- all(path: Path, middleware: MiddlewareHandler, handler: RouteHandler): MinimalApplication$1;
653
- all(path: Path, middleware1: ExpressMiddleware, middleware2: ExpressMiddleware, handler: ExpressHandler): MinimalApplication$1;
654
- all(path: Path, middleware1: ExpressMiddleware, middleware2: ExpressMiddleware, middleware3: ExpressMiddleware, handler: ExpressHandler): MinimalApplication$1;
655
- all(path: Path, ...args: (RouteHandler | ExpressHandler | MiddlewareHandler | ExpressMiddleware)[]): MinimalApplication$1;
656
- use(...args: any[]): MinimalApplication$1;
657
- static(path: string, root?: string): MinimalApplication$1;
658
- setViews: (path: string) => MinimalApplication$1;
659
- render: (...args: any[]) => MinimalApplication$1;
660
- ws: (path: string, handler: WebSocketHandler) => MinimalApplication$1;
661
- listen(port: number | string, hostname?: string | (() => void), callback?: () => void): MinimalApplication$1;
662
- close: (callback?: () => void) => MinimalApplication$1;
663
- }
664
- /**
665
- * Component lifecycle interface
666
- */
667
- interface Lifecycle$1 {
668
- /**
669
- * Called when component is installed into application
670
- */
671
- install?(app: MinimalApplication$1): void | Promise<void>;
672
- /**
673
- * Called when component is uninstalled from application
674
- */
675
- uninstall?(app: MinimalApplication$1): void | Promise<void>;
676
- /**
677
- * Called when application starts
678
- */
679
- start?(): void | Promise<void>;
680
- /**
681
- * Called when application stops
682
- */
683
- stop?(): void | Promise<void>;
143
+ declare class TimeoutError extends NextRushError {
144
+ constructor(message?: string);
684
145
  }
685
-
686
146
  /**
687
- * Abstract base class for components
688
- * Provides a foundation for extensible components with inheritance
689
- *
690
- * @abstract
691
- * @example
692
- * ```typescript
693
- * class RouterComponent extends BaseComponent {
694
- * constructor() {
695
- * super('Router');
696
- * }
697
- *
698
- * public install(app: MinimalApplication): void {
699
- * app.get = this.get.bind(this);
700
- * app.post = this.post.bind(this);
701
- * }
702
- * }
703
- * ```
147
+ * Rate Limit Error (429)
704
148
  */
705
-
149
+ declare class RateLimitError extends NextRushError {
150
+ readonly retryAfter: number;
151
+ constructor(message?: string, retryAfter?: number);
152
+ }
706
153
  /**
707
- * Abstract base class for all components
708
- * Enables OOP with inheritance for extensible component behavior
154
+ * Error Factory for creating common errors
709
155
  */
710
- declare abstract class BaseComponent implements Lifecycle$1 {
711
- /**
712
- * Unique component name
713
- * @readonly
714
- */
715
- readonly name: string;
716
- /**
717
- * Component initialization status
718
- * @protected
719
- */
720
- protected isInitialized: boolean;
721
- /**
722
- * Component running status
723
- * @protected
724
- */
725
- protected isRunning: boolean;
156
+ declare class ErrorFactory {
726
157
  /**
727
- * Reference to the application instance
728
- * @protected
158
+ * Create validation error
729
159
  */
730
- protected app?: MinimalApplication$1;
160
+ static validation(field: string, message: string, value?: unknown): ValidationError;
731
161
  /**
732
- * Create a new base component
733
- * @param name - Unique component name
162
+ * Create not found error
734
163
  */
735
- constructor(name: string);
164
+ static notFound(resource: string): NotFoundError;
736
165
  /**
737
- * Install component on application (abstract - must be implemented)
738
- * @param app - Minimal application instance
739
- * @abstract
166
+ * Create unauthorized error
740
167
  */
741
- abstract install(app: MinimalApplication$1): void | Promise<void>;
168
+ static unauthorized(message?: string): AuthenticationError;
742
169
  /**
743
- * Start component (optional override)
744
- * Called when application starts
170
+ * Create forbidden error
745
171
  */
746
- start(): Promise<void>;
172
+ static forbidden(message?: string): AuthorizationError;
747
173
  /**
748
- * Stop component (optional override)
749
- * Called when application stops
174
+ * Create bad request error
750
175
  */
751
- stop(): Promise<void>;
176
+ static badRequest(message?: string): BadRequestError;
752
177
  /**
753
- * Check if component is initialized
754
- * @returns True if component is initialized
178
+ * Create conflict error
755
179
  */
756
- getIsInitialized(): boolean;
180
+ static conflict(message?: string): ConflictError;
757
181
  /**
758
- * Check if component is running
759
- * @returns True if component is running
182
+ * Create internal server error
760
183
  */
761
- getIsRunning(): boolean;
184
+ static internal(message?: string): InternalServerError;
762
185
  /**
763
- * Get component information
764
- * @returns Component information object
186
+ * Create rate limit error
765
187
  */
766
- getInfo(): ComponentInfo;
188
+ static rateLimit(message?: string, retryAfter?: number): RateLimitError;
767
189
  /**
768
- * Set application reference (called during installation)
769
- * @param app - Application instance
770
- * @protected
190
+ * Create timeout error
771
191
  */
772
- protected setApp(app: MinimalApplication$1): void;
192
+ static timeout(message?: string): TimeoutError;
773
193
  /**
774
- * Ensure component is initialized
775
- * @throws Error if component is not initialized
776
- * @protected
194
+ * Create service unavailable error
777
195
  */
778
- protected ensureInitialized(): void;
196
+ static serviceUnavailable(message?: string): ServiceUnavailableError;
779
197
  /**
780
- * Ensure component is running
781
- * @throws Error if component is not running
782
- * @protected
198
+ * Create database error
783
199
  */
784
- protected ensureRunning(): void;
200
+ static database(message: string, operation: string, table?: string): DatabaseError;
785
201
  /**
786
- * Log component message with name prefix
787
- * @param level - Log level
788
- * @param message - Log message
789
- * @param meta - Optional metadata
790
- * @protected
202
+ * Create network error
791
203
  */
792
- protected log(level: 'info' | 'warn' | 'error', message: string, meta?: any): void;
204
+ static network(message: string, host: string, port: number): NetworkError;
793
205
  }
794
206
  /**
795
- * Component information interface
207
+ * Exception Filter Interface (NestJS style)
796
208
  */
797
- interface ComponentInfo {
798
- name: string;
799
- isInitialized: boolean;
800
- isRunning: boolean;
801
- type: 'component' | 'plugin';
209
+ interface ExceptionFilter {
210
+ catch(error: Error, ctx: any): void | Promise<void>;
802
211
  }
803
-
804
212
  /**
805
- * 🔌 BasePlugin - Core Plugin Implementation
806
- *
807
- * According to copilot instructions, all features must be implemented as plugins
808
- * inheriting from BasePlugin under src/plugins/
213
+ * Global Exception Filter
809
214
  */
810
-
215
+ declare class GlobalExceptionFilter implements ExceptionFilter {
216
+ catch(error: Error, ctx: any): Promise<void>;
217
+ }
811
218
  /**
812
- * Plugin Registry interface for event system and plugin access
219
+ * Exception Filter for specific error types
813
220
  */
814
- interface PluginRegistry {
815
- emit(event: string, ...args: any[]): void;
816
- on(event: string, listener: (...args: any[]) => void): void;
817
- off(event: string, listener: (...args: any[]) => void): void;
818
- getPlugin?(name: string): BasePlugin | undefined;
221
+ declare class ValidationExceptionFilter implements ExceptionFilter {
222
+ catch(error: Error, ctx: any): Promise<void>;
819
223
  }
820
224
  /**
821
- * Base Plugin class that all NextRush plugins must inherit from
822
- * Follows the copilot instructions for unified plugin architecture
225
+ * Exception Filter for authentication errors
823
226
  */
824
- declare abstract class BasePlugin {
825
- abstract name: string;
826
- protected registry: PluginRegistry;
827
- constructor(registry: PluginRegistry);
828
- /**
829
- * Install the plugin into the application
830
- * This is where plugins register their capabilities (app.get, app.use, etc.)
831
- */
832
- abstract install(app: Application): void;
833
- /**
834
- * Start the plugin - activate its functionality
835
- */
836
- abstract start(): void;
837
- /**
838
- * Stop the plugin - deactivate its functionality
839
- */
840
- abstract stop(): void;
841
- /**
842
- * Emit events to other plugins
843
- */
844
- protected emit(event: string, ...args: any[]): void;
845
- /**
846
- * Listen to events from other plugins
847
- */
848
- protected on(event: string, listener: (...args: any[]) => void): void;
849
- /**
850
- * Remove event listener
851
- */
852
- protected off(event: string, listener: (...args: any[]) => void): void;
227
+ declare class AuthenticationExceptionFilter implements ExceptionFilter {
228
+ catch(error: Error, ctx: any): Promise<void>;
853
229
  }
854
-
855
230
  /**
856
- * 🚀 MEGA ULTIMATE PARSER - NextRush Framework
857
- *
858
- * SINGLE UNIFIED PARSER WITH NODEJS RAW POWER + V8 ENGINE OPTIMIZATION
859
- *
860
- * Features:
861
- * - 🔥 Zero-copy buffer operations using Node.js raw power
862
- * - 🚀 V8 engine optimizations for maximum performance
863
- * - 🧠 AI-like content type auto-detection
864
- * - 🌊 Streaming parser with backpressure handling
865
- * - 💾 Memory-pooled buffer management
866
- * - ⚡ CPU-optimized parsing with vectorized operations
867
- * - 🎯 Smart caching and pre-compiled patterns
868
- * - 🛡️ Enterprise-grade error handling
869
- * - 📊 Real-time performance metrics collection
870
- *
871
- * This replaces ALL existing parsers with a single unified solution.
872
- *
873
- * @author NextRush Framework Team
874
- * @version 2.0.0 - MEGA ULTIMATE EDITION
875
- * @since 1.0.0
231
+ * Exception Filter for authorization errors
232
+ */
233
+ declare class AuthorizationExceptionFilter implements ExceptionFilter {
234
+ catch(error: Error, ctx: any): Promise<void>;
235
+ }
236
+ /**
237
+ * Exception Filter for not found errors
876
238
  */
239
+ declare class NotFoundExceptionFilter implements ExceptionFilter {
240
+ catch(error: Error, ctx: any): Promise<void>;
241
+ }
242
+ /**
243
+ * Exception Filter for rate limit errors
244
+ */
245
+ declare class RateLimitExceptionFilter implements ExceptionFilter {
246
+ catch(error: Error, ctx: any): Promise<void>;
247
+ }
877
248
 
878
249
  /**
879
- * 🔧 Ultimate parser configuration with enterprise-grade settings
880
- *
881
- * @interface MegaUltimateParserOptions
250
+ * 🔧 Enhanced parser configuration with enterprise-grade settings
882
251
  */
883
- interface MegaUltimateParserOptions {
252
+ interface EnhancedBodyParserOptions {
884
253
  /** Maximum body size in bytes (default: 10MB) */
885
254
  maxSize?: number;
886
- /** Request timeout in milliseconds (default: 30s) */
255
+ /** Request timeout in milliseconds (default: 5s) */
887
256
  timeout?: number;
888
257
  /** Enable streaming for large payloads (default: true) */
889
258
  enableStreaming?: boolean;
@@ -897,1975 +266,2051 @@ interface MegaUltimateParserOptions {
897
266
  autoDetectContentType?: boolean;
898
267
  /** Strict content type checking (default: false) */
899
268
  strictContentType?: boolean;
900
- /** Enable debug logging (default: false) */
901
- debug?: boolean;
902
- /** Maximum number of files for multipart (default: 10) */
903
- maxFiles?: number;
904
- /** Maximum file size for uploads (default: 5MB) */
905
- maxFileSize?: number;
906
- /** Memory storage for files (default: true) */
907
- memoryStorage?: boolean;
908
- /** Upload directory for disk storage */
909
- uploadDir?: string;
910
- /** Character encoding (default: 'utf8') */
269
+ /** Enable metrics collection (default: true) */
270
+ enableMetrics?: boolean;
271
+ /** Encoding for text-based content (default: 'utf8') */
911
272
  encoding?: BufferEncoding;
273
+ /** Custom error messages */
274
+ errorMessages?: {
275
+ maxSizeExceeded?: string;
276
+ timeoutError?: string;
277
+ invalidContentType?: string;
278
+ parseError?: string;
279
+ };
912
280
  }
281
+
913
282
  /**
914
- * 📊 Performance metrics for monitoring
283
+ * Middleware Types for NextRush v2
915
284
  *
916
- * @interface MegaParserMetrics
285
+ * @packageDocumentation
917
286
  */
918
- interface MegaParserMetrics {
919
- /** Total requests processed */
920
- totalRequests: number;
921
- /** Total parsing time in milliseconds */
922
- totalParseTime: number;
923
- /** Average parsing time per request */
924
- averageParseTime: number;
925
- /** Peak memory usage in bytes */
926
- peakMemoryUsage: number;
927
- /** Cache hit ratio (0-1) */
928
- cacheHitRatio: number;
929
- /** Parse success rate (0-1) */
930
- successRate: number;
931
- /** Total bytes processed */
932
- totalBytesProcessed: number;
933
- }
934
287
 
935
288
  /**
936
- * 🚀 Body Parser Plugin v2.0 - MEGA ULTIMATE EDITION
937
- *
938
- * SINGLE UNIFIED PARSER THAT REPLACES ALL OTHER PARSERS
939
- *
940
- * Features:
941
- * - 🔥 Node.js raw power + V8 optimizations
942
- * - 🧠 Smart auto-detection
943
- * - ⚡ Zero-copy operations
944
- * - 📊 Performance monitoring
945
- * - 🛡️ Enterprise-grade error handling
946
- *
947
- * This plugin replaces:
948
- * - All http/parsers/* files
949
- * - All old body parser implementations
950
- * - Enhanced request parsing conflicts
951
- *
952
- * @author NextRush Framework Team
953
- * @version 2.0.0 - MEGA ULTIMATE EDITION
289
+ * Standard middleware function signature
954
290
  */
291
+ type Middleware$1 = (ctx: Context, next: () => Promise<void>) => Promise<void>;
292
+ /**
293
+ * CORS middleware options
294
+ */
295
+ interface CorsOptions {
296
+ /** Allowed origins */
297
+ origin?: string | string[] | boolean | ((origin: string) => boolean);
298
+ /** Allowed methods */
299
+ methods?: string[];
300
+ /** Allowed headers */
301
+ allowedHeaders?: string[];
302
+ /** Exposed headers */
303
+ exposedHeaders?: string[];
304
+ /** Allow credentials */
305
+ credentials?: boolean;
306
+ /** Max age for preflight */
307
+ maxAge?: number;
308
+ /** Preflight continue */
309
+ preflightContinue?: boolean;
310
+ /** Options success status */
311
+ optionsSuccessStatus?: number;
312
+ }
313
+ /**
314
+ * Helmet middleware options
315
+ */
316
+ interface HelmetOptions {
317
+ /** Content Security Policy */
318
+ contentSecurityPolicy?: {
319
+ directives: Record<string, string[]>;
320
+ reportOnly?: boolean;
321
+ };
322
+ /** HTTP Strict Transport Security */
323
+ hsts?: {
324
+ maxAge: number;
325
+ includeSubDomains?: boolean;
326
+ preload?: boolean;
327
+ };
328
+ /** XSS Protection */
329
+ xssFilter?: boolean;
330
+ /** Content Type Options */
331
+ noSniff?: boolean;
332
+ /** Frame Options */
333
+ frameguard?: {
334
+ action: 'DENY' | 'SAMEORIGIN' | 'ALLOW-FROM';
335
+ domain?: string;
336
+ };
337
+ /** Referrer Policy */
338
+ referrerPolicy?: {
339
+ policy: string;
340
+ };
341
+ /** Hide X-Powered-By header */
342
+ hidePoweredBy?: boolean;
343
+ /** DNS Prefetch Control */
344
+ dnsPrefetchControl?: {
345
+ allow?: boolean;
346
+ };
347
+ /** IE No Open */
348
+ ieNoOpen?: boolean;
349
+ /** Permitted Cross Domain Policies */
350
+ permittedCrossDomainPolicies?: {
351
+ permittedPolicies?: string;
352
+ };
353
+ }
354
+ /**
355
+ * Rate limiter options
356
+ */
357
+ interface RateLimiterOptions {
358
+ /** Time window in milliseconds */
359
+ windowMs?: number;
360
+ /** Maximum requests per window */
361
+ max?: number;
362
+ /** Rate limit message */
363
+ message?: string;
364
+ /** Status code for rate limited requests */
365
+ statusCode?: number;
366
+ /** Include headers */
367
+ headers?: boolean;
368
+ /** Skip successful requests */
369
+ skipSuccessfulRequests?: boolean;
370
+ /** Skip failed requests */
371
+ skipFailedRequests?: boolean;
372
+ /** Key generator function */
373
+ keyGenerator?: (ctx: Context) => string;
374
+ /** Skip function */
375
+ skip?: (ctx: Context) => boolean;
376
+ /** Custom handler */
377
+ handler?: (ctx: Context) => void;
378
+ /** Store implementation */
379
+ store?: {
380
+ get(key: string): {
381
+ count: number;
382
+ resetTime: number;
383
+ } | null;
384
+ increment(key: string): {
385
+ count: number;
386
+ resetTime: number;
387
+ };
388
+ reset(key: string): void;
389
+ clear(): void;
390
+ };
391
+ }
392
+ /**
393
+ * Logger middleware options
394
+ */
395
+ interface LoggerOptions {
396
+ /** Log format */
397
+ format?: 'simple' | 'detailed' | 'json' | 'combined';
398
+ /** Log level */
399
+ level?: 'error' | 'warn' | 'info' | 'http' | 'verbose' | 'debug' | 'silly';
400
+ /** Colorize output */
401
+ colorize?: boolean;
402
+ /** Include timestamp */
403
+ timestamp?: boolean;
404
+ /** Show headers */
405
+ showHeaders?: boolean;
406
+ /** Show body */
407
+ showBody?: boolean;
408
+ /** Show query */
409
+ showQuery?: boolean;
410
+ /** Show response time */
411
+ showResponseTime?: boolean;
412
+ /** Show user agent */
413
+ showUserAgent?: boolean;
414
+ /** Show referer */
415
+ showReferer?: boolean;
416
+ /** Show IP */
417
+ showIP?: boolean;
418
+ /** Show method */
419
+ showMethod?: boolean;
420
+ /** Show URL */
421
+ showURL?: boolean;
422
+ /** Show status */
423
+ showStatus?: boolean;
424
+ /** Show response size */
425
+ showResponseSize?: boolean;
426
+ /** Custom format function */
427
+ customFormat?: (ctx: Context, duration: number) => string;
428
+ /** Filter function */
429
+ filter?: (ctx: Context) => boolean;
430
+ /** Output stream */
431
+ stream?: NodeJS.WritableStream;
432
+ }
433
+ /**
434
+ * Compression middleware options
435
+ */
436
+ interface CompressionOptions {
437
+ /** Compression level (1-9) */
438
+ level?: number;
439
+ /** Minimum size to compress */
440
+ threshold?: number;
441
+ /** Filter function */
442
+ filter?: (ctx: Context) => boolean;
443
+ /** Content types to compress */
444
+ contentType?: string[];
445
+ /** Content types to exclude */
446
+ exclude?: string[];
447
+ /** Enable gzip */
448
+ gzip?: boolean;
449
+ /** Enable deflate */
450
+ deflate?: boolean;
451
+ /** Enable brotli */
452
+ brotli?: boolean;
453
+ /** Window size */
454
+ windowBits?: number;
455
+ /** Memory level */
456
+ memLevel?: number;
457
+ /** Strategy */
458
+ strategy?: number;
459
+ /** Chunk size */
460
+ chunkSize?: number;
461
+ /** Dictionary */
462
+ dictionary?: Buffer;
463
+ /** Enable adaptive compression based on CPU usage */
464
+ adaptive?: boolean;
465
+ /** Maximum CPU usage threshold for adaptive compression (percentage) */
466
+ maxCpuUsage?: number;
467
+ /** Backpressure threshold for skipping compression */
468
+ backpressureThreshold?: number;
469
+ }
470
+ /**
471
+ * Request ID middleware options
472
+ */
473
+ interface RequestIdOptions {
474
+ /** Request ID header name */
475
+ headerName?: string;
476
+ /** Request ID generator function */
477
+ generator?: () => string;
478
+ /** Add to response headers */
479
+ addResponseHeader?: boolean;
480
+ /** Echo existing header */
481
+ echoHeader?: boolean;
482
+ /** Set in context */
483
+ setInContext?: boolean;
484
+ /** Include in logs */
485
+ includeInLogs?: boolean;
486
+ }
487
+ /**
488
+ * Timer middleware options
489
+ */
490
+ interface TimerOptions {
491
+ /** Response time header name */
492
+ header?: string;
493
+ /** Number of decimal places */
494
+ digits?: number;
495
+ /** Time unit suffix */
496
+ suffix?: string;
497
+ /** Include start time */
498
+ includeStartTime?: boolean;
499
+ /** Include end time */
500
+ includeEndTime?: boolean;
501
+ /** Include duration */
502
+ includeDuration?: boolean;
503
+ /** Format type */
504
+ format?: 'milliseconds' | 'seconds' | 'microseconds' | 'nanoseconds';
505
+ /** Threshold for logging */
506
+ threshold?: number;
507
+ /** Log slow requests */
508
+ logSlow?: boolean;
509
+ /** Slow request threshold */
510
+ logSlowThreshold?: number;
511
+ /** Custom format function */
512
+ customFormat?: (duration: number) => string;
513
+ }
955
514
 
956
515
  /**
957
- * 🚀 MEGA ULTIMATE Body Parser Plugin
958
- *
959
- * The single, unified body parser that handles ALL request body parsing
960
- * with maximum performance and zero conflicts.
961
- *
962
- * @class BodyParserPlugin
963
- * @extends BasePlugin
516
+ * Cookie options interface with security defaults
964
517
  */
965
- declare class BodyParserPlugin extends BasePlugin {
966
- name: string;
967
- /** The mega ultimate parser instance */
968
- private megaParser;
969
- /** Plugin options merged from application config */
970
- private options;
971
- /** Debug logging flag */
972
- private debug;
973
- /**
974
- * Initialize the mega ultimate body parser plugin
975
- *
976
- * @param registry - Plugin registry for event communication
977
- */
978
- constructor(registry: any);
979
- /**
980
- * 🔌 Install the body parser plugin
981
- *
982
- * @param app - Application instance
983
- */
984
- install(app: Application): void;
985
- /**
986
- * 🚀 Start the body parser plugin
987
- */
988
- start(): void;
989
- /**
990
- * 🛑 Stop the body parser plugin and cleanup resources
991
- */
992
- stop(): void;
993
- /**
994
- * 🔧 Install the ultimate auto body parser middleware
995
- *
996
- * This replaces ALL existing body parsing logic with a single unified solution
997
- *
998
- * @param app - Application instance
999
- */
1000
- private installAutoBodyParser;
1001
- /**
1002
- * 🎯 Set request body with FIXED property descriptor
1003
- *
1004
- * This fixes the middleware chain issue where req.body becomes undefined
1005
- *
1006
- * @param req - Request object
1007
- * @param body - Parsed body data
1008
- */
1009
- private setRequestBody;
1010
- /**
1011
- * 📊 Get performance metrics from the mega parser
1012
- *
1013
- * @returns MegaParserMetrics - Performance metrics
1014
- */
1015
- getMetrics(): MegaParserMetrics;
1016
- /**
1017
- * 🔧 Update parser options at runtime
1018
- *
1019
- * @param newOptions - New parser options
1020
- */
1021
- updateOptions(newOptions: Partial<MegaUltimateParserOptions>): void;
1022
- /**
1023
- * 🧹 Manual cleanup method for removing debug logs
1024
- */
1025
- static removeDebugLogs(): void;
518
+ interface CookieOptions {
519
+ /** Domain for the cookie */
520
+ domain?: string;
521
+ /** Expiration date */
522
+ expires?: Date;
523
+ /** HTTP Only flag (default: true for security) */
524
+ httpOnly?: boolean;
525
+ /** Max age in seconds */
526
+ maxAge?: number;
527
+ /** Path (default: '/') */
528
+ path?: string;
529
+ /** Priority (Low, Medium, High) */
530
+ priority?: 'Low' | 'Medium' | 'High';
531
+ /** SameSite attribute (default: 'Strict') */
532
+ sameSite?: 'Strict' | 'Lax' | 'None' | boolean;
533
+ /** Secure flag (default: true in production) */
534
+ secure?: boolean;
1026
535
  }
1027
536
 
1028
537
  /**
1029
- * 🎨 Middleware Composition Functions - NextRush Framework
538
+ * Application configuration options
539
+ */
540
+ interface ApplicationOptions {
541
+ /** Port to listen on (default: 3000) */
542
+ port?: number;
543
+ /** Host to bind to (default: 'localhost') */
544
+ host?: string;
545
+ /** Enable debug mode */
546
+ debug?: boolean;
547
+ /** Trust proxy headers */
548
+ trustProxy?: boolean;
549
+ /** Maximum request body size in bytes */
550
+ maxBodySize?: number;
551
+ /** Request timeout in milliseconds */
552
+ timeout?: number;
553
+ /** Enable CORS by default */
554
+ cors?: boolean;
555
+ /** Static files directory */
556
+ static?: string;
557
+ /** Template engine configuration */
558
+ template?: {
559
+ engine: string;
560
+ directory: string;
561
+ };
562
+ /** HTTP keep-alive timeout in milliseconds */
563
+ keepAlive?: number;
564
+ }
565
+ /**
566
+ * Enhanced request object
567
+ */
568
+ interface NextRushRequest extends IncomingMessage {
569
+ /** Request body */
570
+ body?: unknown;
571
+ /** Route parameters */
572
+ params: Record<string, string>;
573
+ /** Query parameters */
574
+ query: ParsedUrlQuery;
575
+ /** Request path */
576
+ path: string;
577
+ /** Client IP address */
578
+ ip: string;
579
+ /** Request protocol */
580
+ protocol: string;
581
+ /** Whether the request is secure */
582
+ secure: boolean;
583
+ /** Original request URL */
584
+ originalUrl: string;
585
+ }
586
+ /**
587
+ * Enhanced response object
588
+ */
589
+ interface NextRushResponse$1 extends ServerResponse {
590
+ /** Set response status code */
591
+ status(code: number): NextRushResponse$1;
592
+ /** Send JSON response (fast by default) */
593
+ json(data: unknown): NextRushResponse$1;
594
+ /** Send HTML response */
595
+ html(data: string): NextRushResponse$1;
596
+ /** Send text response */
597
+ text(data: string): NextRushResponse$1;
598
+ /** Send CSV response */
599
+ csv(data: string): NextRushResponse$1;
600
+ /** Send XML response */
601
+ xml(data: string): NextRushResponse$1;
602
+ /** Send file response */
603
+ file(path: string, options?: {
604
+ root?: string;
605
+ }): NextRushResponse$1;
606
+ /** Send file response (alias) */
607
+ sendFile(path: string, options?: {
608
+ root?: string;
609
+ etag?: boolean;
610
+ }): NextRushResponse$1;
611
+ /** Send download response */
612
+ download(path: string, filename?: string): NextRushResponse$1;
613
+ /** Redirect response */
614
+ redirect(url: string, status?: number): NextRushResponse$1;
615
+ /** Set response header */
616
+ set(name: string, value: string | number | string[]): NextRushResponse$1;
617
+ /** Get response header */
618
+ get(name: string): string | number | string[] | undefined;
619
+ /** Remove response header */
620
+ remove(name: string): NextRushResponse$1;
621
+ /** Set response type */
622
+ type(type: string): NextRushResponse$1;
623
+ /** Set response length */
624
+ length(length: number): NextRushResponse$1;
625
+ /** Set response etag */
626
+ etag(etag: string): NextRushResponse$1;
627
+ /** Set response last modified */
628
+ lastModified(date: Date): NextRushResponse$1;
629
+ }
630
+
631
+ /**
632
+ * Koa-style context types for NextRush v2
1030
633
  *
1031
- * Provides Express-like middleware composition functions:
1032
- * - compose() - Combine multiple middleware
1033
- * - when() - Conditional middleware
1034
- * - unless() - Exclusion middleware
1035
- * - named() - Debug middleware with names
634
+ * @packageDocumentation
1036
635
  */
1037
636
 
1038
637
  /**
1039
- * Compose multiple middleware into a single middleware function
1040
- * Optimized for performance with minimal function calls
1041
- *
1042
- * @example
1043
- * const authFlow = compose(checkApiKey, checkUser, rateLimit);
1044
- * app.get('/protected', authFlow, handler);
638
+ * WebSocket connection interface
1045
639
  */
1046
- declare function compose(...middlewares: ExpressMiddleware$1[]): ExpressMiddleware$1;
640
+ interface WSConnection {
641
+ /** Unique connection ID */
642
+ id: string;
643
+ /** WebSocket request URL */
644
+ url: string;
645
+ /** Connection alive status */
646
+ isAlive: boolean;
647
+ /** Last pong timestamp */
648
+ lastPong: number;
649
+ /** Send message to client */
650
+ send(data: string | Buffer): void;
651
+ /** Close connection */
652
+ close(code?: number, reason?: string): void;
653
+ /** Join a room */
654
+ join(room: string): void;
655
+ /** Leave a room */
656
+ leave(room: string): void;
657
+ /** Listen for incoming messages */
658
+ onMessage(listener: (data: string | Buffer) => void): void;
659
+ /** Listen for connection close */
660
+ onClose(listener: (code: number, reason: string) => void): void;
661
+ }
662
+ /**
663
+ * WebSocket route handler type
664
+ */
665
+ type WSHandler = (socket: WSConnection, req: IncomingMessage) => void | Promise<void>;
666
+ /**
667
+ * WebSocket middleware type
668
+ */
669
+ type WSMiddleware = (socket: WSConnection, req: IncomingMessage, next: () => void) => void | Promise<void>;
670
+ /**
671
+ * WebSocket plugin options
672
+ */
673
+ interface WebSocketPluginOptions {
674
+ /** Accepted paths (exact or wildcard *) */
675
+ path?: string | string[];
676
+ /** Ping interval in milliseconds */
677
+ heartbeatMs?: number;
678
+ /** Close if no pong within this timeout */
679
+ pongTimeoutMs?: number;
680
+ /** Maximum concurrent connections */
681
+ maxConnections?: number;
682
+ /** Maximum message size in bytes */
683
+ maxMessageSize?: number;
684
+ /** Allowed origins for CORS */
685
+ allowOrigins?: (string | RegExp)[];
686
+ /** Custom client verification */
687
+ verifyClient?: (req: IncomingMessage) => Promise<boolean> | boolean;
688
+ /** Debug mode */
689
+ debug?: boolean;
690
+ }
1047
691
  /**
1048
- * Conditionally apply middleware based on a condition function
1049
- *
1050
- * @example
1051
- * const mobileOnly = when(
1052
- * (req) => req.headers['user-agent']?.includes('Mobile'),
1053
- * mobileOptimization
1054
- * );
692
+ * Enhanced response object with Express-like methods
1055
693
  */
1056
- declare function when(condition: (req: NextRushRequest) => boolean, middleware: ExpressMiddleware$1): ExpressMiddleware$1;
694
+ interface NextRushResponse extends ServerResponse {
695
+ /** Send JSON response */
696
+ json(data: unknown): NextRushResponse;
697
+ /** Send HTML response */
698
+ html(data: string): NextRushResponse;
699
+ /** Send text response */
700
+ text(data: string): NextRushResponse;
701
+ /** Send CSV response */
702
+ csv(data: string): NextRushResponse;
703
+ /** Send XML response */
704
+ xml(data: string): NextRushResponse;
705
+ /** Send any data type response */
706
+ send(data: string | Buffer | object): void;
707
+ /** Stream response */
708
+ stream(stream: NodeJS.ReadableStream, contentType?: string): void;
709
+ /** Render HTML from a template string or a template name under viewsDir */
710
+ render(templateOrName: string, data?: Record<string, unknown>, options?: {
711
+ layout?: string;
712
+ }): Promise<void>;
713
+ /** Send file response (alias) */
714
+ file(path: string, options?: {
715
+ root?: string;
716
+ etag?: boolean;
717
+ }): NextRushResponse;
718
+ /** Send file response */
719
+ sendFile(path: string, options?: {
720
+ root?: string;
721
+ etag?: boolean;
722
+ }): NextRushResponse;
723
+ /** Send download response */
724
+ download(path: string, filename?: string): NextRushResponse;
725
+ /** Redirect response */
726
+ redirect(url: string, status?: number): NextRushResponse;
727
+ /** Permanent redirect (301) */
728
+ redirectPermanent(url: string): NextRushResponse;
729
+ /** Temporary redirect (307) */
730
+ redirectTemporary(url: string): NextRushResponse;
731
+ /** Set response status */
732
+ status(code: number): NextRushResponse;
733
+ /** Set response header */
734
+ set(name: string, value: string | number | string[]): NextRushResponse;
735
+ /** Set response header (alias) */
736
+ header(field: string, value: string): NextRushResponse;
737
+ /** Get response header */
738
+ get(name: string): string | number | string[] | undefined;
739
+ /** Remove response header */
740
+ remove(name: string): NextRushResponse;
741
+ /** Remove response header (implementation method) */
742
+ removeHeader(field: string): NextRushResponse;
743
+ /** Set response type */
744
+ type(type: string): NextRushResponse;
745
+ /** Set response length */
746
+ length(length: number): NextRushResponse;
747
+ /** Set response etag */
748
+ etag(etag: string): NextRushResponse;
749
+ /** Set response last modified */
750
+ lastModified(date: Date): NextRushResponse;
751
+ /** Set cookie */
752
+ cookie(name: string, value: string, options?: CookieOptions): NextRushResponse;
753
+ /** Clear cookie */
754
+ clearCookie(name: string, options?: CookieOptions): NextRushResponse;
755
+ /** Set cache headers */
756
+ cache(seconds: number): NextRushResponse;
757
+ /** Disable caching */
758
+ noCache(): NextRushResponse;
759
+ /** Set CORS headers */
760
+ cors(origin?: string): NextRushResponse;
761
+ /** Set security headers */
762
+ security(): NextRushResponse;
763
+ /** Enable compression hint */
764
+ compress(): NextRushResponse;
765
+ /** Send success response */
766
+ success(data: unknown, message?: string): void;
767
+ /** Send error response */
768
+ error(message: string, code?: number, details?: unknown): void;
769
+ /** Send paginated response */
770
+ paginate(data: unknown[], page: number, limit: number, total: number): void;
771
+ /** Get content type from file extension */
772
+ getContentTypeFromExtension(ext: string): string;
773
+ /** Get smart content type from file path */
774
+ getSmartContentType(filePath: string): string;
775
+ /** Generate ETag from stats */
776
+ generateETag(stats: unknown): string;
777
+ /** Convert data to CSV */
778
+ convertToCSV(data: unknown[]): string;
779
+ /** Add timing header */
780
+ time(label?: string): NextRushResponse;
781
+ /** Get nested value from object */
782
+ getNestedValue(obj: unknown, path: string): unknown;
783
+ /** Check if value is truthy */
784
+ isTruthy(value: unknown): boolean;
785
+ }
1057
786
  /**
1058
- * Apply middleware UNLESS a condition is true (opposite of when)
1059
- *
1060
- * @example
1061
- * const authExceptPublic = unless(
1062
- * (req) => req.path.startsWith('/public'),
1063
- * requireAuth
1064
- * );
787
+ * Koa-style context interface
1065
788
  */
1066
- declare function unless(condition: (req: NextRushRequest) => boolean, middleware: ExpressMiddleware$1): ExpressMiddleware$1;
789
+ interface Context {
790
+ /** Request object (Express-like) */
791
+ req: NextRushRequest;
792
+ /** Response object (Express-like) */
793
+ res: NextRushResponse;
794
+ /** Request body (Express-like) */
795
+ body: unknown;
796
+ /** Request method */
797
+ method: string;
798
+ /** Request URL */
799
+ url: string;
800
+ /** Request path */
801
+ path: string;
802
+ /** Request headers */
803
+ headers: IncomingMessage['headers'];
804
+ /** Query parameters */
805
+ query: ParsedUrlQuery;
806
+ /** Route parameters */
807
+ params: Record<string, string>;
808
+ /** Request ID for tracing */
809
+ id: string | undefined;
810
+ /** Request ID for logging (alternative to id) */
811
+ requestId?: string;
812
+ /** Request-specific logger */
813
+ logger?: {
814
+ log: (...args: unknown[]) => void;
815
+ error: (...args: unknown[]) => void;
816
+ warn: (...args: unknown[]) => void;
817
+ info: (...args: unknown[]) => void;
818
+ };
819
+ /** State object for middleware communication */
820
+ state: Record<string, unknown>;
821
+ /** Request start time */
822
+ startTime: number;
823
+ /** Get client IP */
824
+ ip: string;
825
+ /** Check if request is secure */
826
+ secure: boolean;
827
+ /** Request protocol */
828
+ protocol: string;
829
+ /** Request hostname */
830
+ hostname: string;
831
+ /** Request host */
832
+ host: string;
833
+ /** Request origin */
834
+ origin: string;
835
+ /** Request href */
836
+ href: string;
837
+ /** Request search */
838
+ search: string;
839
+ /** Request search params */
840
+ searchParams: URLSearchParams;
841
+ /** Response status */
842
+ status: number;
843
+ /** Response headers */
844
+ responseHeaders: Record<string, string | number | string[]>;
845
+ /** Throw an error */
846
+ throw(status: number, message?: string): never;
847
+ /** Assert a condition */
848
+ assert(condition: unknown, status: number, message?: string): asserts condition;
849
+ /** Check if response is fresh */
850
+ fresh(): boolean;
851
+ /** Check if response is stale */
852
+ stale(): boolean;
853
+ /** Check if request is idempotent */
854
+ idempotent(): boolean;
855
+ /** Check if request is cacheable */
856
+ cacheable(): boolean;
857
+ /** Set response header (Koa-style) */
858
+ set(name: string, value: string | number | string[]): void;
859
+ /** Send a file using the enhanced response */
860
+ sendFile(path: string, options?: {
861
+ root?: string;
862
+ etag?: boolean;
863
+ }): void;
864
+ /** Render HTML from a template string or a template name under viewsDir */
865
+ render(templateOrName: string, data?: Record<string, unknown>, options?: {
866
+ layout?: string;
867
+ }): Promise<void>;
868
+ /** Send JSON response (convenience for ctx.res.json) */
869
+ json(data: unknown): void;
870
+ /** Send response data (convenience for ctx.res.send) */
871
+ send(data: string | Buffer | object): void;
872
+ /** Redirect response (convenience for ctx.res.redirect) */
873
+ redirect(url: string, statusCode?: number): void;
874
+ /** Set cookie (convenience for ctx.res.cookie) */
875
+ cookie(name: string, value: string, options?: CookieOptions): NextRushResponse;
876
+ }
1067
877
  /**
1068
- * Give middleware a name for easier debugging and tracking
1069
- *
1070
- * @example
1071
- * app.use(named('rate-limiter', rateLimitMiddleware));
1072
- * app.use(named('auth-check', authMiddleware));
878
+ * Next function for middleware
1073
879
  */
1074
- declare function named(name: string, middleware: ExpressMiddleware$1): ExpressMiddleware$1;
880
+ type Next = () => Promise<void>;
1075
881
  /**
1076
- * Create a group of middleware that can be applied together
1077
- *
1078
- * @example
1079
- * const securityGroup = group([cors(), helmet(), rateLimit()]);
1080
- * app.use('/api', securityGroup);
882
+ * Middleware function type
1081
883
  */
1082
- declare function group(middlewares: ExpressMiddleware$1[]): ExpressMiddleware$1;
1083
-
884
+ type Middleware = (ctx: Context, next: Next) => Promise<void>;
1084
885
  /**
1085
- * 📁 Static Files Types & Interfaces
1086
- * Core type definitions for NextRush Static Files system
886
+ * Route handler function type
1087
887
  */
1088
-
888
+ type RouteHandler = (ctx: Context) => Promise<void> | void;
889
+ /** Dotfiles policy for static files */
890
+ type DotfilesPolicy = 'ignore' | 'deny' | 'allow';
891
+ /** Options for StaticFilesPlugin */
892
+ interface StaticFilesOptions {
893
+ /** Absolute directory to serve files from */
894
+ root: string;
895
+ /** URL prefix to mount under, e.g., "/static"; default: '' (root) */
896
+ prefix?: `/${string}` | '';
897
+ /** Default index file to serve for directories; set false to disable */
898
+ index?: string | false;
899
+ /** If true, call next() on 404 instead of sending 404; default: false */
900
+ fallthrough?: boolean;
901
+ /** If true, redirect directory request without trailing slash to slash; default: true */
902
+ redirect?: boolean;
903
+ /** Send Cache-Control max-age seconds; default: 0 (no explicit caching) */
904
+ maxAge?: number;
905
+ /** Add immutable directive to Cache-Control when maxAge > 0; default: false */
906
+ immutable?: boolean;
907
+ /** Control dotfiles serving; default: 'ignore' (404) */
908
+ dotfiles?: DotfilesPolicy;
909
+ /** Additional extensions to try when file not found (e.g., ['.html']); default: [] */
910
+ extensions?: string[];
911
+ /** Hook to customize headers */
912
+ setHeaders?: (ctx: Context, absolutePath: string, stat: StatsLike) => void;
913
+ }
914
+ /** Stats-like interface for static files */
915
+ interface StatsLike {
916
+ isFile(): boolean;
917
+ isDirectory(): boolean;
918
+ size: number;
919
+ mtime: Date;
920
+ }
921
+ /** Options for TemplatePlugin */
922
+ interface TemplatePluginOptions {
923
+ /** Directory containing template files */
924
+ viewsDir?: string;
925
+ /** Enable template caching; default: true */
926
+ cache?: boolean;
927
+ /** Custom helper functions */
928
+ helpers?: Record<string, (value: unknown, ...args: unknown[]) => unknown>;
929
+ /** Preloaded partial templates */
930
+ partials?: Record<string, string>;
931
+ /** Enable loading partials from viewsDir; default: true */
932
+ enableFilePartials?: boolean;
933
+ /** File extension for partials; default: '.html' */
934
+ partialExt?: string;
935
+ }
936
+ /** Template helper function type */
937
+ type TemplateHelper = (value: unknown, ...args: unknown[]) => unknown;
938
+ /** Template render options */
939
+ interface TemplateRenderOptions {
940
+ /** Layout template to wrap content in */
941
+ layout?: string;
942
+ }
1089
943
  /**
1090
- * Static files statistics
944
+ * Route configuration object (Fastify-style)
1091
945
  */
1092
- interface StaticStats {
1093
- totalRequests: number;
1094
- cacheHits: number;
1095
- compressionHits: number;
1096
- bytesServed: number;
1097
- filesCached: number;
1098
- cacheSize: number;
1099
- mounts: number;
1100
- uptime: number;
946
+ interface RouteConfig {
947
+ /** Route handler */
948
+ handler: RouteHandler;
949
+ /** Route middleware */
950
+ middleware?: Middleware[];
951
+ /** Route schema validation */
952
+ schema?: {
953
+ body?: Record<string, unknown>;
954
+ query?: Record<string, unknown>;
955
+ params?: Record<string, unknown>;
956
+ response?: Record<string, unknown>;
957
+ };
958
+ /** Route options */
959
+ options?: {
960
+ /** Route name */
961
+ name?: string;
962
+ /** Route description */
963
+ description?: string;
964
+ /** Route tags */
965
+ tags?: string[];
966
+ /** Route version */
967
+ version?: string;
968
+ /** Route deprecated */
969
+ deprecated?: boolean;
970
+ /** Route summary */
971
+ summary?: string;
972
+ /** Route external docs */
973
+ externalDocs?: {
974
+ description: string;
975
+ url: string;
976
+ };
977
+ };
1101
978
  }
1102
-
1103
979
  /**
1104
- * 📁 NextRush Static Files Plugin
980
+ * Route data with handler and middleware
981
+ */
982
+ interface RouteData {
983
+ handler: RouteHandler;
984
+ middleware: Middleware[];
985
+ }
986
+ /**
987
+ * Router interface for modular routing
988
+ */
989
+ interface Router {
990
+ /** Register GET route */
991
+ get(path: string, handler: RouteHandler | RouteConfig): Router;
992
+ /** Register POST route */
993
+ post(path: string, handler: RouteHandler | RouteConfig): Router;
994
+ /** Register PUT route */
995
+ put(path: string, handler: RouteHandler | RouteConfig): Router;
996
+ /** Register DELETE route */
997
+ delete(path: string, handler: RouteHandler | RouteConfig): Router;
998
+ /** Register PATCH route */
999
+ patch(path: string, handler: RouteHandler | RouteConfig): Router;
1000
+ /** Register middleware */
1001
+ use(middleware: Middleware): Router;
1002
+ /** Register sub-router */
1003
+ use(prefix: string, router: Router): Router;
1004
+ /** Get router middleware */
1005
+ getMiddleware(): Middleware[];
1006
+ /** Get router routes */
1007
+ getRoutes(): Map<string, RouteData>;
1008
+ }
1009
+ /**
1010
+ * Application interface (forward declaration)
1011
+ */
1012
+ interface Application {
1013
+ /** Register GET route */
1014
+ get(path: string, handler: RouteHandler | RouteConfig): Application;
1015
+ /** Register POST route */
1016
+ post(path: string, handler: RouteHandler | RouteConfig): Application;
1017
+ /** Register PUT route */
1018
+ put(path: string, handler: RouteHandler | RouteConfig): Application;
1019
+ /** Register DELETE route */
1020
+ delete(path: string, handler: RouteHandler | RouteConfig): Application;
1021
+ /** Register PATCH route */
1022
+ patch(path: string, handler: RouteHandler | RouteConfig): Application;
1023
+ /** Register middleware */
1024
+ use(middleware: Middleware): Application;
1025
+ /** Register router */
1026
+ use(prefix: string, router: Router): Application;
1027
+ /** Create router */
1028
+ router(): Router;
1029
+ /** Start the server */
1030
+ listen(port?: number, callback?: () => void): unknown;
1031
+ listen(port?: number, host?: string, callback?: () => void): unknown;
1032
+ /** Get the underlying HTTP server */
1033
+ getServer(): unknown;
1034
+ /** Gracefully shutdown the application */
1035
+ shutdown(): Promise<void>;
1036
+ /** Create CORS middleware */
1037
+ cors(options?: CorsOptions): Middleware;
1038
+ /** Create helmet middleware */
1039
+ helmet(options?: HelmetOptions): Middleware;
1040
+ /** Create JSON body parser middleware */
1041
+ json(options?: EnhancedBodyParserOptions): Middleware;
1042
+ /** Create URL-encoded body parser middleware */
1043
+ urlencoded(options?: EnhancedBodyParserOptions): Middleware;
1044
+ /** Create text body parser middleware */
1045
+ text(options?: EnhancedBodyParserOptions): Middleware;
1046
+ /** Create rate limiter middleware */
1047
+ rateLimit(options?: RateLimiterOptions): Middleware;
1048
+ /** Create logger middleware */
1049
+ logger(options?: LoggerOptions): Middleware;
1050
+ /** Create compression middleware */
1051
+ compression(options?: CompressionOptions): Middleware;
1052
+ /** Create request ID middleware */
1053
+ requestId(options?: RequestIdOptions): Middleware;
1054
+ /** Create timer middleware */
1055
+ timer(options?: TimerOptions): Middleware;
1056
+ /** Create smart body parser middleware */
1057
+ smartBodyParser(options?: EnhancedBodyParserOptions): Middleware;
1058
+ /** Create exception filter middleware */
1059
+ exceptionFilter(filters?: ExceptionFilter[]): Middleware;
1060
+ /** Simple Events API for Express-style event handling */
1061
+ events: {
1062
+ /** Emit a simple string-based event */
1063
+ emit(eventName: string, data?: any): Promise<void>;
1064
+ /** Listen for a simple string-based event */
1065
+ on(eventName: string, handler: (data: any) => void | Promise<void>): () => void;
1066
+ /** Listen for a simple string-based event (once) */
1067
+ once(eventName: string, handler?: (data: any) => void | Promise<void>): Promise<any>;
1068
+ /** Remove all listeners for an event */
1069
+ off(eventName: string): void;
1070
+ /** Remove all listeners */
1071
+ removeAllListeners(): void;
1072
+ /** Get list of event names that have listeners */
1073
+ eventNames(): string[];
1074
+ /** Get number of listeners for an event */
1075
+ listenerCount(eventName: string): number;
1076
+ /** Get maximum number of listeners */
1077
+ getMaxListeners(): number;
1078
+ /** Set maximum number of listeners */
1079
+ setMaxListeners(n: number): any;
1080
+ };
1081
+ /** Advanced Event System for CQRS and Event Sourcing */
1082
+ eventSystem: {
1083
+ /** Emit events */
1084
+ emit(event: any): Promise<void>;
1085
+ /** Subscribe to events */
1086
+ subscribe(eventType: string, handler: (event: any) => void | Promise<void>): {
1087
+ unsubscribe(): void;
1088
+ };
1089
+ /** Additional advanced methods available but not typed here for brevity */
1090
+ [key: string]: any;
1091
+ };
1092
+ /** Logger instance (set by LoggerPlugin) - overrides logger method when plugin is installed */
1093
+ loggerInstance?: {
1094
+ error: (message: string, context?: Record<string, unknown>) => void;
1095
+ warn: (message: string, context?: Record<string, unknown>) => void;
1096
+ info: (message: string, context?: Record<string, unknown>) => void;
1097
+ debug: (message: string, context?: Record<string, unknown>) => void;
1098
+ trace: (message: string, context?: Record<string, unknown>) => void;
1099
+ log: (message: string, context?: Record<string, unknown>) => void;
1100
+ };
1101
+ /** Register a WebSocket route (exact path or with trailing * wildcard) */
1102
+ ws?: (path: string, handler: WSHandler) => Application;
1103
+ /** Register a WebSocket middleware executed before the handler */
1104
+ wsUse?: (middleware: WSMiddleware) => Application;
1105
+ /** Broadcast a message to all sockets or a specific room */
1106
+ wsBroadcast?: (message: string, room?: string) => Application;
1107
+ /** Register a static files route */
1108
+ static?: (prefix: string, root: string, options?: StaticFilesOptions) => Application;
1109
+ /** Register template engine and view directory */
1110
+ setViewEngine?: (engine: string, viewsDir?: string, options?: TemplatePluginOptions) => Application;
1111
+ /** Add template helper */
1112
+ helper?: (name: string, fn: (value: unknown, ...args: unknown[]) => unknown) => Application;
1113
+ /** Add template partial */
1114
+ partial?: (name: string, template: string) => Application;
1115
+ }
1116
+
1117
+ /**
1118
+ * Base plugin class for NextRush v2
1105
1119
  *
1106
- * Enterprise-grade static file serving with:
1107
- * - 🗜️ Smart compression (gzip/brotli)
1108
- * - 💾 Intelligent LRU caching
1109
- * - 📡 Range requests for streaming
1110
- * - 🔒 Comprehensive security
1111
- * - 🚀 High-performance optimization
1112
- * - 📱 SPA support with fallback
1120
+ * @packageDocumentation
1113
1121
  */
1114
1122
 
1115
1123
  /**
1116
- * NextRush Static Files Plugin
1124
+ * Plugin interface
1117
1125
  */
1118
- declare class StaticFilesPlugin extends BasePlugin {
1126
+ interface Plugin {
1127
+ /** Plugin name */
1128
+ name: string;
1129
+ /** Plugin version */
1130
+ version: string;
1131
+ /** Plugin description */
1132
+ description?: string;
1133
+ /** Plugin author */
1134
+ author?: string;
1135
+ /** Plugin homepage */
1136
+ homepage?: string;
1137
+ /** Plugin license */
1138
+ license?: string;
1139
+ /** Plugin keywords */
1140
+ keywords?: string[];
1141
+ /** Install plugin on application */
1142
+ install(app: Application): void;
1143
+ /** Plugin initialization */
1144
+ init?(): void | Promise<void>;
1145
+ /** Plugin cleanup */
1146
+ cleanup?(): void | Promise<void>;
1147
+ /** Plugin configuration validation */
1148
+ validateConfig?(): boolean;
1149
+ /** Plugin health check */
1150
+ healthCheck?(): Promise<boolean>;
1151
+ }
1152
+ /**
1153
+ * Plugin metadata interface
1154
+ */
1155
+ interface PluginMetadata {
1119
1156
  name: string;
1120
- private cacheManager;
1121
- private compressionHandler;
1122
- private mimeTypeHandler;
1123
- private rangeHandler;
1124
- private securityHandler;
1125
- private mounts;
1126
- private stats;
1127
- private maintenanceInterval;
1128
- constructor(registry: PluginRegistry);
1129
- /**
1130
- * Install static file serving capabilities
1157
+ version: string;
1158
+ description?: string;
1159
+ author?: string;
1160
+ homepage?: string;
1161
+ license?: string;
1162
+ keywords?: string[];
1163
+ dependencies?: string[];
1164
+ conflicts?: string[];
1165
+ }
1166
+ /**
1167
+ * Base plugin class that all plugins should extend
1168
+ *
1169
+ * @example
1170
+ * ```typescript
1171
+ * import { BasePlugin } from 'nextrush-v2';
1172
+ * import type { Application } from 'nextrush-v2';
1173
+ *
1174
+ * export class MyPlugin extends BasePlugin {
1175
+ * name = 'MyPlugin';
1176
+ * version = '1.0.0';
1177
+ * description = 'A custom plugin';
1178
+ *
1179
+ * install(app: Application): void {
1180
+ * // Plugin installation logic
1181
+ * app.use((req, res, next) => {
1182
+ * // Middleware logic
1183
+ * next();
1184
+ * });
1185
+ * }
1186
+ *
1187
+ * async init(): Promise<void> {
1188
+ * // Plugin initialization
1189
+ * }
1190
+ *
1191
+ * async cleanup(): Promise<void> {
1192
+ * // Plugin cleanup
1193
+ * }
1194
+ * }
1195
+ * ```
1196
+ */
1197
+ declare abstract class BasePlugin implements Plugin {
1198
+ abstract name: string;
1199
+ abstract version: string;
1200
+ abstract onInstall(app: Application): void;
1201
+ description?: string;
1202
+ author?: string;
1203
+ homepage?: string;
1204
+ license?: string;
1205
+ keywords?: string[];
1206
+ dependencies?: string[];
1207
+ conflicts?: string[];
1208
+ protected app?: Application;
1209
+ protected config: Record<string, unknown>;
1210
+ protected isInitialized: boolean;
1211
+ protected isInstalled: boolean;
1212
+ /**
1213
+ * Install the plugin on an application
1131
1214
  */
1132
1215
  install(app: Application): void;
1133
1216
  /**
1134
- * Start the plugin
1217
+ * Abstract method that plugins must implement
1135
1218
  */
1136
- start(): void;
1137
1219
  /**
1138
- * Stop the plugin
1220
+ * Get plugin metadata
1139
1221
  */
1140
- stop(): void;
1222
+ getMetadata(): PluginMetadata;
1141
1223
  /**
1142
- * Get comprehensive statistics
1224
+ * Set plugin configuration
1143
1225
  */
1144
- getStats(): StaticStats & {
1145
- cache: any;
1146
- };
1226
+ setConfig(config: Record<string, unknown>): void;
1147
1227
  /**
1148
- * Add static mount
1228
+ * Get plugin configuration
1149
1229
  */
1150
- private addMount;
1230
+ getConfig(): Record<string, unknown>;
1151
1231
  /**
1152
- * Handle incoming requests
1232
+ * Get a specific configuration value
1153
1233
  */
1154
- private handleRequest;
1234
+ getConfigValue<T>(key: string, defaultValue?: T): T | undefined;
1155
1235
  /**
1156
- * Serve file from specific mount
1236
+ * Check if plugin is installed
1157
1237
  */
1158
- private serveFromMount;
1238
+ isPluginInstalled(): boolean;
1159
1239
  /**
1160
- * Serve directory with index files
1240
+ * Check if plugin is initialized
1161
1241
  */
1162
- private serveDirectory;
1242
+ isPluginInitialized(): boolean;
1163
1243
  /**
1164
- * Serve individual file with all optimizations
1244
+ * Register middleware with the application
1165
1245
  */
1166
- private serveFile;
1246
+ protected registerMiddleware(middleware: Middleware): void;
1167
1247
  /**
1168
- * Create optimized cache entry
1248
+ * Log plugin message
1169
1249
  */
1170
- private createCacheEntry;
1250
+ protected log(message: string): void;
1171
1251
  /**
1172
- * Handle conditional requests (ETag, If-Modified-Since)
1252
+ * Log plugin error
1173
1253
  */
1174
- private handleConditionalRequest;
1254
+ protected logError(message: string, error?: Error): void;
1175
1255
  /**
1176
- * Handle range requests
1256
+ * Log plugin warning
1177
1257
  */
1178
- private handleRangeRequest;
1258
+ protected logWarning(message: string): void;
1179
1259
  /**
1180
- * Send file with optimized headers and compression
1260
+ * Log plugin debug message
1181
1261
  */
1182
- private sendFile;
1262
+ protected logDebug(message: string): void;
1183
1263
  /**
1184
- * Serve SPA fallback
1264
+ * Emit plugin event
1185
1265
  */
1186
- private serveSpaFallback;
1266
+ protected emit(event: string, ...args: unknown[]): void;
1187
1267
  /**
1188
- * Set cache control headers
1268
+ * Create a middleware that wraps the plugin's functionality
1189
1269
  */
1190
- private setCacheControl;
1270
+ protected createMiddleware(handler: (ctx: Context, next: () => Promise<void>) => void | Promise<void>): Middleware;
1191
1271
  /**
1192
- * Utility methods
1272
+ * Create an async middleware that wraps the plugin's functionality
1193
1273
  */
1194
- private shouldCache;
1195
- private isPathUnderMount;
1196
- private normalizePath;
1197
- private parseMaxAge;
1274
+ protected createAsyncMiddleware(handler: (ctx: Context, next: () => Promise<void>) => Promise<void>): Middleware;
1198
1275
  /**
1199
- * Initialize modular components
1276
+ * Validate plugin configuration
1200
1277
  */
1201
- private initializeComponents;
1278
+ validateConfig(): boolean;
1202
1279
  /**
1203
- * Start maintenance tasks
1280
+ * Plugin health check
1204
1281
  */
1205
- private startMaintenance;
1282
+ healthCheck(): Promise<boolean>;
1206
1283
  /**
1207
- * Stop maintenance tasks
1284
+ * Get plugin status
1208
1285
  */
1209
- private stopMaintenance;
1286
+ getStatus(): Record<string, unknown>;
1210
1287
  }
1211
1288
 
1212
1289
  /**
1213
- * 🚀 NextRush Performance-Optimized Plugin System
1290
+ * Logger Types and Interfaces for NextRush v2
1214
1291
  *
1215
- * Reduces plugin overhead from 12 plugins to 3-5 essential plugins
1216
- * for maximum performance in production environments.
1217
- *
1218
- * Expected Performance Improvement: +25-30% (400-500 RPS)
1219
- */
1220
-
1221
- /**
1222
- * Plugin loading strategy based on environment
1223
- */
1224
- declare enum PluginMode {
1225
- PERFORMANCE = "performance",// 4 plugins - max performance
1226
- DEVELOPMENT = "development",// 6 plugins - debugging tools
1227
- FULL_FEATURES = "full"
1292
+ * @packageDocumentation
1293
+ */
1294
+ declare enum LogLevel {
1295
+ ERROR = 0,
1296
+ WARN = 1,
1297
+ INFO = 2,
1298
+ DEBUG = 3,
1299
+ TRACE = 4
1300
+ }
1301
+ interface LogEntry {
1302
+ timestamp: Date | string;
1303
+ level: LogLevel | string;
1304
+ message: string;
1305
+ context?: Record<string, unknown>;
1306
+ error?: Error;
1307
+ }
1308
+ interface LoggerConfig extends Record<string, unknown> {
1309
+ level?: LogLevel;
1310
+ format?: 'json' | 'text' | 'simple';
1311
+ timestamp?: boolean;
1312
+ colors?: boolean;
1313
+ maxEntries?: number;
1314
+ flushInterval?: number;
1315
+ maxMemoryUsage?: number;
1316
+ asyncFlush?: boolean;
1317
+ transports?: Array<{
1318
+ type: 'console' | 'file' | 'stream';
1319
+ options?: Record<string, unknown>;
1320
+ }>;
1321
+ }
1322
+ /**
1323
+ * Transport interface
1324
+ */
1325
+ interface Transport {
1326
+ name: string;
1327
+ level: string;
1328
+ write(entry: LogEntry): void | Promise<void>;
1228
1329
  }
1229
- /**
1230
- * Create plugins based on mode
1231
- */
1232
- declare function createPlugins(registry: PluginRegistry, mode?: PluginMode): any[];
1233
1330
 
1234
1331
  /**
1235
- * 🚀 NextRush Application - Complete, Type-Safe Framework
1332
+ * Core Logger Plugin for NextRush v2
1236
1333
  *
1237
- * Zero `any` usage, proper overloads, createRoute feature, enterprise-grade typing
1334
+ * @packageDocumentation
1238
1335
  */
1239
1336
 
1240
- interface ApplicationOptions {
1241
- router?: Router;
1242
- routerOptions?: RouterOptions;
1243
- errorHandler?: ErrorHandler;
1244
- timeout?: number;
1245
- maxRequestSize?: number;
1246
- enableEvents?: boolean;
1247
- enableWebSocket?: boolean;
1248
- caseSensitive?: boolean;
1249
- strict?: boolean;
1250
- pluginMode?: PluginMode;
1251
- bodyParser?: {
1252
- debug?: boolean;
1253
- maxSize?: number;
1254
- timeout?: number;
1255
- enableStreaming?: boolean;
1256
- autoDetectContentType?: boolean;
1257
- [key: string]: any;
1258
- };
1259
- }
1260
- interface StaticOptions {
1261
- maxAge?: string | number;
1262
- etag?: boolean;
1263
- index?: string | string[] | false;
1264
- dotfiles?: 'allow' | 'deny' | 'ignore';
1265
- extensions?: string[] | false;
1266
- immutable?: boolean;
1267
- redirect?: boolean;
1268
- spa?: boolean;
1269
- compress?: boolean | 'auto';
1270
- memoryCache?: boolean;
1271
- acceptRanges?: boolean;
1272
- cacheControl?: string;
1273
- setHeaders?: (res: any, path: string) => void;
1274
- }
1275
- interface RouteDefinition {
1276
- method: HttpMethod;
1277
- path: Path;
1278
- handler: RouteHandler$1 | ExpressHandler$1;
1279
- middleware?: (MiddlewareHandler$1 | ExpressMiddleware$1)[];
1280
- name?: string;
1281
- description?: string;
1282
- }
1283
- /**
1284
- * 🔥 NextRush Application - Enterprise-Grade with Proper Typing
1285
- */
1286
- declare class Application extends BaseComponent {
1287
- private router;
1288
- private errorHandler;
1289
- private httpServer?;
1290
- private appOptions;
1291
- events?: SimpleEventEmitter;
1292
- private viewsDirectory?;
1293
- private pluginRegistry;
1294
- constructor(applicationOptions?: ApplicationOptions);
1295
- /**
1296
- * Install method required by BaseComponent
1297
- */
1298
- install(): void;
1299
- testMethod(): string;
1300
- /**
1301
- * 🔌 Initialize the plugin system
1302
- */
1303
- private initializePlugins;
1304
- /**
1305
- * GET method with comprehensive overloads - Express-style compatibility
1306
- */
1307
- get(path: Path, handler: ExpressHandler$1): Application;
1308
- get(path: Path, handler: RouteHandler$1): Application;
1309
- get(path: Path, middleware: ExpressMiddleware$1, handler: ExpressHandler$1): Application;
1310
- get(path: Path, middleware: ExpressMiddleware$1, handler: RouteHandler$1): Application;
1311
- get(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, handler: ExpressHandler$1): Application;
1312
- get(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, handler: RouteHandler$1): Application;
1313
- get(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, middleware3: ExpressMiddleware$1, handler: ExpressHandler$1): Application;
1314
- get(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, middleware3: ExpressMiddleware$1, handler: RouteHandler$1): Application;
1315
- /**
1316
- * POST method with comprehensive overloads - Express-style compatibility
1317
- */
1318
- post(path: Path, handler: ExpressHandler$1): Application;
1319
- post(path: Path, handler: RouteHandler$1): Application;
1320
- post(path: Path, middleware: ExpressMiddleware$1, handler: ExpressHandler$1): Application;
1321
- post(path: Path, middleware: ExpressMiddleware$1, handler: RouteHandler$1): Application;
1322
- post(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, handler: ExpressHandler$1): Application;
1323
- post(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, handler: RouteHandler$1): Application;
1324
- /**
1325
- * PUT method with comprehensive overloads - Express-style compatibility
1326
- */
1327
- put(path: Path, handler: ExpressHandler$1): Application;
1328
- put(path: Path, handler: RouteHandler$1): Application;
1329
- put(path: Path, middleware: ExpressMiddleware$1, handler: ExpressHandler$1): Application;
1330
- put(path: Path, middleware: ExpressMiddleware$1, handler: RouteHandler$1): Application;
1331
- put(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, handler: ExpressHandler$1): Application;
1332
- put(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, handler: RouteHandler$1): Application;
1337
+ declare class LoggerPlugin extends BasePlugin {
1338
+ name: string;
1339
+ version: string;
1340
+ config: LoggerConfig;
1341
+ private entries;
1342
+ private flushTimer?;
1343
+ private _transports;
1344
+ private eventListeners;
1345
+ constructor(config?: LoggerConfig);
1346
+ onInstall(app: Application): void;
1347
+ private startFlushTimer;
1348
+ private stopFlushTimer;
1349
+ private addEntry;
1350
+ /**
1351
+ * Check memory usage and flush if necessary
1352
+ */
1353
+ private checkMemoryUsage;
1354
+ private flush;
1355
+ private writeToTransport;
1356
+ /**
1357
+ * Write latest entry to all transports
1358
+ */
1359
+ private writeToTransports;
1360
+ error(message: string, context?: Record<string, unknown>): void;
1361
+ warn(message: string, context?: Record<string, unknown>): void;
1362
+ info(message: string, context?: Record<string, unknown>): void;
1363
+ debug(message: string, context?: Record<string, unknown>): void;
1364
+ trace(message: string, context?: Record<string, unknown>): void;
1365
+ log(message: string, context?: Record<string, unknown>): void;
1366
+ getEntries(): LogEntry[];
1367
+ clear(): void;
1368
+ setLevel(level: LogLevel | string): void;
1333
1369
  /**
1334
- * DELETE method with comprehensive overloads - Express-style compatibility
1370
+ * Add a transport
1335
1371
  */
1336
- delete(path: Path, handler: ExpressHandler$1): Application;
1337
- delete(path: Path, handler: RouteHandler$1): Application;
1338
- delete(path: Path, middleware: ExpressMiddleware$1, handler: ExpressHandler$1): Application;
1339
- delete(path: Path, middleware: ExpressMiddleware$1, handler: RouteHandler$1): Application;
1340
- delete(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, handler: ExpressHandler$1): Application;
1341
- delete(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, handler: RouteHandler$1): Application;
1372
+ addTransport(transport: Transport): void;
1342
1373
  /**
1343
- * PATCH method with comprehensive overloads - Express-style compatibility
1374
+ * Remove a transport by name
1344
1375
  */
1345
- patch(path: Path, handler: ExpressHandler$1): Application;
1346
- patch(path: Path, handler: RouteHandler$1): Application;
1347
- patch(path: Path, middleware: ExpressMiddleware$1, handler: ExpressHandler$1): Application;
1348
- patch(path: Path, middleware: ExpressMiddleware$1, handler: RouteHandler$1): Application;
1349
- patch(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, handler: ExpressHandler$1): Application;
1350
- patch(path: Path, middleware1: ExpressMiddleware$1, middleware2: ExpressMiddleware$1, handler: RouteHandler$1): Application;
1376
+ removeTransport(name: string): void;
1351
1377
  /**
1352
- * HEAD method with comprehensive overloads - Express-style compatibility
1378
+ * Add event listener
1353
1379
  */
1354
- head(path: Path, handler: ExpressHandler$1): Application;
1355
- head(path: Path, handler: RouteHandler$1): Application;
1356
- head(path: Path, middleware: ExpressMiddleware$1, handler: ExpressHandler$1): Application;
1357
- head(path: Path, middleware: ExpressMiddleware$1, handler: RouteHandler$1): Application;
1380
+ on(event: string, listener: (entry: LogEntry) => void): void;
1358
1381
  /**
1359
- * OPTIONS method with comprehensive overloads - Express-style compatibility
1382
+ * Remove event listener
1360
1383
  */
1361
- options(path: Path, handler: ExpressHandler$1): Application;
1362
- options(path: Path, handler: RouteHandler$1): Application;
1363
- options(path: Path, middleware: ExpressMiddleware$1, handler: ExpressHandler$1): Application;
1364
- options(path: Path, middleware: ExpressMiddleware$1, handler: RouteHandler$1): Application;
1384
+ off(event: string, listener: (entry: LogEntry) => void): void;
1365
1385
  /**
1366
- * ALL method - matches all HTTP methods with comprehensive overloads
1386
+ * Log a message (internal method for testing)
1367
1387
  */
1368
- all(path: Path, handler: ExpressHandler$1): Application;
1369
- all(path: Path, handler: RouteHandler$1): Application;
1370
- all(path: Path, middleware: ExpressMiddleware$1, handler: ExpressHandler$1): Application;
1371
- all(path: Path, middleware: ExpressMiddleware$1, handler: RouteHandler$1): Application;
1388
+ logMessage(level: LogLevel | string, message: string, context?: Record<string, unknown>): void;
1372
1389
  /**
1373
- * Use middleware with proper overloads - Express-style compatibility
1390
+ * Get transports (for testing)
1374
1391
  */
1375
- use(middleware: (req: NextRushRequest, res: NextRushResponse, next: () => void) => void | Promise<void>): Application;
1376
- use(middleware: (context: RequestContext, next: () => Promise<void>) => void | Promise<void>): Application;
1377
- use(path: Path, middleware: (req: NextRushRequest, res: NextRushResponse, next: () => void) => void | Promise<void>): Application;
1378
- use(path: Path, middleware: (context: RequestContext, next: () => Promise<void>) => void | Promise<void>): Application;
1379
- use(path: Path, router: Router): Application;
1392
+ getTransports(): Transport[];
1380
1393
  /**
1381
- * Create a route definition without immediately registering it
1394
+ * Get transports property (for testing)
1382
1395
  */
1383
- createRoute(definition: RouteDefinition): Route;
1384
- /**
1385
- * Register a pre-created route
1386
- */
1387
- addCreatedRoute(route: Route): Application;
1388
- /**
1389
- * Create and register route in one step
1390
- */
1391
- route(definition: RouteDefinition): Application;
1392
- private templateEngine?;
1393
- private templateOptions;
1394
- /**
1395
- * Set the template engine for Ultimate Template support
1396
- */
1397
- setTemplateEngine(engine: any): this;
1398
- /**
1399
- * Start the server - BaseComponent method
1400
- */
1401
- start(): Promise<void>;
1402
- /**
1403
- * Stop the server - BaseComponent method
1404
- */
1405
- stop(): Promise<void>;
1406
- private addRoute;
1407
- private convertHandler;
1408
- private convertMiddleware;
1409
- private generateRouteId;
1410
- private createServer;
1396
+ get transports(): Transport[];
1397
+ cleanup(): void;
1411
1398
  }
1412
1399
 
1413
1400
  /**
1414
- * 🔄 Event-Driven Architecture Plugin - NextRush Framework
1401
+ * Logger Factory Functions for NextRush v2
1415
1402
  *
1416
- * Provides comprehensive event-driven capabilities with pub/sub patterns,
1417
- * event sourcing, and reactive programming features.
1403
+ * @packageDocumentation
1418
1404
  */
1419
1405
 
1420
1406
  /**
1421
- * Event middleware options
1407
+ * Create minimal logger for testing
1422
1408
  */
1423
- interface EventMiddlewareOptions {
1424
- autoEmit?: boolean;
1425
- events?: string[];
1426
- includeRequest?: boolean;
1427
- includeResponse?: boolean;
1428
- }
1409
+ declare function createMinimalLogger(): LoggerPlugin;
1429
1410
  /**
1430
- * Event pipeline configuration
1411
+ * Create development logger
1431
1412
  */
1432
- interface EventPipeline {
1433
- name: string;
1434
- events: string[];
1435
- handler: (eventData: any) => void | Promise<void>;
1436
- filters?: Array<(data: any) => boolean>;
1437
- }
1413
+ declare function createDevLogger(): LoggerPlugin;
1438
1414
  /**
1439
- * 🔄 Event-Driven Architecture Plugin
1415
+ * Create production logger
1440
1416
  */
1441
- declare class EventDrivenPlugin extends BasePlugin {
1442
- name: string;
1443
- private eventEmitter;
1444
- private listeners;
1445
- private pipelines;
1446
- private eventHistory;
1447
- private maxHistorySize;
1448
- constructor(registry: PluginRegistry);
1449
- /**
1450
- * Install event-driven capabilities
1451
- */
1452
- install(app: Application): void;
1453
- /**
1454
- * Start the event-driven plugin
1455
- */
1456
- start(): void;
1457
- /**
1458
- * Stop the event-driven plugin
1459
- */
1460
- stop(): void;
1461
- /**
1462
- * 📢 Add event listener
1463
- */
1464
- addEventListener(event: string, handler: (...args: any[]) => void | Promise<void>, options?: {
1465
- priority?: number;
1466
- }): string;
1467
- /**
1468
- * 📢 Add one-time event listener
1469
- */
1470
- addEventListenerOnce(event: string, handler: (...args: any[]) => void | Promise<void>): string;
1471
- /**
1472
- * 🚫 Remove event listener
1473
- */
1474
- removeEventListener(event: string, listenerId?: string): boolean;
1475
- /**
1476
- * 📡 Emit event
1477
- */
1478
- emitEvent(event: string, data?: any): void;
1479
- /**
1480
- * 🔧 Create event pipeline
1481
- */
1482
- createPipeline(name: string, config: Omit<EventPipeline, 'name'>): void;
1483
- /**
1484
- * ⚡ Trigger specific pipeline
1485
- */
1486
- triggerPipeline(name: string, data?: any): void;
1487
- /**
1488
- * 🔧 Create event middleware
1489
- */
1490
- createEventMiddleware(options?: EventMiddlewareOptions): (req: NextRushRequest, res: NextRushResponse, next: () => void) => void;
1491
- /**
1492
- * 📊 Get event statistics
1493
- */
1494
- getEventStats(): any;
1495
- /**
1496
- * 📝 Add event to history
1497
- */
1498
- private addToHistory;
1499
- /**
1500
- * ⚡ Trigger pipelines for event
1501
- */
1502
- private triggerPipelinesForEvent;
1503
- /**
1504
- * 🔧 Generate unique ID
1505
- */
1506
- private generateId;
1507
- }
1417
+ declare function createProdLogger(): LoggerPlugin;
1508
1418
 
1509
1419
  /**
1510
- * 🛡️ Validation & Sanitization Plugin - NextRush Framework
1420
+ * Logger Transport implementations for NextRush v2
1511
1421
  *
1512
- * Provides comprehensive input validation, sanitization, and security features
1513
- * following the unified plugin architecture.
1422
+ * @packageDocumentation
1514
1423
  */
1515
1424
 
1516
1425
  /**
1517
- * Validation rule interface
1518
- */
1519
- interface ValidationRule {
1520
- required?: boolean;
1521
- type?: 'string' | 'number' | 'email' | 'url' | 'boolean' | 'array' | 'object';
1522
- minLength?: number;
1523
- maxLength?: number;
1524
- min?: number;
1525
- max?: number;
1526
- pattern?: RegExp;
1527
- in?: any[];
1528
- custom?: (value: any) => boolean | string;
1529
- }
1530
- /**
1531
- * Validation schema
1426
+ * Console Transport
1532
1427
  */
1533
- interface ValidationSchema {
1534
- [field: string]: ValidationRule;
1428
+ declare class ConsoleTransport implements Transport {
1429
+ name: string;
1430
+ private _level;
1431
+ private _levelString;
1432
+ constructor(level?: LogLevel | string);
1433
+ get levelString(): string;
1434
+ get level(): string;
1435
+ set level(value: LogLevel | string);
1436
+ write(entry: LogEntry): void;
1535
1437
  }
1536
1438
  /**
1537
- * Sanitization options
1439
+ * File Transport
1538
1440
  */
1539
- interface SanitizationOptions {
1540
- removeHtml?: boolean;
1541
- escapeHtml?: boolean;
1542
- trim?: boolean;
1543
- lowercase?: boolean;
1544
- uppercase?: boolean;
1545
- removeSpecialChars?: boolean;
1546
- allowedTags?: string[];
1441
+ declare class FileTransport implements Transport {
1442
+ name: string;
1443
+ private _level;
1444
+ private filePath;
1445
+ private _levelString;
1446
+ constructor(filePath: string, level?: LogLevel | string);
1447
+ get levelString(): string;
1448
+ get level(): string;
1449
+ set level(value: LogLevel | string);
1450
+ write(entry: LogEntry): Promise<void>;
1547
1451
  }
1548
1452
  /**
1549
- * Validation result
1453
+ * HTTP Transport
1550
1454
  */
1551
- interface ValidationResult {
1552
- isValid: boolean;
1553
- errors: Record<string, string[]>;
1554
- sanitized: Record<string, any>;
1455
+ declare class HttpTransport implements Transport {
1456
+ name: string;
1457
+ private _level;
1458
+ private url;
1459
+ private _levelString;
1460
+ constructor(url: string, level?: LogLevel | string);
1461
+ get levelString(): string;
1462
+ get level(): string;
1463
+ set level(value: LogLevel | string);
1464
+ write(entry: LogEntry): Promise<void>;
1555
1465
  }
1556
1466
  /**
1557
- * 🛡️ Validation & Sanitization Plugin
1467
+ * Stream Transport
1558
1468
  */
1559
- declare class ValidationPlugin extends BasePlugin {
1469
+ declare class StreamTransport implements Transport {
1560
1470
  name: string;
1561
- constructor(registry: PluginRegistry);
1562
- /**
1563
- * Install validation capabilities
1564
- */
1565
- install(app: Application): void;
1566
- /**
1567
- * Start the validation plugin
1568
- */
1569
- start(): void;
1570
- /**
1571
- * Stop the validation plugin
1572
- */
1573
- stop(): void;
1574
- /**
1575
- * 🔍 Validate request against schema
1576
- */
1577
- private validateRequest;
1578
- /**
1579
- * 🧹 Sanitize data recursively
1580
- */
1581
- private sanitizeData;
1582
- /**
1583
- * 🧹 Sanitize string value
1584
- */
1585
- private sanitizeString;
1586
- /**
1587
- * 🔍 Validate specific type
1588
- */
1589
- private validateType;
1590
- /**
1591
- * 🔍 Check if value is empty
1592
- */
1593
- private isEmpty;
1471
+ private _level;
1472
+ private stream;
1473
+ private _levelString;
1474
+ constructor(stream: NodeJS.WritableStream, level?: LogLevel | string);
1475
+ get levelString(): string;
1476
+ get level(): string;
1477
+ set level(value: LogLevel | string);
1478
+ write(entry: LogEntry): void;
1594
1479
  }
1595
1480
 
1596
1481
  /**
1597
- * 🔐 Auth Plugin Interfaces - NextRush Framework
1482
+ * Core Application class for NextRush v2
1598
1483
  *
1599
- * Type definitions for authentication, authorization, and session management.
1484
+ * @packageDocumentation
1600
1485
  */
1486
+
1601
1487
  /**
1602
- * JWT configuration options
1603
- */
1604
- interface JwtOptions {
1605
- secret: string;
1606
- algorithm?: 'HS256' | 'HS384' | 'HS512';
1607
- expiresIn?: string | number;
1608
- issuer?: string;
1609
- audience?: string;
1610
- notBefore?: string | number;
1611
- }
1612
- /**
1613
- * Session configuration options
1488
+ * Create a new NextRush application instance
1489
+ *
1490
+ * @param options - Application configuration options
1491
+ * @returns Application instance
1492
+ *
1493
+ * @example
1494
+ * ```typescript
1495
+ * import { createApp } from 'nextrush-v2';
1496
+ *
1497
+ * const app = createApp({
1498
+ * port: 3000,
1499
+ * host: 'localhost',
1500
+ * cors: true,
1501
+ * });
1502
+ *
1503
+ * app.use(app.cors());
1504
+ * app.use(app.helmet());
1505
+ *
1506
+ * app.get('/hello', (ctx) => {
1507
+ * ctx.res.json({ message: 'Hello, World!' });
1508
+ * });
1509
+ *
1510
+ * app.listen(3000, () => {
1511
+ * console.log('Server running on http://localhost:3000');
1512
+ * });
1513
+ * ```
1614
1514
  */
1615
- interface SessionOptions {
1616
- secret: string;
1617
- name?: string;
1618
- maxAge?: number;
1619
- secure?: boolean;
1620
- httpOnly?: boolean;
1621
- sameSite?: 'strict' | 'lax' | 'none';
1622
- rolling?: boolean;
1623
- store?: SessionStore;
1624
- }
1515
+ declare function createApp(options?: ApplicationOptions): Application;
1516
+
1625
1517
  /**
1626
- * User interface for authentication
1518
+ * Context factory for NextRush v2
1519
+ *
1520
+ * @packageDocumentation
1627
1521
  */
1628
- interface User {
1629
- id: string | number;
1630
- username?: string;
1631
- email?: string;
1632
- roles?: string[];
1633
- permissions?: string[];
1634
- metadata?: Record<string, unknown>;
1635
- }
1522
+
1636
1523
  /**
1637
- * Session data interface
1524
+ * Create a Koa-style context object with Express-like design
1525
+ *
1526
+ * @param req - HTTP request object
1527
+ * @param res - HTTP response object
1528
+ * @param options - Application options
1529
+ * @returns Enhanced context object
1530
+ *
1531
+ * @example
1532
+ * ```typescript
1533
+ * import { createContext } from '@/core/context';
1534
+ *
1535
+ * const ctx = createContext(req, res, options);
1536
+ * console.log(ctx.req.ip()); // Client IP
1537
+ * ctx.res.json({ message: 'Hello' });
1538
+ * ```
1638
1539
  */
1639
- interface SessionData {
1640
- id: string;
1641
- userId: string | number;
1642
- data: Record<string, unknown>;
1643
- createdAt: number;
1644
- lastAccess: number;
1645
- expiresAt: number;
1646
- }
1540
+ declare function createContext(req: IncomingMessage | NextRushRequest, res: ServerResponse | NextRushResponse, _options: Required<ApplicationOptions>): Context;
1541
+
1647
1542
  /**
1648
- * Session store interface
1543
+ * Static Files Plugin for NextRush v2
1544
+ *
1545
+ * Express/Koa/Fastify-inspired static file serving with strong DX and security.
1546
+ *
1547
+ * - Prefix-based mounting (virtual path)
1548
+ * - Safe path resolution (prevents traversal)
1549
+ * - ETag/Last-Modified + 304 handling
1550
+ * - Range requests (single range)
1551
+ * - Cache-Control with maxAge/immutable
1552
+ * - HEAD support
1553
+ * - Optional index.html serving and directory redirect
1554
+ * - Dotfiles policy (ignore/deny/allow)
1555
+ * - Optional custom header hook
1556
+ *
1557
+ * @packageDocumentation
1649
1558
  */
1650
- interface SessionStore {
1651
- get(sessionId: string): Promise<SessionData | undefined>;
1652
- set(sessionId: string, data: SessionData): Promise<void>;
1653
- destroy(sessionId: string): Promise<void>;
1654
- cleanup(): Promise<void>;
1655
- }
1559
+
1656
1560
  /**
1657
- * RBAC permissions interface
1561
+ * StaticFilesPlugin
1658
1562
  */
1659
- interface Permission {
1660
- resource: string;
1661
- action: string;
1662
- conditions?: Record<string, any>;
1563
+ declare class StaticFilesPlugin extends BasePlugin {
1564
+ private readonly userOptions;
1565
+ name: string;
1566
+ version: string;
1567
+ description: string;
1568
+ private options;
1569
+ constructor(userOptions: StaticFilesOptions);
1570
+ onInstall(app: Application): void;
1571
+ private normalizeOptions;
1572
+ private createStaticMiddleware;
1573
+ private failOrNext;
1663
1574
  }
1575
+
1664
1576
  /**
1665
- * Role interface
1666
- */
1667
- interface Role {
1577
+ * Template Plugin for NextRush v2
1578
+ *
1579
+ * Safe, minimal, helper-based HTML templating with auto-escaping.
1580
+ *
1581
+ * Features:
1582
+ * - Auto-escape by default; triple mustache {{{expr}}} to output raw
1583
+ * - Helpers: stripHTML, json, upper, lower, date, safe
1584
+ * - Partials: {{> partialName}} (inline or file-based when viewsDir is set)
1585
+ * - Nested path access: {{user.name}}, {{profile.bio}}
1586
+ * - File-based rendering when viewsDir provided; otherwise inline templates
1587
+ * - Simple cache of compiled templates (in-memory)
1588
+ * - Block syntax:
1589
+ * - Conditionals: {{#if cond}}...{{else}}...{{/if}}
1590
+ * - Loops: {{#each items}}...{{/each}} with {{this}}, {{@index}}, {{@key}}
1591
+ * - With: {{#with obj}}...{{/with}}
1592
+ * - Layouts (when viewsDir provided): render(template, data, { layout: 'layout.html' })
1593
+ */
1594
+
1595
+ declare class TemplatePlugin extends BasePlugin {
1668
1596
  name: string;
1669
- permissions: Permission[];
1670
- inherits?: string[];
1597
+ version: string;
1598
+ description: string;
1599
+ private engine;
1600
+ constructor(options?: TemplatePluginOptions);
1601
+ onInstall(app: Application): void;
1602
+ }
1603
+
1604
+ declare class WSRoomManager extends EventEmitter {
1605
+ private rooms;
1606
+ add(socket: WSConnection, room: string): void;
1607
+ remove(socket: WSConnection, room: string): void;
1608
+ leaveAll(socket: WSConnection): void;
1609
+ broadcast(room: string, data: string | Buffer, exclude?: WSConnection): void;
1610
+ getRooms(): string[];
1671
1611
  }
1672
1612
 
1673
1613
  /**
1674
- * 🛡️ RBAC Manager - NextRush Framework
1614
+ * WebSocket Plugin Type Augmentation
1675
1615
  *
1676
- * Role-Based Access Control with hierarchical permissions and inheritance.
1616
+ * This file provides type-safe WebSocket functionality through smart type casting
1617
+ * and utility types for perfect TypeScript intelligence.
1677
1618
  */
1678
1619
 
1679
- /**
1680
- * Predefined roles for common use cases
1681
- */
1682
- declare const CommonRoles: {
1683
- admin: () => Role;
1684
- user: () => Role;
1685
- moderator: () => Role;
1686
- editor: () => Role;
1687
- viewer: () => Role;
1688
- };
1620
+ interface WebSocketApplication extends Application {
1621
+ ws: (path: string, handler: WSHandler) => WebSocketApplication;
1622
+ wsUse: (middleware: WSMiddleware) => WebSocketApplication;
1623
+ wsBroadcast: (message: string, room?: string) => WebSocketApplication;
1624
+ }
1625
+ declare function hasWebSocketSupport(app: Application): app is WebSocketApplication;
1626
+ declare function withWebSocket(app: Application): WebSocketApplication;
1689
1627
 
1690
1628
  /**
1691
- * 🔥 CORS Types - High-Performance Type Definitions
1692
- * Zero memory leaks, enterprise-grade CORS configuration
1629
+ * WebSocket Plugin for NextRush v2 - Context-based Architecture
1630
+ * Provides WebSocket functionality through context enhancement
1693
1631
  */
1694
- type CorsOrigin = string | string[] | boolean | CorsOriginFunction;
1695
- type CorsOriginFunction = (origin: string | undefined, callback: (err: Error | null, allow?: boolean) => void) => void;
1696
- type CorsMethod = 'GET' | 'HEAD' | 'PUT' | 'PATCH' | 'POST' | 'DELETE' | 'OPTIONS';
1697
- interface CorsOptions {
1698
- /** Allowed origins for CORS requests */
1699
- origin?: CorsOrigin;
1700
- /** Allowed HTTP methods */
1701
- methods?: string | string[] | CorsMethod[];
1702
- /** Allowed request headers */
1703
- allowedHeaders?: string | string[];
1704
- /** Headers exposed to the client */
1705
- exposedHeaders?: string | string[];
1706
- /** Allow credentials in cross-origin requests */
1707
- credentials?: boolean;
1708
- /** Preflight cache duration in seconds */
1709
- maxAge?: number;
1710
- /** Continue to next middleware after preflight */
1711
- preflightContinue?: boolean;
1712
- /** Success status code for OPTIONS requests */
1713
- optionsSuccessStatus?: number;
1714
- /** Handle preflight requests automatically */
1715
- preflight?: boolean;
1716
- /** Enable origin caching for performance */
1717
- cacheOrigins?: boolean;
1718
- /** Cache TTL in milliseconds */
1719
- cacheTtl?: number;
1720
- /** Enable CORS metrics collection */
1721
- enableMetrics?: boolean;
1722
- }
1723
- declare enum CorsPresetType {
1724
- ALLOW_ALL = "allow_all",
1725
- STRICT = "strict",
1726
- DEVELOPMENT = "development",
1727
- PRODUCTION = "production",
1728
- API_ONLY = "api_only",
1729
- MICROSERVICE = "microservice"
1730
- }
1731
1632
 
1732
1633
  /**
1733
- * 🔥 CORS Presets - Production-Ready Configurations
1734
- * Optimized CORS configurations for different environments and use cases
1634
+ * Enhanced Context with WebSocket functionality
1735
1635
  */
1736
-
1636
+ interface WSContext extends Context {
1637
+ /** WebSocket connection (available when request is upgraded) */
1638
+ ws?: WSConnection;
1639
+ /** Check if request is WebSocket upgrade request */
1640
+ isWebSocket: boolean;
1641
+ /** WebSocket room manager */
1642
+ wsRooms: WSRoomManager;
1643
+ }
1737
1644
  /**
1738
- * 🚀 CORS Presets Factory
1645
+ * WebSocket Plugin for NextRush v2
1646
+ *
1647
+ * Enhances context with WebSocket functionality following v2 architecture patterns
1739
1648
  */
1740
- declare class CorsPresets {
1649
+ declare class WebSocketPlugin extends BasePlugin {
1650
+ name: string;
1651
+ version: string;
1652
+ description: string;
1653
+ private options;
1654
+ private roomManager;
1655
+ private connections;
1656
+ private routes;
1657
+ private middlewares;
1658
+ private heartbeatTimer;
1659
+ constructor(options?: WebSocketPluginOptions);
1660
+ /**
1661
+ * Install WebSocket plugin - adds WebSocket middleware to app
1662
+ */
1663
+ onInstall(app: Application): void;
1664
+ /**
1665
+ * Start heartbeat timer for connection cleanup
1666
+ */
1667
+ private startHeartbeat;
1668
+ /**
1669
+ * Cleanup plugin resources
1670
+ */
1671
+ cleanup(): void;
1672
+ /**
1673
+ * Setup HTTP upgrade event handler
1674
+ */
1675
+ private setupUpgradeHandler;
1676
+ /**
1677
+ * Handle HTTP to WebSocket upgrade
1678
+ */
1679
+ private handleUpgrade;
1741
1680
  /**
1742
- * Allow all origins - suitable for public APIs (use with caution)
1681
+ * Execute WebSocket middlewares
1743
1682
  */
1744
- static allowAll(): CorsOptions;
1683
+ private executeMiddlewares;
1745
1684
  /**
1746
- * Strict CORS - only specified origins with credentials
1685
+ * Handle WebSocket upgrade in middleware context
1747
1686
  */
1748
- static strict(allowedOrigins: string[]): CorsOptions;
1687
+ private handleWebSocketUpgrade;
1749
1688
  /**
1750
- * Development-friendly CORS - very permissive for testing
1689
+ * Verify WebSocket upgrade request
1751
1690
  */
1752
- static development(): CorsOptions;
1691
+ private verifyUpgrade;
1753
1692
  /**
1754
- * Production-safe CORS with security focus
1693
+ * Perform WebSocket handshake
1755
1694
  */
1756
- static production(allowedOrigins: string[]): CorsOptions;
1695
+ private performHandshake;
1757
1696
  /**
1758
- * API-only CORS (no credentials, suitable for public APIs)
1697
+ * Generate WebSocket accept key
1759
1698
  */
1760
- static apiOnly(allowedOrigins?: string[]): CorsOptions;
1699
+ private generateAcceptKey;
1761
1700
  /**
1762
- * Microservice CORS - for service-to-service communication
1701
+ * Check if request is WebSocket upgrade request
1763
1702
  */
1764
- static microservice(serviceOrigins: string[]): CorsOptions;
1703
+ private isWebSocketRequest;
1765
1704
  /**
1766
- * WebApp CORS - for traditional web applications
1705
+ * Check if path matches registered WebSocket routes
1767
1706
  */
1768
- static webApp(allowedOrigins: string[]): CorsOptions;
1707
+ private matchPath;
1769
1708
  /**
1770
- * SPA (Single Page Application) CORS
1709
+ * Reject WebSocket connection
1771
1710
  */
1772
- static spa(allowedOrigins: string[]): CorsOptions;
1711
+ private rejectConnection;
1773
1712
  /**
1774
- * Get preset by type
1713
+ * Get all active connections
1775
1714
  */
1776
- static getPreset(type: CorsPresetType, origins?: string[]): CorsOptions;
1715
+ getConnections(): WSConnection[];
1777
1716
  /**
1778
- * Get environment-based preset
1717
+ * Broadcast message to all connections
1779
1718
  */
1780
- static getEnvironmentPreset(env?: string, origins?: string[]): CorsOptions;
1719
+ broadcast(message: string, room?: string): void;
1781
1720
  /**
1782
- * Merge multiple CORS options (later options override earlier ones)
1721
+ * Get connection statistics
1783
1722
  */
1784
- static merge(...optionsArray: CorsOptions[]): CorsOptions;
1723
+ getStats(): {
1724
+ totalConnections: number;
1725
+ rooms: string[];
1726
+ handlers: number;
1727
+ };
1785
1728
  }
1786
1729
 
1787
1730
  /**
1788
- * 🛡️ Rate Limiter Plugin - NextRush Framework
1731
+ * 🚀 Smart Body Parser Dispatcher - NextRush v2
1732
+ *
1733
+ * INTELLIGENT CONTENT-TYPE AWARE PARSER LOADER
1734
+ *
1735
+ * 🎯 **PERFORMANCE BREAKTHROUGH:**
1736
+ * - 🔥 Only loads the parser you need based on Content-Type
1737
+ * - ⚡ JSON request → Only loads JSON parser (~150 lines)
1738
+ * - 🌊 Multipart request → Only loads multipart parser (~200 lines)
1739
+ * - 🎭 Form request → Only loads URL-encoded parser (~150 lines)
1740
+ * - 📄 Text request → Only loads text parser (~100 lines)
1741
+ * - 💾 Raw request → Only loads raw parser (~100 lines)
1742
+ *
1743
+ * OLD WAY: Every request loads 1,032 lines ❌
1744
+ * NEW WAY: Each request loads only 100-200 lines ✅
1789
1745
  *
1790
- * Built-in rate limiting with memory and Redis backends.
1791
- * Prevents abuse and controls traffic with configurable windows and limits.
1746
+ * @author NextRush Framework Team
1747
+ * @version 2.0.0
1792
1748
  */
1793
1749
 
1794
1750
  /**
1795
- * Rate limiter options
1751
+ * 🌍 Global smart parser instance (removed unused variable)
1796
1752
  */
1797
- interface RateLimiterOptions {
1798
- windowMs?: number;
1799
- max?: number;
1800
- message?: string;
1801
- statusCode?: number;
1802
- standardHeaders?: boolean;
1803
- legacyHeaders?: boolean;
1804
- skipSuccessfulRequests?: boolean;
1805
- skipFailedRequests?: boolean;
1806
- keyGenerator?: (req: NextRushRequest) => string;
1807
- skip?: (req: NextRushRequest) => boolean;
1808
- handler?: (req: NextRushRequest, res: NextRushResponse) => void;
1809
- store?: RateLimiterStore;
1810
- onLimitReached?: (req: NextRushRequest, options: RateLimiterOptions) => void;
1811
- }
1812
1753
  /**
1813
- * Rate limiter store interface
1754
+ * 🚀 Create smart body parser middleware
1814
1755
  */
1815
- interface RateLimiterStore {
1816
- get(key: string): Promise<RateLimiterData | undefined>;
1817
- set(key: string, data: RateLimiterData, windowMs: number): Promise<void>;
1818
- increment(key: string, windowMs: number): Promise<RateLimiterData>;
1819
- reset(key: string): Promise<void>;
1820
- resetAll(): Promise<void>;
1821
- }
1756
+ declare function smartBodyParser(options?: EnhancedBodyParserOptions): Middleware;
1757
+
1822
1758
  /**
1823
- * Rate limiter data structure
1759
+ * Compression middleware for NextRush v2
1760
+ *
1761
+ * @packageDocumentation
1824
1762
  */
1825
- interface RateLimiterData {
1826
- count: number;
1827
- resetTime: number;
1828
- firstHit?: number;
1829
- }
1830
1763
 
1831
1764
  /**
1832
- * 📊 Metrics Plugin Interfaces - NextRush Framework
1833
- *
1834
- * Core type definitions for the metrics and monitoring system.
1765
+ * Compression middleware factory
1835
1766
  */
1767
+ declare function compression(options?: CompressionOptions): Middleware;
1836
1768
 
1837
1769
  /**
1838
- * Simple metrics configuration for end users
1770
+ * CORS Middleware for NextRush v2
1771
+ *
1772
+ * High-performance CORS implementation with pre-computed headers
1773
+ * and optimized origin checking for enterprise applications.
1774
+ *
1775
+ * @packageDocumentation
1839
1776
  */
1840
- interface MetricsOptions {
1841
- endpoint?: string;
1842
- enableHealthCheck?: boolean;
1843
- collectDefaultMetrics?: boolean;
1844
- prefix?: string;
1845
- defaultLabels?: Record<string, string>;
1846
- customMetrics?: CustomMetric[];
1847
- authentication?: (req: NextRushRequest) => boolean;
1848
- }
1777
+
1849
1778
  /**
1850
- * Custom metric definition
1779
+ * Create CORS middleware
1780
+ *
1781
+ * @param options - CORS configuration options
1782
+ * @returns CORS middleware function
1783
+ *
1784
+ * @example
1785
+ * ```typescript
1786
+ * import { createApp } from 'nextrush-v2';
1787
+ * import { cors } from '@/core/middleware';
1788
+ *
1789
+ * const app = createApp();
1790
+ *
1791
+ * // Basic CORS
1792
+ * app.use(cors());
1793
+ *
1794
+ * // Advanced CORS
1795
+ * app.use(cors({
1796
+ * origin: ['https://app.example.com', 'https://admin.example.com'],
1797
+ * credentials: true,
1798
+ * methods: ['GET', 'POST', 'PUT', 'DELETE'],
1799
+ * allowedHeaders: ['Content-Type', 'Authorization', 'X-API-Key'],
1800
+ * }));
1801
+ * ```
1851
1802
  */
1852
- interface CustomMetric {
1853
- name: string;
1854
- type: 'counter' | 'gauge' | 'histogram' | 'summary';
1855
- help: string;
1856
- labels?: string[];
1857
- buckets?: number[];
1858
- quantiles?: number[];
1859
- }
1803
+ declare function cors(options?: CorsOptions): Middleware$1;
1804
+
1860
1805
  /**
1861
- * Metric value with metadata
1806
+ * Helmet Middleware for NextRush v2
1807
+ *
1808
+ * Provides security headers to protect against common vulnerabilities
1809
+ *
1810
+ * @packageDocumentation
1862
1811
  */
1863
- interface MetricValue {
1864
- value: number;
1865
- labels?: Record<string, string>;
1866
- timestamp: number;
1867
- samples?: number;
1868
- sum?: number;
1869
- }
1812
+
1870
1813
  /**
1871
- * HTTP request metrics
1814
+ * Create Helmet middleware for security headers
1815
+ *
1816
+ * @param options - Helmet configuration options
1817
+ * @returns Helmet middleware function
1818
+ *
1819
+ * @example
1820
+ * ```typescript
1821
+ * import { helmet } from '@/core/middleware/helmet';
1822
+ *
1823
+ * const app = createApp();
1824
+ * app.use(helmet());
1825
+ *
1826
+ * // With custom options
1827
+ * app.use(helmet({
1828
+ * contentSecurityPolicy: {
1829
+ * directives: {
1830
+ * defaultSrc: ["'self'"],
1831
+ * scriptSrc: ["'self'", "'unsafe-inline'"],
1832
+ * },
1833
+ * },
1834
+ * }));
1835
+ * ```
1872
1836
  */
1873
- interface RequestMetrics {
1874
- total: number;
1875
- active: number;
1876
- byMethod: Record<string, number>;
1877
- byStatus: Record<number, number>;
1878
- averageResponseTime: number;
1879
- errors: number;
1880
- p95ResponseTime: number;
1881
- p99ResponseTime: number;
1882
- }
1837
+ declare function helmet(options?: HelmetOptions): Middleware$1;
1838
+
1883
1839
  /**
1884
- * System performance metrics
1840
+ * Logger Middleware for NextRush v2
1841
+ *
1842
+ * Provides request logging functionality
1843
+ *
1844
+ * @packageDocumentation
1885
1845
  */
1886
- interface SystemMetrics {
1887
- uptime: number;
1888
- memory: {
1889
- used: number;
1890
- total: number;
1891
- heap: NodeJS.MemoryUsage;
1892
- };
1893
- cpu: {
1894
- usage: number;
1895
- load: number[];
1896
- };
1897
- process: {
1898
- pid: number;
1899
- uptime: number;
1900
- };
1901
- }
1846
+
1902
1847
  /**
1903
- * Health check status
1848
+ * Create logger middleware
1849
+ *
1850
+ * @param options - Logger configuration options
1851
+ * @returns Logger middleware function
1852
+ *
1853
+ * @example
1854
+ * ```typescript
1855
+ * import { logger } from '@/core/middleware/logger';
1856
+ *
1857
+ * const app = createApp();
1858
+ *
1859
+ * // Basic logging
1860
+ * app.use(logger());
1861
+ *
1862
+ * // Advanced logging
1863
+ * app.use(logger({
1864
+ * format: 'combined',
1865
+ * level: 'info',
1866
+ * colorize: true,
1867
+ * showResponseTime: true,
1868
+ * showUserAgent: true,
1869
+ * }));
1870
+ * ```
1904
1871
  */
1905
- interface HealthStatus {
1906
- status: 'healthy' | 'unhealthy' | 'degraded';
1907
- timestamp: number;
1908
- uptime: number;
1909
- checks: Record<string, HealthCheckResult>;
1910
- }
1872
+ declare function logger(options?: LoggerOptions): Middleware$1;
1873
+
1911
1874
  /**
1912
- * Individual health check result
1875
+ * Rate Limiter Middleware for NextRush v2
1876
+ *
1877
+ * Provides rate limiting functionality to prevent abuse
1878
+ *
1879
+ * @packageDocumentation
1913
1880
  */
1914
- interface HealthCheckResult {
1915
- status: 'pass' | 'fail' | 'warn';
1916
- message?: string;
1917
- duration: number;
1918
- timestamp: number;
1919
- }
1881
+
1920
1882
  /**
1921
- * Simple health check function
1883
+ * Create rate limiter middleware
1884
+ *
1885
+ * @param options - Rate limiter configuration options
1886
+ * @returns Rate limiter middleware function
1887
+ *
1888
+ * @example
1889
+ * ```typescript
1890
+ * import { rateLimit } from '@/core/middleware/rate-limiter';
1891
+ *
1892
+ * const app = createApp();
1893
+ *
1894
+ * // Basic rate limiting
1895
+ * app.use(rateLimit({ windowMs: 15 * 60 * 1000, max: 100 }));
1896
+ *
1897
+ * // Advanced rate limiting
1898
+ * app.use(rateLimit({
1899
+ * windowMs: 15 * 60 * 1000,
1900
+ * max: 100,
1901
+ * message: 'Too many requests from this IP',
1902
+ * keyGenerator: (ctx) => ctx.ip,
1903
+ * skip: (ctx) => ctx.path.startsWith('/public'),
1904
+ * }));
1905
+ * ```
1922
1906
  */
1923
- type HealthCheckFunction = () => Promise<{
1924
- status: 'pass' | 'fail' | 'warn';
1925
- message?: string;
1926
- }>;
1907
+ declare function rateLimit(options?: RateLimiterOptions): Middleware$1;
1927
1908
 
1928
1909
  /**
1929
- * 🎯 Template Engine Types
1930
- * Core interfaces and types for the NextRush template system
1910
+ * Request ID Middleware for NextRush v2
1911
+ *
1912
+ * Provides request ID generation and tracking functionality
1913
+ *
1914
+ * @packageDocumentation
1931
1915
  */
1932
1916
 
1933
1917
  /**
1934
- * Template context for variable substitution
1918
+ * Create request ID middleware
1919
+ *
1920
+ * @param options - Request ID configuration options
1921
+ * @returns Request ID middleware function
1922
+ *
1923
+ * @example
1924
+ * ```typescript
1925
+ * import { requestId } from '@/core/middleware/request-id';
1926
+ *
1927
+ * const app = createApp();
1928
+ *
1929
+ * // Basic request ID
1930
+ * app.use(requestId());
1931
+ *
1932
+ * // Advanced request ID
1933
+ * app.use(requestId({
1934
+ * headerName: 'X-Correlation-ID',
1935
+ * generator: () => generateUUID(),
1936
+ * addResponseHeader: true,
1937
+ * echoHeader: true,
1938
+ * }));
1939
+ * ```
1935
1940
  */
1936
- interface TemplateContext {
1937
- [key: string]: any;
1938
- }
1941
+ declare function requestId(options?: RequestIdOptions): Middleware$1;
1942
+
1939
1943
  /**
1940
- * Path aliases for template resolution
1944
+ * Timer middleware for NextRush v2
1945
+ *
1946
+ * @packageDocumentation
1941
1947
  */
1942
- interface PathAliases {
1943
- [alias: string]: string;
1944
- }
1948
+
1945
1949
  /**
1946
- * Helper function registry
1950
+ * Create timer middleware
1951
+ *
1952
+ * @param options - Timer configuration options
1953
+ * @returns Timer middleware function
1954
+ *
1955
+ * @example
1956
+ * ```typescript
1957
+ * import { timer } from '@/core/middleware/timer';
1958
+ *
1959
+ * const app = createApp();
1960
+ *
1961
+ * // Basic timer
1962
+ * app.use(timer());
1963
+ *
1964
+ * // Advanced timer
1965
+ * app.use(timer({
1966
+ * header: 'X-Response-Time',
1967
+ * digits: 3,
1968
+ * suffix: 'ms',
1969
+ * logSlow: true,
1970
+ * logSlowThreshold: 1000,
1971
+ * }));
1972
+ * ```
1947
1973
  */
1948
- interface HelperRegistry {
1949
- [name: string]: (...args: any[]) => any;
1950
- }
1974
+ declare function timer(options?: TimerOptions): Middleware$1;
1975
+
1951
1976
  /**
1952
- * Filter function registry
1977
+ * Request Enhancer for NextRush v2
1978
+ *
1979
+ * @packageDocumentation
1953
1980
  */
1954
- interface FilterRegistry {
1955
- [name: string]: (value: any, ...args: any[]) => any;
1956
- }
1981
+
1957
1982
  /**
1958
- * Internationalization configuration
1983
+ * Enhanced request interface with Express-like properties and methods
1959
1984
  */
1960
- interface I18nConfig {
1961
- locale?: string;
1962
- fallback?: string;
1963
- translations?: {
1964
- [locale: string]: {
1965
- [key: string]: string;
1966
- };
1985
+ interface EnhancedRequest extends IncomingMessage {
1986
+ params: Record<string, string>;
1987
+ query: ParsedUrlQuery;
1988
+ body: unknown;
1989
+ pathname: string;
1990
+ originalUrl: string;
1991
+ path: string;
1992
+ files: Record<string, unknown>;
1993
+ cookies: Record<string, string>;
1994
+ session: Record<string, unknown>;
1995
+ locals: Record<string, unknown>;
1996
+ startTime: number;
1997
+ fresh: boolean;
1998
+ stale: boolean;
1999
+ middlewareStack?: string[];
2000
+ param(name: string): string | undefined;
2001
+ header(name: string): string | undefined;
2002
+ get(name: string): string | undefined;
2003
+ sanitizeObject(obj: unknown, options?: unknown): unknown;
2004
+ getRequestTiming(): unknown;
2005
+ ip: string;
2006
+ secure: boolean;
2007
+ protocol: string;
2008
+ hostname(): string;
2009
+ fullUrl(): string;
2010
+ is(type: string): boolean;
2011
+ accepts(types: string | string[]): string | false;
2012
+ parseCookies(): Record<string, string>;
2013
+ validate(rules: unknown): unknown;
2014
+ sanitize(value: unknown, options?: unknown): unknown;
2015
+ isValidEmail(email: string): boolean;
2016
+ isValidUrl(url: string): boolean;
2017
+ sanitizeValue(value: unknown, rule: unknown): unknown;
2018
+ fingerprint(): string;
2019
+ userAgent(): {
2020
+ raw: string;
2021
+ browser: string;
2022
+ os: string;
2023
+ device: string;
2024
+ isMobile: boolean;
2025
+ isBot: boolean;
1967
2026
  };
1968
- directory?: string;
1969
- defaultLocale?: string;
1970
- locales?: string[];
1971
- }
1972
- /**
1973
- * Template engine configuration options
1974
- */
1975
- interface TemplateOptions {
1976
- views?: string;
1977
- layouts?: string;
1978
- partials?: string;
1979
- components?: string;
1980
- cache?: boolean;
1981
- engine?: 'mustache' | 'handlebars' | 'jsx' | 'auto';
1982
- pathAliases?: PathAliases;
1983
- encoding?: BufferEncoding;
1984
- extensions?: string[];
1985
- globals?: TemplateContext;
1986
- helpers?: HelperRegistry;
1987
- filters?: FilterRegistry;
1988
- i18n?: I18nConfig;
1989
- minify?: boolean;
1990
- debug?: boolean;
1991
- watchFiles?: boolean;
1992
- streaming?: boolean;
1993
- defaultExtension?: string;
1994
- }
1995
- /**
1996
- * Template rendering options
1997
- */
1998
- interface RenderOptions {
1999
- engine?: string;
2000
- cache?: boolean;
2001
- layout?: string;
2002
- locals?: TemplateContext;
2003
- streaming?: boolean;
2004
- partials?: Record<string, string>;
2005
- helpers?: Record<string, Function>;
2006
- filters?: Record<string, Function>;
2007
- [key: string]: any;
2008
- }
2009
- /**
2010
- * Template AST node types
2011
- */
2012
- interface TemplateNode {
2013
- type: 'text' | 'variable' | 'block' | 'component' | 'partial' | 'layout' | 'helper';
2014
- content?: string;
2015
- key?: string;
2016
- props?: TemplateContext;
2017
- children?: TemplateNode[];
2018
- escape?: boolean;
2019
- condition?: string;
2020
- iterator?: {
2021
- array: string;
2022
- item: string;
2023
- index?: string;
2027
+ timing(): {
2028
+ start: number;
2029
+ duration: number;
2030
+ timestamp: string;
2024
2031
  };
2025
- name?: string;
2026
- args?: any[];
2027
- start?: number;
2028
- end?: number;
2029
- }
2030
- /**
2031
- * Template parsing result
2032
- */
2033
- interface ParseResult {
2034
- nodes: TemplateNode[];
2035
- metadata: {
2036
- dependencies: string[];
2037
- components: string[];
2038
- partials: string[];
2039
- layout?: string;
2040
- frontmatter?: any;
2041
- title?: string;
2042
- author?: string;
2043
- date?: string;
2044
- tags?: string[];
2032
+ rateLimit(): {
2033
+ limit: number;
2034
+ remaining: number;
2035
+ reset: number;
2036
+ retryAfter: number;
2045
2037
  };
2038
+ parseBrowser(ua: string): string;
2039
+ parseOS(ua: string): string;
2040
+ parseDevice(ua: string): string;
2041
+ isBot(ua: string): boolean;
2042
+ isMobile(ua: string): boolean;
2046
2043
  }
2047
2044
  /**
2048
- * Compiled template result
2049
- */
2050
- interface CompileResult {
2051
- render: (context: TemplateContext, options?: RenderOptions) => Promise<string>;
2052
- renderStream: (context: TemplateContext, stream: Writable, options?: RenderOptions) => Promise<void>;
2053
- metadata: ParseResult['metadata'];
2054
- }
2055
- /**
2056
- * Test rendering result interface
2045
+ * Request Enhancer class for NextRush v2
2046
+ *
2047
+ * @example
2048
+ * ```typescript
2049
+ * import { RequestEnhancer } from '@/core/enhancers/request-enhancer';
2050
+ *
2051
+ * const enhancedReq = RequestEnhancer.enhance(req);
2052
+ * console.log(enhancedReq.ip()); // Client IP
2053
+ * console.log(enhancedReq.userAgent()); // User agent info
2054
+ * ```
2057
2055
  */
2058
- interface TestRenderResult {
2059
- html: string;
2060
- errors: string[];
2061
- metadata?: ParseResult['metadata'];
2056
+ declare class RequestEnhancer {
2057
+ /**
2058
+ * Enhance a Node.js IncomingMessage with NextRush v2 features
2059
+ *
2060
+ * @param req - The original HTTP request
2061
+ * @returns Enhanced request with additional properties and methods
2062
+ */
2063
+ static enhance(req: IncomingMessage): EnhancedRequest;
2062
2064
  }
2063
2065
 
2064
2066
  /**
2065
- * 🔧 Template Helpers and Filters
2066
- * Built-in and custom helper functions for template rendering
2067
+ * Response Enhancer for NextRush v2
2068
+ *
2069
+ * @packageDocumentation
2067
2070
  */
2068
2071
 
2069
2072
  /**
2070
- * Helper and Filter Manager
2073
+ * File options interface
2071
2074
  */
2072
- declare class TemplateHelperManager {
2073
- private helpers;
2074
- private filters;
2075
- private i18nConfig;
2076
- constructor(i18nConfig?: I18nConfig);
2077
- /**
2078
- * Register a custom helper
2079
- */
2080
- registerHelper(name: string, fn: (...args: any[]) => any): void;
2081
- /**
2082
- * Register a custom filter
2083
- */
2084
- registerFilter(name: string, fn: (value: any, ...args: any[]) => any): void;
2085
- /**
2086
- * Get helper function
2087
- */
2088
- getHelper(name: string): ((...args: any[]) => any) | undefined;
2089
- /**
2090
- * Get filter function
2091
- */
2092
- getFilter(name: string): ((value: any, ...args: any[]) => any) | undefined;
2093
- /**
2094
- * Get all helpers
2095
- */
2096
- getAllHelpers(): HelperRegistry;
2097
- /**
2098
- * Get all filters
2099
- */
2100
- getAllFilters(): FilterRegistry;
2101
- /**
2102
- * Setup built-in helper functions
2103
- */
2104
- private setupBuiltinHelpers;
2105
- /**
2106
- * Setup built-in filter functions
2107
- */
2108
- private setupBuiltinFilters;
2109
- /**
2110
- * Translate a key using i18n configuration
2111
- */
2112
- private translate;
2113
- /**
2114
- * Translate plural forms
2115
- */
2116
- private translatePlural;
2075
+ interface FileOptions {
2076
+ etag?: boolean;
2077
+ root?: string;
2117
2078
  }
2118
-
2119
2079
  /**
2120
- * 🎨 Template Parser
2121
- * Multi-syntax template parsing engine for NextRush
2080
+ * Enhanced response interface with Express-like methods
2122
2081
  */
2123
-
2082
+ interface EnhancedResponse extends ServerResponse {
2083
+ locals: Record<string, unknown>;
2084
+ status(code: number): EnhancedResponse;
2085
+ json(data: unknown): void;
2086
+ send(data: string | Buffer | object): void;
2087
+ html(data: string): void;
2088
+ text(data: string): void;
2089
+ xml(data: string): void;
2090
+ csv(data: unknown[], filename?: string): void;
2091
+ stream(stream: NodeJS.ReadableStream, contentType?: string): void;
2092
+ sendFile(filePath: string, options?: FileOptions): void;
2093
+ file(filePath: string, options?: FileOptions): EnhancedResponse;
2094
+ download(filePath: string, filename?: string, options?: FileOptions): void;
2095
+ getSmartContentType(filePath: string): string;
2096
+ generateETag(stats: unknown): string;
2097
+ redirect(url: string, status?: number): void;
2098
+ redirectPermanent(url: string): void;
2099
+ redirectTemporary(url: string): void;
2100
+ set(field: string | Record<string, string>, value?: string): EnhancedResponse;
2101
+ header(field: string, value: string): EnhancedResponse;
2102
+ removeHeader(field: string): EnhancedResponse;
2103
+ remove(field: string): EnhancedResponse;
2104
+ get(field: string): string | undefined;
2105
+ type(type: string): EnhancedResponse;
2106
+ length(length: number): EnhancedResponse;
2107
+ etag(etag: string): EnhancedResponse;
2108
+ lastModified(date: Date): EnhancedResponse;
2109
+ cookie(name: string, value: string, options?: CookieOptions): EnhancedResponse;
2110
+ clearCookie(name: string, options?: CookieOptions): EnhancedResponse;
2111
+ render(template: string, data?: unknown): void;
2112
+ getNestedValue(obj: unknown, path: string): unknown;
2113
+ isTruthy(value: unknown): boolean;
2114
+ cache(seconds: number): EnhancedResponse;
2115
+ noCache(): EnhancedResponse;
2116
+ cors(origin?: string): EnhancedResponse;
2117
+ security(): EnhancedResponse;
2118
+ compress(): EnhancedResponse;
2119
+ success(data: unknown, message?: string): void;
2120
+ error(message: string, code?: number, details?: unknown): void;
2121
+ paginate(data: unknown[], page: number, limit: number, total: number): void;
2122
+ getContentTypeFromExtension(ext: string): string;
2123
+ convertToCSV(data: unknown[]): string;
2124
+ time(label?: string): EnhancedResponse;
2125
+ }
2124
2126
  /**
2125
- * Ultimate Template Parser - Handles multiple template syntaxes
2127
+ * Response Enhancer class for NextRush v2
2128
+ *
2129
+ * @example
2130
+ * ```typescript
2131
+ * import { ResponseEnhancer } from '@/core/enhancers/response-enhancer';
2132
+ *
2133
+ * const enhancedRes = ResponseEnhancer.enhance(res);
2134
+ * enhancedRes.json({ message: 'Hello World' });
2135
+ * ```
2126
2136
  */
2127
- declare class UltimateTemplateParser {
2128
- private pos;
2129
- private input;
2130
- private options;
2131
- constructor(input: string, options?: TemplateOptions);
2132
- /**
2133
- * Parse template content into AST nodes
2134
- */
2135
- parse(): ParseResult;
2136
- /**
2137
- * Parse a single template node
2138
- */
2139
- private parseNode;
2140
- /**
2141
- * Parse Handlebars-like syntax: {{variable}} {{#block}} {{>partial}}
2142
- */
2143
- private parseHandlebarsLike;
2144
- /**
2145
- * Parse JSX-like syntax: <% if %> <% for %> <%= variable %>
2146
- */
2147
- private parseJSXLike;
2148
- /**
2149
- * Parse React-like components: <Component prop="value">content</Component>
2150
- */
2151
- private parseComponent;
2152
- /**
2153
- * Parse block helpers: {{#if}} {{#each}}
2154
- */
2155
- private parseBlock;
2156
- /**
2157
- * Parse until a specific end tag is found
2158
- */
2159
- private parseUntil;
2160
- /**
2161
- * Parse plain text content
2162
- */
2163
- private parseText;
2164
- /**
2165
- * Peek ahead in the input string
2166
- */
2167
- private peek;
2168
- /**
2169
- * Check if the current position matches a regex
2170
- */
2171
- private peekRegex;
2172
- /**
2173
- * Consume a specific string if it matches current position
2174
- */
2175
- private consume;
2137
+ declare class ResponseEnhancer {
2176
2138
  /**
2177
- * Read until a specific end string is found
2139
+ * Enhance a Node.js ServerResponse with NextRush v2 features
2140
+ *
2141
+ * @param res - The original HTTP response
2142
+ * @returns Enhanced response with additional methods
2178
2143
  */
2179
- private readUntil;
2144
+ static enhance(res: ServerResponse): EnhancedResponse;
2180
2145
  }
2181
2146
 
2182
2147
  /**
2183
- * 🎨 Template Renderer
2184
- * High-performance template rendering engine for NextRush
2148
+ * Optimized Radix Tree Router for NextRush v2
2149
+ *
2150
+ * High-performance router with O(k) lookup performance
2151
+ * where k is path length, not route count.
2152
+ *
2153
+ * Performance optimizations:
2154
+ * - Zero-copy path splitting
2155
+ * - LRU cache for frequent paths
2156
+ * - Iterative traversal (no recursion)
2157
+ * - Pre-allocated parameter objects
2158
+ * - Optimized parameter matching
2159
+ *
2160
+ * @packageDocumentation
2185
2161
  */
2186
2162
 
2187
2163
  /**
2188
- * Ultimate Template Renderer - High-performance rendering engine
2164
+ * Route match result with pre-allocated parameter object
2189
2165
  */
2190
- declare class UltimateTemplateRenderer {
2191
- private options;
2192
- private helperManager;
2193
- private globals;
2194
- private partials;
2195
- private components;
2196
- private layouts;
2197
- private templateCache;
2198
- constructor(options?: TemplateOptions);
2199
- /**
2200
- * Load template from file system
2201
- */
2202
- loadTemplate(templatePath: string, type?: 'template' | 'partial' | 'component' | 'layout'): Promise<ParseResult | null>;
2166
+ interface OptimizedRouteMatch {
2167
+ handler: RouteHandler;
2168
+ middleware: Middleware[];
2169
+ params: Record<string, string>;
2170
+ path: string;
2171
+ compiled?: (ctx: any) => Promise<void>;
2172
+ }
2173
+ /**
2174
+ * Optimized Router class with performance improvements
2175
+ */
2176
+ declare class OptimizedRouter implements Router {
2177
+ private root;
2178
+ private middleware;
2179
+ private prefix;
2180
+ private cache;
2181
+ private paramPool;
2182
+ private maxPoolSize;
2183
+ private poolHits;
2184
+ private poolMisses;
2185
+ private readonly staticRoutes;
2186
+ constructor(prefix?: string, cacheSize?: number);
2203
2187
  /**
2204
- * Get base directory for template type
2188
+ * Optimized parameter object management
2205
2189
  */
2206
- private getBaseDirectory;
2190
+ private getParamObject;
2207
2191
  /**
2208
- * Render nodes to a writable stream
2192
+ * Get pool statistics for monitoring
2209
2193
  */
2210
- renderStream(nodes: TemplateNode[], context: TemplateContext, stream: Writable, options?: RenderOptions): Promise<void>;
2194
+ private getPoolStats;
2211
2195
  /**
2212
- * Render a single template node
2196
+ * Register a GET route
2213
2197
  */
2214
- private renderNode;
2198
+ get(path: string, handler: RouteHandler | RouteConfig): OptimizedRouter;
2215
2199
  /**
2216
- * Render helper function calls
2200
+ * Register a POST route
2217
2201
  */
2218
- private renderHelper;
2202
+ post(path: string, handler: RouteHandler | RouteConfig): OptimizedRouter;
2219
2203
  /**
2220
- * Render block elements (if, each)
2204
+ * Register a PUT route
2221
2205
  */
2222
- private renderBlock;
2206
+ put(path: string, handler: RouteHandler | RouteConfig): OptimizedRouter;
2223
2207
  /**
2224
- * Render partial templates
2208
+ * Register a DELETE route
2225
2209
  */
2226
- private renderPartial;
2210
+ delete(path: string, handler: RouteHandler | RouteConfig): OptimizedRouter;
2227
2211
  /**
2228
- * Render components
2212
+ * Register a PATCH route
2229
2213
  */
2230
- private renderComponent;
2214
+ patch(path: string, handler: RouteHandler | RouteConfig): OptimizedRouter;
2231
2215
  /**
2232
- * Render with layout
2216
+ * Use middleware or create sub-router
2233
2217
  */
2234
- private renderLayout;
2218
+ use(middlewareOrPrefix: string | Middleware, router?: Router): OptimizedRouter;
2235
2219
  /**
2236
- * Render template to string
2220
+ * Get all registered routes for sub-router integration
2237
2221
  */
2238
- render(nodes: TemplateNode[], context: TemplateContext, options?: RenderOptions): Promise<string>;
2222
+ getRoutes(): Map<string, RouteData>;
2239
2223
  /**
2240
- * Render with layout support
2224
+ * Get router middleware
2241
2225
  */
2242
- renderWithLayout(parseResult: ParseResult, context: TemplateContext, options?: RenderOptions): Promise<string>;
2226
+ getMiddleware(): Middleware[];
2243
2227
  /**
2244
- * Register a partial template
2228
+ * 🔥 Inject compiled handler for a route (used by compiler)
2229
+ * This allows the pre-compilation system to inject optimized handlers
2245
2230
  */
2246
- registerPartial(name: string, parseResult: ParseResult): void;
2231
+ setCompiledHandler(method: string, pattern: string, compiledExecute: (ctx: any) => Promise<void>): void;
2247
2232
  /**
2248
- * Register a component template
2233
+ * Get comprehensive cache and performance statistics
2249
2234
  */
2250
- registerComponent(name: string, parseResult: ParseResult): void;
2235
+ getCacheStats(): {
2236
+ cache: {
2237
+ size: number;
2238
+ hitRate: number;
2239
+ hits: number;
2240
+ misses: number;
2241
+ };
2242
+ pool: {
2243
+ poolSize: number;
2244
+ maxSize: number;
2245
+ hits: number;
2246
+ misses: number;
2247
+ hitRate: number;
2248
+ };
2249
+ performance: {
2250
+ totalRoutes: number;
2251
+ pathCacheSize: number;
2252
+ };
2253
+ };
2251
2254
  /**
2252
- * Register a layout template
2255
+ * Get total number of registered routes
2253
2256
  */
2254
- registerLayout(name: string, parseResult: ParseResult): void;
2257
+ private getTotalRoutes;
2255
2258
  /**
2256
- * Clear template cache
2259
+ * Clear the route cache
2257
2260
  */
2258
2261
  clearCache(): void;
2259
- }
2260
-
2261
- /**
2262
- * 🎯 Simple Template Engine - Super Easy DX
2263
- * One-line setup, zero configuration needed!
2264
- * Hide all complexity behind clean API
2265
- */
2266
-
2267
- /**
2268
- * Simple template configuration options
2269
- */
2270
- interface SimpleTemplateOptions {
2271
- /** Enable caching for better performance (default: true) */
2272
- cache?: boolean;
2273
- /** Custom helpers for templates */
2274
- helpers?: HelperRegistry;
2275
- /** Enable debug mode in development */
2276
- debug?: boolean;
2277
- }
2278
- /**
2279
- * 🚀 Create a simple template engine with one line!
2280
- *
2281
- * @example
2282
- * ```typescript
2283
- * // Super simple setup
2284
- * const template = createTemplate();
2285
- * app.setTemplateEngine(template);
2286
- *
2287
- * // With custom helpers
2288
- * const template = createTemplate({
2289
- * helpers: {
2290
- * currency: (amount) => `$${amount.toFixed(2)}`
2291
- * }
2292
- * });
2293
- * ```
2294
- */
2295
- declare function createTemplate(options?: SimpleTemplateOptions): {
2296
2262
  /**
2297
- * Render template with data - super simple!
2263
+ * Ultra-fast route finder with aggressive optimizations
2298
2264
  */
2299
- render(templateContent: string, data?: Record<string, any>): Promise<string>;
2265
+ find(method: string, path: string): OptimizedRouteMatch | null;
2300
2266
  /**
2301
- * Validate template syntax (optional, but helpful for debugging)
2267
+ * Hyper-optimized internal finder with minimal allocations
2302
2268
  */
2303
- validate(templateContent: string): {
2304
- valid: boolean;
2305
- errors: string[];
2306
- };
2307
- };
2308
- /**
2309
- * 🎯 Quick setup for NextRush apps - ONE LINE!
2310
- *
2311
- * @example
2312
- * ```typescript
2313
- * import { quickTemplate } from 'next-rush';
2314
- *
2315
- * const app = createApp();
2316
- * app.setTemplateEngine(quickTemplate());
2317
- * ```
2318
- */
2319
- declare function quickTemplate(helpers?: HelperRegistry): {
2269
+ private findInternalOptimized;
2320
2270
  /**
2321
- * Render template with data - super simple!
2271
+ * Optimized route registration with O(k) insertion
2322
2272
  */
2323
- render(templateContent: string, data?: Record<string, any>): Promise<string>;
2273
+ private registerRoute;
2324
2274
  /**
2325
- * Validate template syntax (optional, but helpful for debugging)
2275
+ * Iteratively collect all routes from the tree (no recursion)
2326
2276
  */
2327
- validate(templateContent: string): {
2328
- valid: boolean;
2329
- errors: string[];
2330
- };
2331
- };
2277
+ private collectRoutesIterative;
2278
+ }
2332
2279
  /**
2333
- * 🛠️ Advanced template setup (but still simple!)
2280
+ * Create a new optimized router instance
2281
+ *
2282
+ * @param prefix - Optional route prefix
2283
+ * @param cacheSize - Optional cache size (default: 1000)
2284
+ * @returns OptimizedRouter instance
2334
2285
  *
2335
2286
  * @example
2336
2287
  * ```typescript
2337
- * import { advancedTemplate } from 'next-rush';
2288
+ * import { createOptimizedRouter } from 'nextrush-v2';
2338
2289
  *
2339
- * const template = advancedTemplate({
2340
- * cache: true,
2341
- * debug: true,
2342
- * helpers: {
2343
- * myHelper: (value) => `Custom: ${value}`
2344
- * }
2345
- * });
2346
- * ```
2347
- */
2348
- declare function advancedTemplate(options: SimpleTemplateOptions): {
2349
- /**
2350
- * Render template with data - super simple!
2351
- */
2352
- render(templateContent: string, data?: Record<string, any>): Promise<string>;
2353
- /**
2354
- * Validate template syntax (optional, but helpful for debugging)
2355
- */
2356
- validate(templateContent: string): {
2357
- valid: boolean;
2358
- errors: string[];
2359
- };
2360
- };
2361
- /**
2362
- * 🎨 Template with common web helpers pre-loaded
2363
- */
2364
- declare function webTemplate(): {
2365
- /**
2366
- * Render template with data - super simple!
2367
- */
2368
- render(templateContent: string, data?: Record<string, any>): Promise<string>;
2369
- /**
2370
- * Validate template syntax (optional, but helpful for debugging)
2371
- */
2372
- validate(templateContent: string): {
2373
- valid: boolean;
2374
- errors: string[];
2375
- };
2376
- };
2377
-
2378
- /**
2379
- * 🔧 Template Engine Utilities
2380
- * Helper classes and utility functions for the template system
2381
- */
2382
-
2383
- /**
2384
- * HTML escaping utility
2385
- */
2386
- declare function escapeHTML(str: string): string;
2387
- /**
2388
- * Get nested value from object using dot notation
2389
- */
2390
- declare function getValue(context: Record<string, any>, key: string): any;
2391
- /**
2392
- * Simple condition evaluation for templates
2393
- */
2394
- declare function evaluateCondition(condition: string, context: Record<string, any>): boolean;
2395
- /**
2396
- * Parse YAML-like frontmatter
2397
- */
2398
- declare function parseFrontmatter(content: string): {
2399
- content: string;
2400
- frontmatter: any;
2401
- };
2402
- /**
2403
- * Create slot map from child nodes for component rendering
2404
- */
2405
- declare function createSlotMap(children: any[]): {
2406
- [slotName: string]: any[];
2407
- };
2408
- /**
2409
- * Resolve template path with proper extension handling
2410
- */
2411
- declare function resolveTemplatePath(templatePath: string, baseDir: string, defaultExtension?: string): string;
2412
-
2413
- /**
2414
- * 🧪 Template Testing Utilities
2415
- * Testing tools for template engine development and validation
2416
- */
2417
-
2418
- /**
2419
- * Test template rendering with error handling
2420
- */
2421
- declare function testTemplateRender(templateContent: string, data: TemplateContext, options?: TemplateOptions): Promise<TestRenderResult>;
2422
- /**
2423
- * Validate template syntax without rendering
2424
- */
2425
- declare function validateTemplateSyntax(templateContent: string, options?: TemplateOptions): {
2426
- valid: boolean;
2427
- errors: string[];
2428
- };
2429
- /**
2430
- * Benchmark template rendering performance
2431
- */
2432
- declare function benchmarkTemplate(templateContent: string, data: TemplateContext, iterations?: number, options?: TemplateOptions): Promise<{
2433
- totalTime: number;
2434
- averageTime: number;
2435
- iterationsPerSecond: number;
2436
- }>;
2437
- /**
2438
- * Compare template engines performance
2439
- */
2440
- declare function compareTemplateEngines(templateContent: string, data: TemplateContext, engines: Array<{
2441
- name: string;
2442
- options: TemplateOptions;
2443
- }>, iterations?: number): Promise<Array<{
2444
- name: string;
2445
- totalTime: number;
2446
- averageTime: number;
2447
- iterationsPerSecond: number;
2448
- }>>;
2449
-
2450
- /**
2451
- * 🚀 NextRush Component Architecture Interfaces
2452
- *
2453
- * Clean, type-safe interfaces for the plugin-based architecture
2454
- */
2455
- /**
2456
- * Minimal Application Interface - Core methods that plugins install
2457
- * Provides full type inference for all HTTP methods and middleware
2458
- */
2459
- interface MinimalApplication {
2460
- get(path: Path, handler: RouteHandler$1): MinimalApplication;
2461
- get(path: Path, handler: ExpressHandler$1): MinimalApplication;
2462
- get(path: Path, middleware: MiddlewareHandler$1, handler: RouteHandler$1): MinimalApplication;
2463
- get(path: Path, middleware: ExpressMiddleware$1, handler: ExpressHandler$1): MinimalApplication;
2464
- get(path: Path, ...handlers: (RouteHandler$1 | ExpressHandler$1 | MiddlewareHandler$1 | ExpressMiddleware$1)[]): MinimalApplication;
2465
- post(path: Path, handler: RouteHandler$1): MinimalApplication;
2466
- post(path: Path, handler: ExpressHandler$1): MinimalApplication;
2467
- post(path: Path, middleware: MiddlewareHandler$1, handler: RouteHandler$1): MinimalApplication;
2468
- post(path: Path, middleware: ExpressMiddleware$1, handler: ExpressHandler$1): MinimalApplication;
2469
- post(path: Path, ...handlers: (RouteHandler$1 | ExpressHandler$1 | MiddlewareHandler$1 | ExpressMiddleware$1)[]): MinimalApplication;
2470
- put(path: Path, handler: RouteHandler$1): MinimalApplication;
2471
- put(path: Path, handler: ExpressHandler$1): MinimalApplication;
2472
- put(path: Path, middleware: MiddlewareHandler$1, handler: RouteHandler$1): MinimalApplication;
2473
- put(path: Path, middleware: ExpressMiddleware$1, handler: ExpressHandler$1): MinimalApplication;
2474
- put(path: Path, ...handlers: (RouteHandler$1 | ExpressHandler$1 | MiddlewareHandler$1 | ExpressMiddleware$1)[]): MinimalApplication;
2475
- delete(path: Path, handler: RouteHandler$1): MinimalApplication;
2476
- delete(path: Path, handler: ExpressHandler$1): MinimalApplication;
2477
- delete(path: Path, middleware: MiddlewareHandler$1, handler: RouteHandler$1): MinimalApplication;
2478
- delete(path: Path, middleware: ExpressMiddleware$1, handler: ExpressHandler$1): MinimalApplication;
2479
- delete(path: Path, ...handlers: (RouteHandler$1 | ExpressHandler$1 | MiddlewareHandler$1 | ExpressMiddleware$1)[]): MinimalApplication;
2480
- patch(path: Path, handler: RouteHandler$1): MinimalApplication;
2481
- patch(path: Path, handler: ExpressHandler$1): MinimalApplication;
2482
- patch(path: Path, middleware: MiddlewareHandler$1, handler: RouteHandler$1): MinimalApplication;
2483
- patch(path: Path, middleware: ExpressMiddleware$1, handler: ExpressHandler$1): MinimalApplication;
2484
- patch(path: Path, ...handlers: (RouteHandler$1 | ExpressHandler$1 | MiddlewareHandler$1 | ExpressMiddleware$1)[]): MinimalApplication;
2485
- head(path: Path, handler: RouteHandler$1): MinimalApplication;
2486
- head(path: Path, handler: ExpressHandler$1): MinimalApplication;
2487
- head(path: Path, middleware: MiddlewareHandler$1, handler: RouteHandler$1): MinimalApplication;
2488
- head(path: Path, middleware: ExpressMiddleware$1, handler: ExpressHandler$1): MinimalApplication;
2489
- head(path: Path, ...handlers: (RouteHandler$1 | ExpressHandler$1 | MiddlewareHandler$1 | ExpressMiddleware$1)[]): MinimalApplication;
2490
- options(path: Path, handler: RouteHandler$1): MinimalApplication;
2491
- options(path: Path, handler: ExpressHandler$1): MinimalApplication;
2492
- options(path: Path, middleware: MiddlewareHandler$1, handler: RouteHandler$1): MinimalApplication;
2493
- options(path: Path, middleware: ExpressMiddleware$1, handler: ExpressHandler$1): MinimalApplication;
2494
- options(path: Path, ...handlers: (RouteHandler$1 | ExpressHandler$1 | MiddlewareHandler$1 | ExpressMiddleware$1)[]): MinimalApplication;
2495
- all(path: Path, handler: RouteHandler$1): MinimalApplication;
2496
- all(path: Path, handler: ExpressHandler$1): MinimalApplication;
2497
- all(path: Path, middleware: MiddlewareHandler$1, handler: RouteHandler$1): MinimalApplication;
2498
- all(path: Path, middleware: ExpressMiddleware$1, handler: ExpressHandler$1): MinimalApplication;
2499
- all(path: Path, ...handlers: (RouteHandler$1 | ExpressHandler$1 | MiddlewareHandler$1 | ExpressMiddleware$1)[]): MinimalApplication;
2500
- use(handler: MiddlewareHandler$1): MinimalApplication;
2501
- use(handler: ExpressMiddleware$1): MinimalApplication;
2502
- use(path: Path, handler: MiddlewareHandler$1): MinimalApplication;
2503
- use(path: Path, handler: ExpressMiddleware$1): MinimalApplication;
2504
- use(pathOrHandler: Path | MiddlewareHandler$1 | ExpressMiddleware$1, handler?: MiddlewareHandler$1 | ExpressMiddleware$1): MinimalApplication;
2505
- static?(staticPath: string, options?: any): MinimalApplication;
2506
- serveStatic?(staticPath: string, options?: any): MinimalApplication;
2507
- render?(view: string, data?: any): Promise<string>;
2508
- setTemplateEngine?(engine: any): MinimalApplication;
2509
- setViews?(viewsPath: string): MinimalApplication;
2510
- json?(options?: any): MiddlewareHandler$1;
2511
- urlencoded?(options?: any): MiddlewareHandler$1;
2512
- raw?(options?: any): MiddlewareHandler$1;
2513
- text?(options?: any): MiddlewareHandler$1;
2514
- cors?(options?: any): MiddlewareHandler$1;
2515
- helmet?(options?: any): MiddlewareHandler$1;
2516
- ws?(path: string, handler: any): MinimalApplication;
2517
- websocket?(path: string, handler: any): MinimalApplication;
2518
- enableWebSocket?(options?: any): MinimalApplication;
2519
- listen(port: number, hostname?: string, callback?: () => void): Promise<void>;
2520
- close(): Promise<void>;
2521
- getPluginRegistry?(): any;
2522
- registerPlugin?(plugin: any): Promise<void>;
2523
- unregisterPlugin?(name: string): Promise<void>;
2524
- }
2525
- /**
2526
- * Component lifecycle interface
2527
- */
2528
- interface Lifecycle {
2529
- readonly name: string;
2530
- install(app: MinimalApplication): void | Promise<void>;
2531
- start?(): void | Promise<void>;
2532
- stop?(): void | Promise<void>;
2533
- }
2534
-
2535
- /**
2536
- * 🔥 Optimized Custom Error Classes for NextRush Framework
2537
- * Zero memory leaks, performance-optimized, enterprise-grade error handling
2538
- */
2539
- declare enum ErrorSeverity {
2540
- LOW = "low",
2541
- MEDIUM = "medium",
2542
- HIGH = "high",
2543
- CRITICAL = "critical"
2544
- }
2545
- declare enum ErrorCategory {
2546
- VALIDATION = "validation",
2547
- AUTHENTICATION = "authentication",
2548
- AUTHORIZATION = "authorization",
2549
- NETWORK = "network",
2550
- DATABASE = "database",
2551
- FILESYSTEM = "filesystem",
2552
- BUSINESS_LOGIC = "business_logic",
2553
- SYSTEM = "system",
2554
- EXTERNAL_SERVICE = "external_service"
2555
- }
2556
- /**
2557
- * 🔥 High-Performance Base Error Class
2558
- * - Memory-optimized with object pooling
2559
- * - Conditional stack capture for performance
2560
- * - Immutable properties for thread safety
2561
- * - Rich metadata for debugging
2562
- */
2563
- declare abstract class NextRushError extends Error {
2564
- readonly code: string;
2565
- readonly statusCode: number;
2566
- readonly details: Readonly<Record<string, unknown>>;
2567
- readonly timestamp: number;
2568
- readonly severity: ErrorSeverity;
2569
- readonly category: ErrorCategory;
2570
- readonly correlationId?: string;
2571
- readonly retryable: boolean;
2572
- private static readonly errorPool;
2573
- private static readonly maxPoolSize;
2574
- constructor(message: string, code: string, statusCode?: number, details?: Record<string, unknown>, severity?: ErrorSeverity, category?: ErrorCategory, retryable?: boolean, correlationId?: string);
2575
- /**
2576
- * 🚀 High-performance JSON serialization
2577
- */
2578
- toJSON(): Record<string, unknown>;
2579
- /**
2580
- * 🚀 Smart stack capture decision
2581
- */
2582
- private shouldCaptureStack;
2583
- /**
2584
- * 🚀 Smart stack inclusion decision
2585
- */
2586
- private shouldIncludeStack;
2587
- /**
2588
- * 🚀 Generate correlation ID for error tracking
2589
- */
2590
- private generateCorrelationId;
2591
- /**
2592
- * 🚀 Static factory method with error pooling
2593
- */
2594
- static create<T extends NextRushError>(this: new (...args: any[]) => T, ...args: any[]): T;
2595
- /**
2596
- * 🚀 Check if error is retryable
2597
- */
2598
- isRetryable(): boolean;
2599
- /**
2600
- * 🚀 Check if error is critical
2601
- */
2602
- isCritical(): boolean;
2603
- /**
2604
- * 🚀 Get user-friendly message (sanitized for production)
2605
- */
2606
- getUserMessage(): string;
2607
- }
2608
- /**
2609
- * 🚀 Client Errors (4xx)
2610
- */
2611
- declare class ValidationError extends NextRushError {
2612
- constructor(message: string, details?: Record<string, unknown>, correlationId?: string);
2613
- static field(fieldName: string, value: unknown, expected: string, correlationId?: string): ValidationError;
2614
- static schema(errors: Array<{
2615
- field: string;
2616
- message: string;
2617
- }>, correlationId?: string): ValidationError;
2618
- }
2619
- declare class NotFoundError extends NextRushError {
2620
- constructor(resource?: string, identifier?: string | number, correlationId?: string);
2621
- }
2622
- declare class MethodNotAllowedError extends NextRushError {
2623
- constructor(method: string, allowedMethods?: string[], correlationId?: string);
2624
- }
2625
- /**
2626
- * 🚀 Server Errors (5xx)
2627
- */
2628
- declare class InternalServerError extends NextRushError {
2629
- constructor(message?: string, details?: Record<string, unknown>, correlationId?: string);
2630
- }
2631
-
2632
- /**
2633
- * 🔧 NextRush Middleware Types
2634
- * Type definitions for middl# Named middleware interface wit// Built-in middleware option types using NextRush types
2635
- export interface CorsOptions {
2636
- origin?: string | string[] | boolean | ((or# Middleware execution context# Advanced middleware types with NextRush types
2637
- export type ConditionalMiddleware<TRequest = NextRushRequest, TResponse = NextRushResponse> = {
2638
- condition: ConditionalPredicate<TRequest, TResponse>;
2639
- middleware: Middleware<TRequest, TResponse>;
2640
- };
2641
-
2642
- export type TimedMiddleware<TRequest = NextRushRequest, TResponse = NextRushResponse> = {
2643
- timeout: number;
2644
- middleware: Middleware<TRequest, TResponse>;
2645
- onTimeout?: (context: MiddlewareContext<TRequest, TResponse>) => void;
2646
- };
2647
-
2648
- export type RetryableMiddleware<TRequest = NextRushRequest, TResponse = NextRushResponse> = {
2649
- maxRetries: number;
2650
- middleware: Middleware<TRequest, TResponse>;
2651
- shouldRetry?: (error: any, attempt: number) => boolean;
2652
- delay?: number | ((attempt: number) => number);
2653
- };es
2654
- export interface MiddlewareContext<TRequest = NextRushRequest, TResponse = NextRushResponse> {
2655
- req: TRequest;
2656
- res: TResponse;
2657
- next: NextFunction;
2658
- config?: MiddlewareConfig;
2659
- startTime?: number;
2660
- endTime?: number;
2661
- error?: any;
2662
- metadata?: Record<string, any>;
2663
- }g | undefined, req: NextRushRequest) => boolean);
2664
- methods?: string | string[];
2665
- allowedHeaders?: string | string[];
2666
- exposedHeaders?: string | string[];
2667
- credentials?: boolean;
2668
- maxAge?: number;
2669
- preflightContinue?: boolean;
2670
- optionsSuccessStatus?: number;
2671
- }types
2672
- export interface NamedMiddleware<
2673
- TRequest = NextRushRequest,
2674
- TResponse = NextRushResponse,
2675
- TNextFunction = NextFunction
2676
- > extends Middleware<TRequest, TResponse, TNextFunction> {
2677
- middlewareName: string;
2678
- config?: MiddlewareConfig;
2679
- }tem using proper NextRush types
2680
- */
2681
-
2682
- type NextFunction = (error?: any) => void;
2683
- type Middleware<TRequest = NextRushRequest, TResponse = NextRushResponse, TNextFunction = NextFunction> = (req: TRequest, res: TResponse, next: TNextFunction) => void;
2684
- type AsyncMiddleware<TRequest = NextRushRequest, TResponse = NextRushResponse, TNextFunction = NextFunction> = (req: TRequest, res: TResponse, next: TNextFunction) => Promise<void>;
2685
- type ErrorMiddleware<TError = any, TRequest = NextRushRequest, TResponse = NextRushResponse, TNextFunction = NextFunction> = (error: TError, req: TRequest, res: TResponse, next: TNextFunction) => void;
2686
- type RequestHandler<TRequest = NextRushRequest, TResponse = NextRushResponse, TNextFunction = NextFunction> = Middleware<TRequest, TResponse, TNextFunction>;
2687
- type ErrorRequestHandler<TError = any, TRequest = NextRushRequest, TResponse = NextRushResponse, TNextFunction = NextFunction> = ErrorMiddleware<TError, TRequest, TResponse, TNextFunction>;
2688
-
2689
- /**
2690
- * 🎛️ NextRush Middleware Presets - Unified Plugin Architecture
2290
+ * const userRouter = createOptimizedRouter('/users', 2000);
2691
2291
  *
2692
- * Pre-configured middleware stacks for common use cases.
2693
- * Following copilot instructions - everything is now plugin-based.
2292
+ * userRouter.get('/profile', async (ctx) => {
2293
+ * ctx.res.json({ user: 'profile' });
2294
+ * });
2694
2295
  *
2695
- * NOTE: CORS functionality now uses the enterprise-grade CorsPlugin
2696
- * instead of built-in middleware for better performance and features.
2697
- */
2698
-
2699
- /**
2700
- * Available preset names
2701
- */
2702
- type PresetName = 'development' | 'production' | 'api' | 'fullFeatured';
2703
- interface PresetOptions {
2704
- cors?: boolean | any;
2705
- helmet?: boolean | any;
2706
- logger?: boolean | any;
2707
- bodyParser?: boolean | any;
2708
- [key: string]: any;
2709
- }
2710
- /**
2711
- * Development preset - Perfect for learning and debugging
2712
- * Uses enterprise CORS plugin for consistency
2713
- */
2714
- declare function developmentPreset(options?: PresetOptions): ExpressMiddleware$1[];
2715
- /**
2716
- * Production preset - Security and performance optimized
2717
- */
2718
- declare function productionPreset(options?: PresetOptions): ExpressMiddleware$1[];
2719
- /**
2720
- * API preset - Perfect for REST APIs
2721
- */
2722
- declare function apiPreset(options?: PresetOptions): ExpressMiddleware$1[];
2723
- /**
2724
- * Minimal preset - Just the basics
2725
- */
2726
- declare function minimalPreset(options?: PresetOptions): ExpressMiddleware$1[];
2727
- /**
2728
- * Security preset - Maximum security headers
2729
- */
2730
- declare function securityPreset(options?: PresetOptions): ExpressMiddleware$1[];
2731
- /**
2732
- * Full-featured preset - Everything enabled for enterprise applications
2733
- */
2734
- declare function fullFeaturedPreset(options?: PresetOptions): ExpressMiddleware$1[];
2735
- /**
2736
- * Get preset by name with enhanced options and fallback support
2296
+ * app.use(userRouter);
2297
+ * ```
2737
2298
  */
2738
- declare function getPreset(name: PresetName | string, options?: PresetOptions): ExpressMiddleware$1[];
2299
+ declare function createOptimizedRouter(prefix?: string, cacheSize?: number): OptimizedRouter;
2739
2300
 
2740
2301
  /**
2741
- * 🔧 Built-in Middleware - NextRush Framework
2302
+ * NextRush v2 - Main Entry Point
2742
2303
  *
2743
- * Re-exports all built-in middleware from plugins for easy access.
2744
- * This provides Express.js-like middleware functions that developers expect.
2745
- */
2746
-
2747
- /**
2748
- * Helmet Security Middleware
2749
- * Sets various HTTP headers to secure your app
2750
- */
2751
- declare function helmet(options?: Record<string, any>): ExpressMiddleware$1;
2752
- /**
2753
- * Logger Middleware
2754
- * Logs HTTP requests with timing
2755
- */
2756
- declare function logger(options?: {
2757
- format?: 'simple' | 'detailed' | 'json';
2758
- }): ExpressMiddleware$1;
2759
- /**
2760
- * Request ID Middleware
2761
- * Adds unique ID to each request
2762
- */
2763
- declare function requestId(options?: {
2764
- header?: string;
2765
- }): ExpressMiddleware$1;
2766
- /**
2767
- * Request Timer Middleware - Optimized version
2768
- * Adds response time header without memory leaks
2769
- */
2770
- declare function requestTimer(options?: {
2771
- header?: string;
2772
- }): ExpressMiddleware$1;
2773
- /**
2774
- * Compression Middleware - Optimized version
2775
- * Compresses response data efficiently
2776
- */
2777
- declare function compression(options?: {
2778
- level?: number;
2779
- threshold?: number;
2780
- filter?: (req: any, res: any) => boolean;
2781
- }): ExpressMiddleware$1;
2782
- /**
2783
- * Rate Limiting Middleware - Optimized with cleanup
2784
- * Limits requests per IP with automatic cleanup
2785
- */
2786
- declare function rateLimit(options?: {
2787
- windowMs?: number;
2788
- max?: number;
2789
- message?: string;
2790
- keyGenerator?: (req: any) => string;
2791
- }): ExpressMiddleware$1;
2792
-
2793
- /**
2794
- * 🚀 NextRush Framework - Modern/**
2795
- * Plugin methods interface for proper TypeScript IntelliSense
2796
- */
2797
- interface PluginMethods {
2798
- listen(port: number | string, hostname?: string | (() => void), callback?: () => void): this;
2799
- close(callback?: () => void): this;
2800
- startServer(port: number | string, hostname?: string | (() => void), callback?: () => void): this;
2801
- shutdown(callback?: () => void): this;
2802
- usePreset(name: string, options?: any): this;
2803
- useGroup(middlewares: any[]): this;
2804
- cors(options?: any): any;
2805
- helmet(options?: any): any;
2806
- compression(options?: any): any;
2807
- rateLimit(options?: any): any;
2808
- logger(options?: any): any;
2809
- requestId(options?: any): any;
2810
- timer(options?: any): any;
2811
- compose(...middlewares: any[]): any;
2812
- when(condition: any, middleware: any): any;
2813
- unless(condition: any, middleware: any): any;
2814
- getPlugin(name: string): any;
2815
- getMiddlewareMetrics(): any;
2816
- clearMiddlewareMetrics(): void;
2817
- ws?(path: string, handler: any): this;
2818
- enableWebSocket?(options?: any): this;
2819
- wsBroadcast?(data: any, room?: string): this;
2820
- getWebSocketStats?(): any;
2821
- getWebSocketConnections?(): any;
2822
- }
2823
- /**
2824
- * Extended Application type with all plugin methods for proper TypeScript IntelliSense
2825
- */
2826
- type ExtendedApplication = Application & PluginMethods;
2827
-
2828
- /**
2829
- * Create a new NextRush application with full type safety
2304
+ * @packageDocumentation
2830
2305
  */
2831
- declare function createApp(options?: ApplicationOptions): ExtendedApplication;
2832
2306
 
2833
- /**
2834
- * Create a new router instance
2835
- */
2836
- declare function createRouter(options?: RouterOptions): Router;
2307
+ declare const VERSION = "2.0.0-alpha.1";
2308
+ declare const NODE_VERSION = ">=18.0.0";
2837
2309
 
2838
- declare module './core/app/application' {
2839
- interface Application {
2840
- /**
2841
- * Start the server - backward compatibility
2842
- * @param port Port number or string
2843
- * @param hostname Optional hostname or callback
2844
- * @param callback Optional callback
2845
- * @returns Application instance
2846
- */
2847
- listen(port: number | string, hostname?: string | (() => void), callback?: () => void): Application;
2848
- /**
2849
- * Close the server - backward compatibility
2850
- * @param callback Optional callback
2851
- * @returns Application instance
2852
- */
2853
- close(callback?: () => void): Application;
2854
- /**
2855
- * Start the server - new method
2856
- * @param port Port number or string
2857
- * @param hostname Optional hostname or callback
2858
- * @param callback Optional callback
2859
- * @returns Application instance
2860
- */
2861
- startServer(port: number | string, hostname?: string | (() => void), callback?: () => void): Application;
2862
- /**
2863
- * Stop the server - new method
2864
- * @param callback Optional callback
2865
- * @returns Application instance
2866
- */
2867
- shutdown(callback?: () => void): Application;
2868
- }
2869
- }
2310
+ declare const _default: {
2311
+ readonly createApp: typeof createApp;
2312
+ readonly VERSION: "2.0.0-alpha.1";
2313
+ readonly NODE_VERSION: ">=18.0.0";
2314
+ };
2870
2315
 
2871
- export { Application, type ApplicationOptions, type AsyncMiddleware, BaseComponent, type BodyParserOptions, BodyParserPlugin, CommonRoles, type CompileResult, type CorsOptions, CorsPresets, type CustomMetric, ErrorHandler, type ErrorMiddleware, type ErrorRequestHandler, EventDrivenPlugin, type ExpressHandler$1 as ExpressHandler, type ExpressMiddleware$1 as ExpressMiddleware, type ExtendedApplication, type FilterRegistry, type HealthCheckFunction, type HealthCheckResult, type HealthStatus, type HelperRegistry, type HttpMethod, type I18nConfig, InternalServerError, type JwtOptions, type Lifecycle, MethodNotAllowedError, type MetricValue, type MetricsOptions, type Middleware, type MiddlewareHandler$1 as MiddlewareHandler, type NextFunction, NextRushError, type NextRushRequest, type NextRushResponse, NotFoundError, type ParseResult, type ParsedRequest, type ParsedResponse, type Path, type Permission, type PluginMethods, PluginMode, type RateLimiterData, type RateLimiterOptions, type RateLimiterStore, type RenderOptions, type RequestContext, type RequestHandler, type RequestMetrics, type Role, type Route, type RouteDefinition, type RouteHandler$1 as RouteHandler, Router, type RouterOptions, type SanitizationOptions, type SessionOptions, type SimpleTemplateOptions, StaticFilesPlugin, type StaticOptions, type SystemMetrics, type TemplateContext, TemplateHelperManager, type TemplateNode, type TemplateOptions, type TestRenderResult, UltimateTemplateParser, UltimateTemplateRenderer, type User, ValidationError, ValidationPlugin, type ValidationResult, type ValidationRule, type ValidationSchema, advancedTemplate, apiPreset, benchmarkTemplate, compareTemplateEngines, compose, compression, createApp, createPlugins, createRouter, createSlotMap, createTemplate, Application as default, developmentPreset, escapeHTML, evaluateCondition, fullFeaturedPreset, getPreset, getValue, group, helmet, logger, minimalPreset, named, parseFrontmatter, productionPreset, quickTemplate, rateLimit, requestId, requestTimer, resolveTemplatePath, securityPreset, testTemplateRender, unless, validateTemplateSyntax, webTemplate, when };
2316
+ export { type Application, AuthenticationError, AuthenticationExceptionFilter, AuthorizationError, AuthorizationExceptionFilter, BadRequestError, ConflictError, ConsoleTransport, type Context, DatabaseError, type DotfilesPolicy, ErrorFactory, type ExceptionFilter, FileTransport, ForbiddenError, GlobalExceptionFilter, HttpTransport, InternalServerError, type LogEntry, LogLevel, type LoggerConfig, LoggerPlugin, MethodNotAllowedError, type Middleware, NODE_VERSION, NetworkError, type Next, NextRushError, type NextRushRequest, type NextRushResponse$1 as NextRushResponse, NotFoundError, NotFoundExceptionFilter, RateLimitError, RateLimitExceptionFilter, RequestEnhancer, ResponseEnhancer, type RouteConfig, type RouteHandler, type Router, ServiceUnavailableError, type StaticFilesOptions, StaticFilesPlugin, type StatsLike, StreamTransport, type TemplateHelper, TemplatePlugin, type TemplatePluginOptions, type TemplateRenderOptions, TimeoutError, TooManyRequestsError, type Transport, UnauthorizedError, UnprocessableEntityError, VERSION, ValidationError, ValidationExceptionFilter, type WSConnection, type WSContext, type WSHandler, type WSMiddleware, type WebSocketApplication, WebSocketPlugin, type WebSocketPluginOptions, smartBodyParser as bodyParser, compression, cors, createApp, createContext, createDevLogger, createMinimalLogger, createProdLogger, createOptimizedRouter as createRouter, _default as default, hasWebSocketSupport, helmet, logger, rateLimit, requestId, timer, withWebSocket };