@stacksjs/bun-router 0.0.2 → 0.0.3

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.
Files changed (128) hide show
  1. package/dist/{chunk-r15a48wc.js → chunk-cjdekj87.js} +536 -98
  2. package/dist/cli.d.ts +1 -0
  3. package/dist/cli.js +2 -2
  4. package/dist/index.d.ts +3 -1
  5. package/dist/index.js +454 -119
  6. package/package.json +6 -8
  7. package/dist/auth.d.ts +0 -77
  8. package/dist/cache/lru-cache.d.ts +0 -88
  9. package/dist/cache/middleware-memoization.d.ts +0 -101
  10. package/dist/cache/route-cache-warmer.d.ts +0 -125
  11. package/dist/cache/sqlite-cache.d.ts +0 -114
  12. package/dist/cache/streaming-cache.d.ts +0 -86
  13. package/dist/cli/colors.d.ts +0 -12
  14. package/dist/cli/index.d.ts +0 -10
  15. package/dist/cli/middleware.d.ts +0 -31
  16. package/dist/cli/openapi.d.ts +0 -17
  17. package/dist/cli/router.d.ts +0 -15
  18. package/dist/cli/routes.d.ts +0 -30
  19. package/dist/cli/utils.d.ts +0 -68
  20. package/dist/config.d.ts +0 -274
  21. package/dist/container/container.d.ts +0 -141
  22. package/dist/container/contextual-binding.d.ts +0 -112
  23. package/dist/container/decorators.d.ts +0 -114
  24. package/dist/container/service-provider.d.ts +0 -221
  25. package/dist/development/hot-reload.d.ts +0 -129
  26. package/dist/development/index.d.ts +0 -144
  27. package/dist/development/performance-profiler.d.ts +0 -152
  28. package/dist/development/route-debugger.d.ts +0 -102
  29. package/dist/development/route-inspector.d.ts +0 -142
  30. package/dist/development/typescript-utilities.d.ts +0 -116
  31. package/dist/docs.d.ts +0 -10
  32. package/dist/errors/circuit-breaker.d.ts +0 -138
  33. package/dist/errors/error-handler.d.ts +0 -57
  34. package/dist/errors/error-reporting.d.ts +0 -135
  35. package/dist/errors/exceptions.d.ts +0 -178
  36. package/dist/errors/graceful-degradation.d.ts +0 -130
  37. package/dist/errors/index.d.ts +0 -6
  38. package/dist/errors/router-errors.d.ts +0 -97
  39. package/dist/file-serving/static-files.d.ts +0 -98
  40. package/dist/middleware/auth.d.ts +0 -34
  41. package/dist/middleware/content_security_policy.d.ts +0 -54
  42. package/dist/middleware/cors.d.ts +0 -5
  43. package/dist/middleware/csrf.d.ts +0 -7
  44. package/dist/middleware/ddos_protection.d.ts +0 -47
  45. package/dist/middleware/file_security.d.ts +0 -23
  46. package/dist/middleware/file_upload.d.ts +0 -41
  47. package/dist/middleware/helmet.d.ts +0 -54
  48. package/dist/middleware/index.d.ts +0 -55
  49. package/dist/middleware/input_validation.d.ts +0 -46
  50. package/dist/middleware/json_body.d.ts +0 -4
  51. package/dist/middleware/performance_alerting.d.ts +0 -88
  52. package/dist/middleware/performance_dashboard.d.ts +0 -97
  53. package/dist/middleware/performance_monitor.d.ts +0 -236
  54. package/dist/middleware/pipeline.d.ts +0 -90
  55. package/dist/middleware/rate_limit.d.ts +0 -33
  56. package/dist/middleware/request_id.d.ts +0 -4
  57. package/dist/middleware/request_signing.d.ts +0 -96
  58. package/dist/middleware/request_tracer.d.ts +0 -76
  59. package/dist/middleware/response_cache.d.ts +0 -90
  60. package/dist/middleware/security.d.ts +0 -70
  61. package/dist/middleware/security_suite.d.ts +0 -46
  62. package/dist/middleware/session.d.ts +0 -7
  63. package/dist/model-binding/index.d.ts +0 -17
  64. package/dist/model-binding/model-middleware.d.ts +0 -80
  65. package/dist/model-binding/model-registry.d.ts +0 -125
  66. package/dist/model-binding.d.ts +0 -123
  67. package/dist/model-resolver-factory.d.ts +0 -31
  68. package/dist/observability/correlation.d.ts +0 -131
  69. package/dist/observability/health-checks.d.ts +0 -129
  70. package/dist/observability/index.d.ts +0 -92
  71. package/dist/observability/integration.d.ts +0 -112
  72. package/dist/observability/metrics.d.ts +0 -135
  73. package/dist/observability/tracing.d.ts +0 -112
  74. package/dist/optimization/bun-utilities.d.ts +0 -106
  75. package/dist/query-builder-integration.d.ts +0 -24
  76. package/dist/request/enhanced-request.d.ts +0 -143
  77. package/dist/request/macros.d.ts +0 -267
  78. package/dist/response/macros.d.ts +0 -207
  79. package/dist/response/response-factory.d.ts +0 -93
  80. package/dist/router/file-based-routing.d.ts +0 -40
  81. package/dist/router/file-streaming.d.ts +0 -6
  82. package/dist/router/fluent-router.d.ts +0 -179
  83. package/dist/router/fluent-routing.d.ts +0 -198
  84. package/dist/router/group-organization.d.ts +0 -5
  85. package/dist/router/handler-resolver.d.ts +0 -13
  86. package/dist/router/http-methods.d.ts +0 -10
  87. package/dist/router/index.d.ts +0 -114
  88. package/dist/router/middleware-integration.d.ts +0 -86
  89. package/dist/router/middleware.d.ts +0 -5
  90. package/dist/router/model-binding.d.ts +0 -7
  91. package/dist/router/optimized-route-matching.d.ts +0 -6
  92. package/dist/router/route-building.d.ts +0 -5
  93. package/dist/router/route-compiler.d.ts +0 -67
  94. package/dist/router/route-matching.d.ts +0 -5
  95. package/dist/router/route-trie.d.ts +0 -69
  96. package/dist/router/router.d.ts +0 -133
  97. package/dist/router/server.d.ts +0 -5
  98. package/dist/router/validation-integration.d.ts +0 -116
  99. package/dist/router/view-rendering.d.ts +0 -5
  100. package/dist/router/websocket.d.ts +0 -5
  101. package/dist/routing/route-caching.d.ts +0 -105
  102. package/dist/routing/route-throttling.d.ts +0 -112
  103. package/dist/routing/subdomain-routing.d.ts +0 -159
  104. package/dist/streaming/index.d.ts +0 -15
  105. package/dist/streaming/sse-handler.d.ts +0 -81
  106. package/dist/streaming/stream-handler.d.ts +0 -81
  107. package/dist/testing/auth-testing.d.ts +0 -107
  108. package/dist/testing/file-upload-testing.d.ts +0 -139
  109. package/dist/testing/index.d.ts +0 -10
  110. package/dist/testing/middleware-testing.d.ts +0 -99
  111. package/dist/testing/model-binding-testing.d.ts +0 -132
  112. package/dist/testing/performance-testing.d.ts +0 -202
  113. package/dist/testing/test-client.d.ts +0 -58
  114. package/dist/testing/test-request.d.ts +0 -43
  115. package/dist/testing/test-response.d.ts +0 -45
  116. package/dist/testing/types.d.ts +0 -206
  117. package/dist/testing/websocket-testing.d.ts +0 -170
  118. package/dist/types/controller-types.d.ts +0 -303
  119. package/dist/types/core.d.ts +0 -526
  120. package/dist/types/middleware-types.d.ts +0 -315
  121. package/dist/types/request-response-augmentation.d.ts +0 -373
  122. package/dist/types/route-inference.d.ts +0 -287
  123. package/dist/types.d.ts +0 -1620
  124. package/dist/utils/index.d.ts +0 -1
  125. package/dist/utils/query-preservation.d.ts +0 -31
  126. package/dist/utils.d.ts +0 -69
  127. package/dist/validation/validator.d.ts +0 -169
  128. package/dist/websocket/clustering.d.ts +0 -114
@@ -1,40 +0,0 @@
1
- import type { EnhancedRequest } from '../types';
2
- import type { Router } from './router';
3
- export type { DiscoveredRoute };
4
- /**
5
- * Registers file-based routing extension on the Router class
6
- */
7
- export declare function registerFileBasedRouting(RouterClass: typeof Router): void;
8
- /**
9
- * File-based routing configuration
10
- */
11
- export declare interface FileBasedRoutingConfig {
12
- enabled?: boolean
13
- viewsPath?: string
14
- extensions?: string[]
15
- exclude?: string[]
16
- render?: (filePath: string, data: Record<string, unknown>, request: EnhancedRequest) => Promise<Response>
17
- }
18
- declare interface DiscoveredRoute {
19
- filePath: string
20
- routePath: string
21
- params: string[]
22
- isIndex: boolean
23
- isDynamic: boolean
24
- }
25
- // Type augmentation for Router
26
- declare module './router' {
27
- interface Router {
28
- _viewsDir?: string | null
29
- _fileRoutingConfig?: FileBasedRoutingConfig | null
30
- _fileBasedRoutes?: DiscoveredRoute[]
31
- _fileRoutesInitialized?: boolean
32
- _initFileRoutes(): Promise<void>
33
- views(config: FileBasedRoutingConfig | string): Router
34
- disableFileRouting(): Router
35
- getFileRoutes(): DiscoveredRoute[]
36
- fileRoutes(viewsPath?: string, options?: Omit<FileBasedRoutingConfig, 'viewsPath'>): Promise<Router>
37
- loadFileRoutes(config?: FileBasedRoutingConfig): Promise<Router>
38
- }
39
- }
40
- export { detectViewsDirectory, discoverRoutes, DEFAULT_VIEW_DIRECTORIES, DEFAULT_EXCLUDES, DEFAULT_EXTENSIONS };
@@ -1,6 +0,0 @@
1
- import type { } from '../types';
2
- import type { Router } from './router';
3
- /**
4
- * File streaming extension for Router class
5
- */
6
- export declare function registerFileStreaming(RouterClass: typeof Router): void;
@@ -1,179 +0,0 @@
1
- import type { ActionHandler, EnhancedRequest, MiddlewareHandler, Route, RouteHandler, } from '../types';
2
- import type { Router } from './router';
3
- /**
4
- * Extend Router with fluent routing methods
5
- */
6
- export declare function registerFluentRouting(RouterClass: typeof import('./router').Router): void;
7
- /**
8
- * Controller class interface
9
- */
10
- export declare interface ControllerClass {
11
- new (): Controller
12
- }
13
- /**
14
- * Base controller interface
15
- */
16
- export declare interface Controller {
17
-
18
- }
19
- /**
20
- * Resource configuration
21
- */
22
- export declare interface ResourceOptions {
23
- only?: ResourceMethod[]
24
- except?: ResourceMethod[]
25
- middleware?: (string | MiddlewareHandler)[]
26
- names?: Partial<Record<ResourceMethod, string>>
27
- parameters?: Record<string, string>
28
- shallow?: boolean
29
- }
30
- /**
31
- * Route builder for fluent API
32
- */
33
- export declare interface FluentRoute {
34
- name: (name: string) => FluentRoute
35
- middleware: (...middleware: (string | MiddlewareHandler)[]) => FluentRoute
36
- withoutMiddleware: (...middleware: string[]) => FluentRoute
37
- where: (param: string, pattern: string | RegExp) => FluentRoute
38
- whereNumber: (param: string) => FluentRoute
39
- whereAlpha: (param: string) => FluentRoute
40
- whereAlphaNumeric: (param: string) => FluentRoute
41
- whereUuid: (param: string) => FluentRoute
42
- whereSlug: (param: string) => FluentRoute
43
- can: (ability: string, model?: string) => FluentRoute
44
- missing: (handler: (req: EnhancedRequest) => Response) => FluentRoute
45
- withTrashed: () => FluentRoute
46
- scopeBindings: () => FluentRoute
47
- }
48
- /**
49
- * Group builder for fluent API
50
- */
51
- export declare interface GroupBuilder {
52
- prefix: (prefix: string) => GroupBuilder
53
- name: (name: string) => GroupBuilder
54
- middleware: (...middleware: (string | MiddlewareHandler)[]) => GroupBuilder
55
- domain: (domain: string) => GroupBuilder
56
- controller: (controller: ControllerClass) => GroupBuilder
57
- routes: (callback: (router: FluentRouter) => void) => void
58
- }
59
- declare interface GroupOptions {
60
- prefix?: string
61
- as?: string
62
- middleware?: (string | MiddlewareHandler)[]
63
- domain?: string
64
- controller?: ControllerClass
65
- }
66
- /**
67
- * Resource controller methods
68
- */
69
- export type ResourceMethod = 'index' | 'create' | 'store' | 'show' | 'edit' | 'update' | 'destroy'
70
- /**
71
- * API resource methods (no create/edit views)
72
- */
73
- export type ApiResourceMethod = 'index' | 'store' | 'show' | 'update' | 'destroy'
74
- /**
75
- * Singleton resource methods
76
- */
77
- export type SingletonMethod = 'show' | 'edit' | 'update'
78
- /**
79
- * Fluent router with chainable API
80
- */
81
- export declare class FluentRouter {
82
- private router: Router;
83
- private currentPrefix: string;
84
- private currentNamePrefix: string;
85
- private currentMiddleware: (string | MiddlewareHandler)[];
86
- private currentDomain: string | null;
87
- private currentController: ControllerClass | null;
88
- private excludedMiddleware: Set<string>;
89
- constructor(router: Router);
90
- get(path: string, handler: RouteHandler | string): FluentRouteBuilder;
91
- post(path: string, handler: RouteHandler | string): FluentRouteBuilder;
92
- put(path: string, handler: RouteHandler | string): FluentRouteBuilder;
93
- patch(path: string, handler: RouteHandler | string): FluentRouteBuilder;
94
- delete(path: string, handler: RouteHandler | string): FluentRouteBuilder;
95
- options(path: string, handler: RouteHandler | string): FluentRouteBuilder;
96
- any(path: string, handler: RouteHandler | string): FluentRouteBuilder;
97
- match(methods: string[], path: string, handler: RouteHandler | string): FluentRouteBuilder;
98
- resource(name: string, Controller: ControllerClass, options?: ResourceOptions): this;
99
- apiResource(name: string, controller: ControllerClass, options?: ResourceOptions): this;
100
- singleton(name: string, Controller: ControllerClass, options?: ResourceOptions): this;
101
- prefix(prefix: string): GroupBuilderImpl;
102
- name(namePrefix: string): GroupBuilderImpl;
103
- middleware(middleware: (string | MiddlewareHandler)[]): GroupBuilderImpl;
104
- domain(domain: string): GroupBuilderImpl;
105
- controller(controller: ControllerClass): GroupBuilderImpl;
106
- group(options: GroupOptions, callback: (router: FluentRouter) => void): this;
107
- has(name: string): boolean;
108
- current(): Route | null;
109
- currentRouteName(): string | null;
110
- route(name: string, params?: Record<string, string | number>): string;
111
- fallback(handler: RouteHandler): this;
112
- private addRoute(method: string, path: string, handler: RouteHandler | string): FluentRouteBuilder;
113
- private createPattern(routePath: string): { exec: (url: URL) => { pathname: { groups: Record<string, string> } } | null };
114
- private buildPath(path: string): string;
115
- private buildMiddleware(additional?: (string | MiddlewareHandler)[]): MiddlewareHandler[];
116
- private resolveHandler(handler: RouteHandler | string): ActionHandler;
117
- private resolveMiddleware(middleware: string | MiddlewareHandler): MiddlewareHandler;
118
- private getResourceMethods(options: ResourceOptions): ResourceMethod[];
119
- private getResourceRoute(name: string, method: ResourceMethod, paramName: string): { httpMethod: string, path: string, handlerName: string };
120
- private getSingletonRoute(name: string, method: SingletonMethod): { httpMethod: string, handlerName: string };
121
- }
122
- /**
123
- * Fluent route builder for chaining route configuration
124
- */
125
- export declare class FluentRouteBuilder implements FluentRoute {
126
- private router: Router;
127
- private path: string;
128
- private method: string;
129
- private routeName: string | null;
130
- private routeMiddleware: MiddlewareHandler[];
131
- private excludedMiddleware: string[];
132
- private constraints: Record<string, string | RegExp>;
133
- private missingHandler: ((req: EnhancedRequest) => Response) | null;
134
- private includeTrashed: boolean;
135
- private scopeBindingsEnabled: boolean;
136
- private ability: string | null;
137
- private abilityModel: string | null;
138
- constructor(router: Router, path: string, method: string);
139
- name(name: string): this;
140
- middleware(middleware: (string | MiddlewareHandler)[]): this;
141
- withoutMiddleware(middleware: string[]): this;
142
- where(param: string, pattern: string | RegExp): this;
143
- whereNumber(param: string): this;
144
- whereAlpha(param: string): this;
145
- whereAlphaNumeric(param: string): this;
146
- whereUuid(param: string): this;
147
- whereSlug(param: string): this;
148
- can(ability: string, model?: string): this;
149
- missing(handler: (req: EnhancedRequest) => Response): this;
150
- withTrashed(): this;
151
- scopeBindings(): this;
152
- private findRoute(): Route | undefined;
153
- }
154
- declare class GroupBuilderImpl implements GroupBuilder {
155
- private fluentRouter: FluentRouter;
156
- private options: GroupOptions;
157
- constructor(router: FluentRouter);
158
- prefix(prefix: string): this;
159
- name(name: string): this;
160
- middleware(middleware: (string | MiddlewareHandler)[]): this;
161
- domain(domain: string): this;
162
- controller(controller: ControllerClass): this;
163
- routes(callback: (router: FluentRouter) => void): void;
164
- }
165
- // ============================================================================
166
- // Type Augmentation
167
- // ============================================================================
168
- declare module './router' {
169
- interface Router {
170
- fluent: () => FluentRouter
171
- resourceController: (name: string, controller: ControllerClass, options?: ResourceOptions) => Router
172
- apiResourceController: (name: string, controller: ControllerClass, options?: ResourceOptions) => Router
173
- singletonResource: (name: string, controller: ControllerClass, options?: ResourceOptions) => Router
174
- hasRoute: (name: string) => boolean
175
- currentRoute: () => Route | null
176
- currentRouteName: () => string | null
177
- routeUrl: (name: string, params?: Record<string, string | number>) => string
178
- }
179
- }
@@ -1,198 +0,0 @@
1
- import { RouteCacheFactory } from '../routing/route-caching';
2
- import { ThrottleFactory } from '../routing/route-throttling';
3
- import type { BunQueryBuilderModel } from '../model-binding';
4
- import type { EnhancedRequest, MiddlewareHandler, RouteHandler, ThrottlePattern } from '../types';
5
- import type { RouteCacheConfig } from '../routing/route-caching';
6
- import type { ThrottleConfig } from '../routing/route-throttling';
7
- /**
8
- * Factory functions for common route patterns
9
- */
10
- export declare const RouteFactory: {
11
- api: (path: string, handler: RouteHandler, options?: ApiRouteOptions) => FluentRouteBuilder
12
- protected: (path: string, handler: RouteHandler, options?: ProtectedRouteOptions) => FluentRouteBuilder
13
- upload: (path: string, handler: RouteHandler, options?: UploadRouteOptions) => FluentRouteBuilder
14
- };
15
- /**
16
- * Utility functions
17
- */
18
- export declare const RouterUtils: {
19
- /**
20
- * Generate route URL with parameters
21
- */
22
- route: (name: string, params: Record<string, string> = {}, query: Record<string, string> = {}) => any;
23
- /**
24
- * Redirect response
25
- */
26
- redirect: (url: string, status: number?) => any;
27
- /**
28
- * JSON response
29
- */
30
- json: (data: any, status: number?) => any
31
- };
32
- /**
33
- * Global router instance
34
- */
35
- export declare const router: FluentRouter;
36
- /**
37
- * Conditional middleware wrapper
38
- */
39
- export declare interface ConditionalMiddleware {
40
- condition: MiddlewareCondition
41
- middleware: MiddlewareHandler[]
42
- }
43
- /** API route options */
44
- export declare interface ApiRouteOptions {
45
- method?: string
46
- cache?: string[]
47
- throttle?: string
48
- }
49
- /** Protected route options */
50
- export declare interface ProtectedRouteOptions {
51
- method?: string
52
- roles?: string[]
53
- }
54
- /** Upload route options */
55
- export declare interface UploadRouteOptions {
56
- maxSize?: number
57
- allowedTypes?: string[]
58
- }
59
- /**
60
- * Middleware condition function type
61
- */
62
- export type MiddlewareCondition = (request: EnhancedRequest) => boolean | Promise<boolean>
63
- /**
64
- * Fluent route builder with chainable API
65
- */
66
- export declare class FluentRouteBuilder {
67
- private middleware: MiddlewareHandler[];
68
- private cacheConfig?: RouteCacheConfig;
69
- private throttleConfig?: ThrottleConfig;
70
- private routeName?: string;
71
- private modelBindings: Record<string, BunQueryBuilderModel>;
72
- private method: string;
73
- private path: string;
74
- private handler: RouteHandler;
75
- constructor(method: string, path: string, handler: RouteHandler);
76
- addMiddleware(middleware: MiddlewareHandler | MiddlewareHandler[]): this;
77
- cached(tags?: string[], config?: Partial<RouteCacheConfig>): this;
78
- throttle(limit: ThrottlePattern | ThrottleConfig, _name?: string): this;
79
- name(name: string): this;
80
- model(parameter: string, model: BunQueryBuilderModel): this;
81
- build(): {
82
- method: string
83
- path: string
84
- handler: RouteHandler
85
- middleware: MiddlewareHandler[]
86
- name?: string
87
- };
88
- }
89
- /**
90
- * Builder for conditional middleware
91
- */
92
- export declare class FluentConditionalBuilder {
93
- private router: FluentRouter;
94
- private condition: MiddlewareCondition;
95
- constructor(router: FluentRouter, condition: MiddlewareCondition);
96
- middleware(middlewareName: string): this;
97
- }
98
- /**
99
- * Builder for middleware with parameters
100
- */
101
- export declare class FluentMiddlewareBuilder {
102
- private router: FluentRouter;
103
- private middleware: MiddlewareHandler[];
104
- constructor(router: FluentRouter, middleware: MiddlewareHandler[]);
105
- get(path: string, handler: RouteHandler): FluentRouteBuilder;
106
- post(path: string, handler: RouteHandler): FluentRouteBuilder;
107
- put(path: string, handler: RouteHandler): FluentRouteBuilder;
108
- delete(path: string, handler: RouteHandler): FluentRouteBuilder;
109
- patch(path: string, handler: RouteHandler): FluentRouteBuilder;
110
- }
111
- /**
112
- * Builder for route groups with middleware
113
- */
114
- export declare class FluentRouteGroupBuilder {
115
- private router: FluentRouter;
116
- private groupMiddleware: MiddlewareHandler[];
117
- constructor(router: FluentRouter, groupMiddleware: MiddlewareHandler[]);
118
- get(path: string, handler: RouteHandler): FluentRouteBuilder;
119
- post(path: string, handler: RouteHandler): FluentRouteBuilder;
120
- put(path: string, handler: RouteHandler): FluentRouteBuilder;
121
- delete(path: string, handler: RouteHandler): FluentRouteBuilder;
122
- patch(path: string, handler: RouteHandler): FluentRouteBuilder;
123
- }
124
- /**
125
- * Fluent router with chainable API and advanced features
126
- */
127
- export declare class FluentRouter {
128
- private routes: Array<{
129
- method: string
130
- path: string
131
- handler: RouteHandler
132
- middleware: MiddlewareHandler[]
133
- name?: string
134
- }>;
135
- private globalMiddleware: MiddlewareHandler[];
136
- private subdomainRouter: any;
137
- private routeGroups: Array<{
138
- prefix?: string
139
- middleware?: MiddlewareHandler[]
140
- name?: string
141
- domain?: string
142
- }>;
143
- private middlewareGroups: any;
144
- private namedMiddleware: any;
145
- private conditionalMiddleware: ConditionalMiddleware[];
146
- constructor();
147
- private setupDefaultMiddleware(): void;
148
- middlewareGroup(name: string, middlewareNames: string[]): this;
149
- middlewareGroupRoutes(name: string): FluentRouteGroupBuilder;
150
- when(condition: MiddlewareCondition): FluentConditionalBuilder;
151
- middleware(middlewareName: string): FluentMiddlewareBuilder;
152
- use(middleware: MiddlewareHandler): this;
153
- get(path: string, handler: RouteHandler): FluentRouteBuilder;
154
- post(path: string, handler: RouteHandler): FluentRouteBuilder;
155
- put(path: string, handler: RouteHandler): FluentRouteBuilder;
156
- delete(path: string, handler: RouteHandler): FluentRouteBuilder;
157
- patch(path: string, handler: RouteHandler): FluentRouteBuilder;
158
- register(builder: FluentRouteBuilder): this;
159
- cached(tags?: string[], config?: Partial<RouteCacheConfig>): {
160
- get: (path: string, handler: RouteHandler) => FluentRouteBuilder
161
- post: (path: string, handler: RouteHandler) => FluentRouteBuilder
162
- put: (path: string, handler: RouteHandler) => FluentRouteBuilder
163
- delete: (path: string, handler: RouteHandler) => FluentRouteBuilder
164
- patch: (path: string, handler: RouteHandler) => FluentRouteBuilder
165
- };
166
- throttled(limit: ThrottlePattern | ThrottleConfig): {
167
- get: (path: string, handler: RouteHandler) => FluentRouteBuilder
168
- post: (path: string, handler: RouteHandler) => FluentRouteBuilder
169
- put: (path: string, handler: RouteHandler) => FluentRouteBuilder
170
- delete: (path: string, handler: RouteHandler) => FluentRouteBuilder
171
- patch: (path: string, handler: RouteHandler) => FluentRouteBuilder
172
- };
173
- group(config: {
174
- prefix?: string
175
- middleware?: MiddlewareHandler[]
176
- name?: string
177
- domain?: string
178
- }, callback: (router: FluentRouter) => void): this;
179
- domain(pattern: string): {
180
- routes: (callback: (router: FluentRouter) => void) => FluentRouter
181
- };
182
- resource(name: string, controller: any, options?: {
183
- only?: string[]
184
- except?: string[]
185
- model?: BunQueryBuilderModel
186
- }): this;
187
- getRoutes(): Array<{
188
- method: string
189
- path: string
190
- handler: RouteHandler
191
- middleware: MiddlewareHandler[]
192
- name?: string
193
- }>;
194
- handle(request: EnhancedRequest): Promise<Response | null>;
195
- private matchesRoute(route: any, request: EnhancedRequest): boolean;
196
- private executeRoute(route: any, request: EnhancedRequest): Promise<Response>;
197
- }
198
- export { RouteCacheFactory, ThrottleFactory };
@@ -1,5 +0,0 @@
1
- import type { Router } from './router';
2
- /**
3
- * Route grouping and organization extension for Router class
4
- */
5
- export declare function registerGroupOrganization(RouterClass: typeof Router): void;
@@ -1,13 +0,0 @@
1
- import type { EnhancedRequest, RouterConfig } from '../types';
2
- /**
3
- * Wraps a value in a Response object if it's not already a Response
4
- */
5
- export declare function wrapResponse(value: unknown): Response;
6
- /**
7
- * Resolves and executes a handler, returning a Response
8
- */
9
- export declare function resolveHandler(handler: unknown, req: EnhancedRequest, config: RouterConfig): Promise<Response>;
10
- /**
11
- * Creates a handler resolver bound to a specific config
12
- */
13
- export declare function createHandlerResolver(config: RouterConfig): (handler: unknown, req: EnhancedRequest) => Promise<Response>;
@@ -1,10 +0,0 @@
1
- import type { Router } from './router';
2
- /**
3
- * HTTP methods extension for Router class
4
- * Uses a class extension pattern instead of prototype manipulation
5
- */
6
- export declare function registerHttpMethods(RouterClass: typeof Router): void;
7
- /**
8
- * Register redirect methods on the Router class
9
- */
10
- export declare function registerRedirectMethods(RouterClass: typeof Router): void;
@@ -1,114 +0,0 @@
1
- import { Dependencies, globalMiddlewarePipeline, MiddlewareFactory, MiddlewarePipeline, SkipConditions } from '../middleware/pipeline';
2
- import { FluentRouteBuilder, FluentRouter, RouteFactory, router, RouterUtils } from './fluent-routing';
3
- import { Router } from './router';
4
- import type { ActionHandler, Route } from '../types';
5
- export type { DiscoveredRoute, FileBasedRoutingConfig } from './file-based-routing';
6
- // Type augmentation for Laravel-style methods
7
- declare module './router' {
8
- interface Router {
9
- stream: (
10
- callback: () => Generator<string | Uint8Array, void, unknown> | AsyncGenerator<string | Uint8Array, void, unknown>,
11
- status?: number,
12
- headers?: Record<string, string>
13
- ) => Response
14
- streamJson: <T>(
15
- data: Record<string, Iterable<T> | AsyncIterable<T>>,
16
- status?: number,
17
- headers?: Record<string, string>
18
- ) => Response
19
- eventStream: <_T = any>(
20
- callback: () => Generator<{ data: any, event?: string, id?: string, retry?: number }, void, unknown> | AsyncGenerator<{ data: any, event?: string, id?: string, retry?: number }, void, unknown>,
21
- headers?: Record<string, string>
22
- ) => Response
23
- streamDownload: (
24
- callback: () => Generator<string | Uint8Array, void, unknown> | AsyncGenerator<string | Uint8Array, void, unknown>,
25
- filename: string,
26
- headers?: Record<string, string>
27
- ) => Response
28
- streamFile: (
29
- filePath: string,
30
- request: any,
31
- options?: {
32
- contentType?: string
33
- enableRanges?: boolean
34
- chunkSize?: number
35
- }
36
- ) => Promise<Response>
37
- streamFileWithRanges: (filePath: string, req: any) => Promise<Response>
38
- streamResponse: (
39
- generator: () => AsyncGenerator<string | Uint8Array, void, unknown>,
40
- options?: { headers?: Record<string, string>, status?: number }
41
- ) => Response
42
- transformStream: (
43
- transformer: (chunk: string | Uint8Array) => string | Uint8Array | Promise<string | Uint8Array>,
44
- options?: { headers?: Record<string, string>, status?: number }
45
- ) => (req: Request) => Response
46
- model: <T>(
47
- key: string,
48
- modelClass: string | ((value: string) => Promise<T | null>),
49
- callback?: (model: T | null) => Response | null
50
- ) => Router
51
- implicitBinding: () => any
52
- missing: (callback: (req: any) => Response) => any
53
- scopedBindings: (bindings: Record<string, string>) => any
54
- clearModelCache: (modelName?: string) => Router
55
- getModelStats: () => {
56
- totalEntries: number
57
- validEntries: number
58
- expiredEntries: number
59
- models: number
60
- }
61
- modelRegistry: {
62
- has: (name: string) => boolean
63
- register: <_T>(name: string, config: any) => void
64
- resolve: <_T>(modelName: string, params: Record<string, string>, req?: any) => Promise<any>
65
- createErrorResponse: (modelName: string, result: any, params: Record<string, string>) => Response
66
- clearCache: (modelName: string, params?: Record<string, string>) => void
67
- clearAllCache: () => void
68
- getCacheStats: () => any
69
- }
70
- matchRoute: (path: string, method: string, domain?: string) => { route: Route, params: Record<string, string> } | undefined
71
- getAllowedMethods: (path: string, domain?: string) => string[]
72
- clearRouteCache: () => void
73
- getCacheStats: () => any
74
- getRouteStats: () => any
75
- warmRouteCache: (commonPaths: Array<{ path: string, method: string }>) => void
76
- getRoutesByMethod: () => any
77
- getRouteConflicts: () => any
78
- rebuildRouteCompiler: () => void
79
- optimizeRoutes: (usageStats?: Record<string, number>) => void
80
- addRouteToCompiler: (route: Route) => void
81
- initializeRouteCompiler: () => void
82
- health: () => Promise<Router>
83
- renderView: (view: string, data?: Record<string, any>, options?: { layout?: string }) => Promise<string>
84
- view: (path: string, view: string, data?: Record<string, any>, options?: { layout?: string, status?: number, headers?: Record<string, string> }) => Promise<Router>
85
- where: ((param: string, pattern: string | RegExp) => Router) & ((constraints: Record<string, string | RegExp>) => Router)
86
- whereNumber: (param: string) => Router
87
- whereAlpha: (param: string) => Router
88
- whereAlphaNumeric: (param: string) => Router
89
- whereUuid: (param: string) => Router
90
- whereIn: (param: string, values: string[]) => Router
91
- domain: (domain: string, callback: () => Promise<void> | void) => Promise<Router>
92
- resource: (name: string, handlers: {
93
- index?: ActionHandler
94
- show?: ActionHandler
95
- store?: ActionHandler
96
- update?: ActionHandler
97
- destroy?: ActionHandler
98
- create?: ActionHandler
99
- edit?: ActionHandler
100
- }) => Promise<Router>
101
- onError: (handler: (error: Error) => Response | Promise<Response>) => Router
102
- redirect: (url: string, status?: 301 | 302 | 303 | 307 | 308) => Response
103
- permanentRedirect: (url: string) => Response
104
- fallback: (handler: ActionHandler) => Router
105
- route: (name: string, params?: Record<string, string>) => string
106
- }
107
- }
108
- export { Router };
109
- export { Dependencies, FluentRouteBuilder, FluentRouter, globalMiddlewarePipeline, MiddlewareFactory, MiddlewarePipeline, RouteFactory, router, RouterUtils, SkipConditions };
110
- export * from '../routing/route-caching';
111
- export * from '../routing/route-throttling';
112
- export * from '../routing/subdomain-routing';
113
- export { createHandlerResolver, resolveHandler, wrapResponse } from './handler-resolver';
114
- export * from './validation-integration';
@@ -1,86 +0,0 @@
1
- import type { EnhancedRequest, MiddlewareHandler } from '../types';
2
- import type { Router } from './router';
3
- /**
4
- * Integration layer for middleware pipeline with the router
5
- */
6
- export declare function registerMiddlewarePipeline(RouterClass: typeof Router): void;
7
- /**
8
- * Helper function to setup common middleware stack
9
- */
10
- export declare function setupMiddlewareStack(router: any, options?: {
11
- auth?: {
12
- jwtSecret: string
13
- skipPaths?: string[]
14
- requireRoles?: string[]
15
- }
16
- rateLimit?: {
17
- maxRequests: number
18
- windowMs: number
19
- skipPaths?: string[]
20
- }
21
- cors?: {
22
- origin?: string | string[]
23
- methods?: string[]
24
- allowedHeaders?: string[]
25
- credentials?: boolean
26
- }
27
- logging?: {
28
- level?: string
29
- skipPaths?: string[]
30
- }
31
- }): MiddlewareHandler[];
32
- /**
33
- * Skip condition helpers
34
- */
35
- export declare const SkipConditions: {
36
- skipForPaths: (paths: string[]) => any;
37
- skipForMethods: (methods: string[]) => any
38
- };
39
- /**
40
- * Dependency helpers
41
- */
42
- export declare const Dependencies: {
43
- cache: (config: { type: string, ttl: number }) => unknown;
44
- logger: (level: string) => unknown
45
- };
46
- // Type placeholders for middleware pipeline
47
- export type SkipConditionFn = (req: EnhancedRequest) => boolean
48
- export type SkipConditionsList = SkipConditionFn[]
49
- declare class MiddlewarePipeline {
50
- registerDependency(_key: string, _dependency: any): this;
51
- registerSkipConditions(_middleware: MiddlewareHandler, _conditions: SkipConditionsList): void;
52
- getStats(): any;
53
- getCacheInfo(): any;
54
- clearCache(): this;
55
- compilePipeline(_key: string, _middleware: MiddlewareHandler[], _options?: any): void;
56
- execute(_key: string, _req: EnhancedRequest, _handler: () => Promise<Response>): Promise<Response>;
57
- }
58
- /**
59
- * Middleware factory for common use cases
60
- */
61
- export declare class MiddlewareFactory {
62
- private pipeline: MiddlewarePipeline;
63
- constructor(pipeline: MiddlewarePipeline);
64
- createAuthMiddleware(options?: {
65
- skipPaths?: string[]
66
- skipMethods?: string[]
67
- requireRoles?: string[]
68
- jwtSecret?: string
69
- }): MiddlewareHandler;
70
- createRateLimitMiddleware(options: {
71
- maxRequests: number
72
- windowMs: number
73
- skipPaths?: string[]
74
- }): MiddlewareHandler;
75
- createLoggingMiddleware(options?: {
76
- level?: string
77
- skipPaths?: string[]
78
- includeBody?: boolean
79
- }): MiddlewareHandler;
80
- createCorsMiddleware(options?: {
81
- origin?: string | string[]
82
- methods?: string[]
83
- allowedHeaders?: string[]
84
- credentials?: boolean
85
- }): MiddlewareHandler;
86
- }
@@ -1,5 +0,0 @@
1
- import type { Router } from './router';
2
- /**
3
- * Middleware handling extension for Router class
4
- */
5
- export declare function registerMiddlewareHandling(RouterClass: typeof Router): void;
@@ -1,7 +0,0 @@
1
- import { } from '../model-binding/model-registry';
2
- import type { } from '../types';
3
- import type { Router } from './router';
4
- /**
5
- * Model binding extension for Router class
6
- */
7
- export declare function registerModelBinding(RouterClass: typeof Router): void;
@@ -1,6 +0,0 @@
1
- import type { Router } from './router';
2
- /**
3
- * Optimized route matching extension for Router class
4
- * Replaces the original route matching with high-performance trie-based matching
5
- */
6
- export declare function registerOptimizedRouteMatching(RouterClass: typeof Router): void;