@stacksjs/bun-router 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +397 -0
- package/bin/cli.ts +9 -0
- package/dist/auth.d.ts +77 -0
- package/dist/cache/lru-cache.d.ts +88 -0
- package/dist/cache/middleware-memoization.d.ts +101 -0
- package/dist/cache/route-cache-warmer.d.ts +125 -0
- package/dist/cache/sqlite-cache.d.ts +114 -0
- package/dist/cache/streaming-cache.d.ts +86 -0
- package/dist/chunk-r15a48wc.js +25448 -0
- package/dist/cli/colors.d.ts +12 -0
- package/dist/cli/index.d.ts +10 -0
- package/dist/cli/middleware.d.ts +31 -0
- package/dist/cli/openapi.d.ts +17 -0
- package/dist/cli/router.d.ts +15 -0
- package/dist/cli/routes.d.ts +30 -0
- package/dist/cli/utils.d.ts +68 -0
- package/dist/cli.d.ts +0 -0
- package/dist/cli.js +3195 -0
- package/dist/config.d.ts +274 -0
- package/dist/container/container.d.ts +141 -0
- package/dist/container/contextual-binding.d.ts +112 -0
- package/dist/container/decorators.d.ts +114 -0
- package/dist/container/service-provider.d.ts +221 -0
- package/dist/development/hot-reload.d.ts +129 -0
- package/dist/development/index.d.ts +144 -0
- package/dist/development/performance-profiler.d.ts +152 -0
- package/dist/development/route-debugger.d.ts +102 -0
- package/dist/development/route-inspector.d.ts +142 -0
- package/dist/development/typescript-utilities.d.ts +116 -0
- package/dist/docs.d.ts +10 -0
- package/dist/errors/circuit-breaker.d.ts +138 -0
- package/dist/errors/error-handler.d.ts +57 -0
- package/dist/errors/error-reporting.d.ts +135 -0
- package/dist/errors/exceptions.d.ts +178 -0
- package/dist/errors/graceful-degradation.d.ts +130 -0
- package/dist/errors/index.d.ts +6 -0
- package/dist/errors/router-errors.d.ts +97 -0
- package/dist/file-serving/static-files.d.ts +98 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +13417 -0
- package/dist/middleware/auth.d.ts +34 -0
- package/dist/middleware/content_security_policy.d.ts +54 -0
- package/dist/middleware/cors.d.ts +5 -0
- package/dist/middleware/csrf.d.ts +7 -0
- package/dist/middleware/ddos_protection.d.ts +47 -0
- package/dist/middleware/file_security.d.ts +23 -0
- package/dist/middleware/file_upload.d.ts +41 -0
- package/dist/middleware/helmet.d.ts +54 -0
- package/dist/middleware/index.d.ts +55 -0
- package/dist/middleware/input_validation.d.ts +46 -0
- package/dist/middleware/json_body.d.ts +4 -0
- package/dist/middleware/performance_alerting.d.ts +88 -0
- package/dist/middleware/performance_dashboard.d.ts +97 -0
- package/dist/middleware/performance_monitor.d.ts +236 -0
- package/dist/middleware/pipeline.d.ts +90 -0
- package/dist/middleware/rate_limit.d.ts +33 -0
- package/dist/middleware/request_id.d.ts +4 -0
- package/dist/middleware/request_signing.d.ts +96 -0
- package/dist/middleware/request_tracer.d.ts +76 -0
- package/dist/middleware/response_cache.d.ts +90 -0
- package/dist/middleware/security.d.ts +70 -0
- package/dist/middleware/security_suite.d.ts +46 -0
- package/dist/middleware/session.d.ts +7 -0
- package/dist/model-binding/index.d.ts +17 -0
- package/dist/model-binding/model-middleware.d.ts +80 -0
- package/dist/model-binding/model-registry.d.ts +125 -0
- package/dist/model-binding.d.ts +123 -0
- package/dist/model-resolver-factory.d.ts +31 -0
- package/dist/observability/correlation.d.ts +131 -0
- package/dist/observability/health-checks.d.ts +129 -0
- package/dist/observability/index.d.ts +92 -0
- package/dist/observability/integration.d.ts +112 -0
- package/dist/observability/metrics.d.ts +135 -0
- package/dist/observability/tracing.d.ts +112 -0
- package/dist/optimization/bun-utilities.d.ts +106 -0
- package/dist/query-builder-integration.d.ts +24 -0
- package/dist/request/enhanced-request.d.ts +143 -0
- package/dist/request/macros.d.ts +267 -0
- package/dist/response/macros.d.ts +207 -0
- package/dist/response/response-factory.d.ts +93 -0
- package/dist/router/file-based-routing.d.ts +40 -0
- package/dist/router/file-streaming.d.ts +6 -0
- package/dist/router/fluent-router.d.ts +179 -0
- package/dist/router/fluent-routing.d.ts +198 -0
- package/dist/router/group-organization.d.ts +5 -0
- package/dist/router/handler-resolver.d.ts +13 -0
- package/dist/router/http-methods.d.ts +10 -0
- package/dist/router/index.d.ts +114 -0
- package/dist/router/middleware-integration.d.ts +86 -0
- package/dist/router/middleware.d.ts +5 -0
- package/dist/router/model-binding.d.ts +7 -0
- package/dist/router/optimized-route-matching.d.ts +6 -0
- package/dist/router/route-building.d.ts +5 -0
- package/dist/router/route-compiler.d.ts +67 -0
- package/dist/router/route-matching.d.ts +5 -0
- package/dist/router/route-trie.d.ts +69 -0
- package/dist/router/router.d.ts +133 -0
- package/dist/router/server.d.ts +5 -0
- package/dist/router/validation-integration.d.ts +116 -0
- package/dist/router/view-rendering.d.ts +5 -0
- package/dist/router/websocket.d.ts +5 -0
- package/dist/routing/route-caching.d.ts +105 -0
- package/dist/routing/route-throttling.d.ts +112 -0
- package/dist/routing/subdomain-routing.d.ts +159 -0
- package/dist/streaming/index.d.ts +15 -0
- package/dist/streaming/sse-handler.d.ts +81 -0
- package/dist/streaming/stream-handler.d.ts +81 -0
- package/dist/testing/auth-testing.d.ts +107 -0
- package/dist/testing/file-upload-testing.d.ts +139 -0
- package/dist/testing/index.d.ts +10 -0
- package/dist/testing/middleware-testing.d.ts +99 -0
- package/dist/testing/model-binding-testing.d.ts +132 -0
- package/dist/testing/performance-testing.d.ts +202 -0
- package/dist/testing/test-client.d.ts +58 -0
- package/dist/testing/test-request.d.ts +43 -0
- package/dist/testing/test-response.d.ts +45 -0
- package/dist/testing/types.d.ts +206 -0
- package/dist/testing/websocket-testing.d.ts +170 -0
- package/dist/types/controller-types.d.ts +303 -0
- package/dist/types/core.d.ts +526 -0
- package/dist/types/middleware-types.d.ts +315 -0
- package/dist/types/request-response-augmentation.d.ts +373 -0
- package/dist/types/route-inference.d.ts +287 -0
- package/dist/types.d.ts +1620 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/query-preservation.d.ts +31 -0
- package/dist/utils.d.ts +69 -0
- package/dist/validation/validator.d.ts +169 -0
- package/dist/websocket/clustering.d.ts +114 -0
- package/package.json +81 -0
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
import type { ServerWebSocket } from 'bun';
|
|
2
|
+
export type {
|
|
3
|
+
AuthContext as AuthContextType,
|
|
4
|
+
CookieOptions as CookieOptionsType,
|
|
5
|
+
MetricEntry as MetricEntryType,
|
|
6
|
+
OAuth2Flows as OAuth2FlowsType,
|
|
7
|
+
OAuth2Profile as OAuth2ProfileType,
|
|
8
|
+
SessionData as SessionDataType,
|
|
9
|
+
TraceAttributes as TraceAttributesType,
|
|
10
|
+
User as UserType,
|
|
11
|
+
ValidationSchema as ValidationSchemaType,
|
|
12
|
+
WebSocketData as WebSocketDataType,
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* OAuth2 Authorization Code Flow configuration
|
|
16
|
+
*/
|
|
17
|
+
export declare interface OAuth2AuthorizationCodeFlow {
|
|
18
|
+
authorizationUrl: string
|
|
19
|
+
tokenUrl: string
|
|
20
|
+
refreshUrl?: string
|
|
21
|
+
scopes: Record<string, string>
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* OAuth2 Implicit Flow configuration
|
|
25
|
+
*/
|
|
26
|
+
export declare interface OAuth2ImplicitFlow {
|
|
27
|
+
authorizationUrl: string
|
|
28
|
+
refreshUrl?: string
|
|
29
|
+
scopes: Record<string, string>
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* OAuth2 Client Credentials Flow configuration
|
|
33
|
+
*/
|
|
34
|
+
export declare interface OAuth2ClientCredentialsFlow {
|
|
35
|
+
tokenUrl: string
|
|
36
|
+
refreshUrl?: string
|
|
37
|
+
scopes: Record<string, string>
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* OAuth2 Password Flow configuration
|
|
41
|
+
*/
|
|
42
|
+
export declare interface OAuth2PasswordFlow {
|
|
43
|
+
tokenUrl: string
|
|
44
|
+
refreshUrl?: string
|
|
45
|
+
scopes: Record<string, string>
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* OAuth2 Flows configuration - replaces `flows?: any`
|
|
49
|
+
*/
|
|
50
|
+
export declare interface OAuth2Flows {
|
|
51
|
+
implicit?: OAuth2ImplicitFlow
|
|
52
|
+
password?: OAuth2PasswordFlow
|
|
53
|
+
clientCredentials?: OAuth2ClientCredentialsFlow
|
|
54
|
+
authorizationCode?: OAuth2AuthorizationCodeFlow
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* OAuth2 Profile from provider - replaces `profile: any`
|
|
58
|
+
*/
|
|
59
|
+
export declare interface OAuth2Profile {
|
|
60
|
+
id: string
|
|
61
|
+
provider: string
|
|
62
|
+
email?: string
|
|
63
|
+
emailVerified?: boolean
|
|
64
|
+
name?: string
|
|
65
|
+
firstName?: string
|
|
66
|
+
lastName?: string
|
|
67
|
+
displayName?: string
|
|
68
|
+
username?: string
|
|
69
|
+
avatar?: string
|
|
70
|
+
profileUrl?: string
|
|
71
|
+
locale?: string
|
|
72
|
+
timezone?: string
|
|
73
|
+
raw?: Record<string, unknown>
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Session data interface - replaces `session?: any`
|
|
77
|
+
*/
|
|
78
|
+
export declare interface SessionData {
|
|
79
|
+
id?: string
|
|
80
|
+
userId?: string
|
|
81
|
+
createdAt?: number
|
|
82
|
+
expiresAt?: number
|
|
83
|
+
data?: Record<string, unknown>
|
|
84
|
+
flash?: Record<string, unknown>
|
|
85
|
+
csrfToken?: string
|
|
86
|
+
regenerate?: () => Promise<void>
|
|
87
|
+
destroy?: () => Promise<void>
|
|
88
|
+
save?: () => Promise<void>
|
|
89
|
+
touch?: () => Promise<void>
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Session serializer interface - replaces serializer with `any`
|
|
93
|
+
*/
|
|
94
|
+
export declare interface SessionSerializer<T = SessionData> {
|
|
95
|
+
stringify: (data: T) => string
|
|
96
|
+
parse: (data: string) => T
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Session store interface - replaces custom store with `any`
|
|
100
|
+
*/
|
|
101
|
+
export declare interface SessionStore<T = SessionData> {
|
|
102
|
+
get: (sid: string) => Promise<T | null>
|
|
103
|
+
set: (sid: string, session: T, ttl?: number) => Promise<void>
|
|
104
|
+
destroy: (sid: string) => Promise<void>
|
|
105
|
+
touch?: (sid: string, session: T, ttl?: number) => Promise<void>
|
|
106
|
+
all?: () => Promise<Record<string, T>>
|
|
107
|
+
length?: () => Promise<number>
|
|
108
|
+
clear?: () => Promise<void>
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Base user interface - replaces `user?: any`
|
|
112
|
+
*/
|
|
113
|
+
export declare interface User {
|
|
114
|
+
id: string | number
|
|
115
|
+
email?: string
|
|
116
|
+
name?: string
|
|
117
|
+
username?: string
|
|
118
|
+
roles?: string[]
|
|
119
|
+
permissions?: string[]
|
|
120
|
+
emailVerifiedAt?: Date | null
|
|
121
|
+
createdAt?: Date
|
|
122
|
+
updatedAt?: Date
|
|
123
|
+
metadata?: Record<string, unknown>
|
|
124
|
+
plan?: string
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Authenticated user with additional auth context
|
|
128
|
+
*/
|
|
129
|
+
export declare interface AuthenticatedUser extends User {
|
|
130
|
+
tokenType?: 'jwt' | 'session' | 'apikey' | 'bearer'
|
|
131
|
+
tokenExpiry?: number
|
|
132
|
+
scopes?: string[]
|
|
133
|
+
isAdmin?: boolean
|
|
134
|
+
isSuperAdmin?: boolean
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Auth context - replaces `auth?: any`
|
|
138
|
+
*/
|
|
139
|
+
export declare interface AuthContext<TUser extends User = User> {
|
|
140
|
+
user: TUser | null
|
|
141
|
+
isAuthenticated: boolean
|
|
142
|
+
check: () => boolean
|
|
143
|
+
guest: () => boolean
|
|
144
|
+
id: () => string | number | null
|
|
145
|
+
validate: (credentials: { email: string, password: string }) => Promise<TUser | null>
|
|
146
|
+
attempt: (credentials: { email: string, password: string }, remember?: boolean) => Promise<boolean>
|
|
147
|
+
login: (user: TUser, remember?: boolean) => Promise<void>
|
|
148
|
+
logout: () => Promise<void>
|
|
149
|
+
hasRole: (role: string | string[]) => boolean
|
|
150
|
+
hasPermission: (permission: string | string[]) => boolean
|
|
151
|
+
can: (ability: string, resource?: unknown) => boolean
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Metric entry interface - replaces `metrics: any[]`
|
|
155
|
+
*/
|
|
156
|
+
export declare interface MetricEntry {
|
|
157
|
+
name: string
|
|
158
|
+
value: number
|
|
159
|
+
timestamp: number
|
|
160
|
+
type: 'counter' | 'gauge' | 'histogram' | 'summary'
|
|
161
|
+
tags?: Record<string, string>
|
|
162
|
+
unit?: string
|
|
163
|
+
description?: string
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Performance metric
|
|
167
|
+
*/
|
|
168
|
+
export declare interface PerformanceMetric extends MetricEntry {
|
|
169
|
+
type: 'histogram'
|
|
170
|
+
percentiles?: {
|
|
171
|
+
p50: number
|
|
172
|
+
p75: number
|
|
173
|
+
p90: number
|
|
174
|
+
p95: number
|
|
175
|
+
p99: number
|
|
176
|
+
}
|
|
177
|
+
min?: number
|
|
178
|
+
max?: number
|
|
179
|
+
avg?: number
|
|
180
|
+
count?: number
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Trace span attributes - replaces `attributes: Record<string, any>`
|
|
184
|
+
*/
|
|
185
|
+
export declare interface TraceAttributes {
|
|
186
|
+
'http.method'?: string
|
|
187
|
+
'http.url'?: string
|
|
188
|
+
'http.status_code'?: number
|
|
189
|
+
'http.route'?: string
|
|
190
|
+
'http.user_agent'?: string
|
|
191
|
+
'http.request_content_length'?: number
|
|
192
|
+
'http.response_content_length'?: number
|
|
193
|
+
'net.peer.ip'?: string
|
|
194
|
+
'net.peer.port'?: number
|
|
195
|
+
'db.system'?: string
|
|
196
|
+
'db.statement'?: string
|
|
197
|
+
'db.operation'?: string
|
|
198
|
+
'error'?: boolean
|
|
199
|
+
'error.message'?: string
|
|
200
|
+
'error.stack'?: string
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Trace span interface
|
|
204
|
+
*/
|
|
205
|
+
export declare interface TraceSpan {
|
|
206
|
+
name: string
|
|
207
|
+
traceId: string
|
|
208
|
+
spanId: string
|
|
209
|
+
parentSpanId?: string
|
|
210
|
+
startTime: number
|
|
211
|
+
endTime?: number
|
|
212
|
+
duration?: number
|
|
213
|
+
status: 'OK' | 'ERROR' | 'UNSET'
|
|
214
|
+
attributes: TraceAttributes
|
|
215
|
+
events?: TraceEvent[]
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Trace event
|
|
219
|
+
*/
|
|
220
|
+
export declare interface TraceEvent {
|
|
221
|
+
name: string
|
|
222
|
+
timestamp: number
|
|
223
|
+
attributes?: TraceAttributes
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* WebSocket data interface - replaces `ServerWebSocket<any>`
|
|
227
|
+
*/
|
|
228
|
+
export declare interface WebSocketData {
|
|
229
|
+
id: string
|
|
230
|
+
userId?: string | number
|
|
231
|
+
channels?: Set<string>
|
|
232
|
+
metadata?: Record<string, unknown>
|
|
233
|
+
connectedAt: number
|
|
234
|
+
lastPingAt?: number
|
|
235
|
+
ip?: string
|
|
236
|
+
userAgent?: string
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Validation schema - replaces `schemas?: Record<string, any>`
|
|
240
|
+
*/
|
|
241
|
+
export declare interface ValidationSchema {
|
|
242
|
+
type?: 'string' | 'number' | 'boolean' | 'array' | 'object' | 'date' | 'email' | 'url' | 'uuid'
|
|
243
|
+
required?: boolean
|
|
244
|
+
nullable?: boolean
|
|
245
|
+
default?: unknown
|
|
246
|
+
rules?: ValidationRule[]
|
|
247
|
+
message?: string
|
|
248
|
+
transform?: (value: unknown) => unknown
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Validation rule
|
|
252
|
+
*/
|
|
253
|
+
export declare interface ValidationRule {
|
|
254
|
+
name: string
|
|
255
|
+
params?: unknown[]
|
|
256
|
+
message?: string
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Input validation schemas
|
|
260
|
+
*/
|
|
261
|
+
export declare interface InputValidationSchemas {
|
|
262
|
+
query?: ValidationSchema
|
|
263
|
+
body?: ValidationSchema
|
|
264
|
+
headers?: ValidationSchema
|
|
265
|
+
params?: ValidationSchema
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Sanitization options - replaces `options?: any`
|
|
269
|
+
*/
|
|
270
|
+
export declare interface SanitizationOptions {
|
|
271
|
+
trim?: boolean
|
|
272
|
+
lowercase?: boolean
|
|
273
|
+
uppercase?: boolean
|
|
274
|
+
escape?: boolean
|
|
275
|
+
stripTags?: boolean
|
|
276
|
+
normalizeEmail?: boolean
|
|
277
|
+
toInt?: boolean
|
|
278
|
+
toFloat?: boolean
|
|
279
|
+
toBoolean?: boolean
|
|
280
|
+
toDate?: boolean
|
|
281
|
+
customSanitizer?: (value: unknown) => unknown
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Sanitization rule configuration
|
|
285
|
+
*/
|
|
286
|
+
export declare interface SanitizationRule {
|
|
287
|
+
type: 'escape' | 'strip' | 'validate' | 'transform'
|
|
288
|
+
options: SanitizationOptions
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Cookie options interface
|
|
292
|
+
*/
|
|
293
|
+
export declare interface CookieOptions {
|
|
294
|
+
maxAge?: number
|
|
295
|
+
expires?: Date
|
|
296
|
+
httpOnly?: boolean
|
|
297
|
+
secure?: boolean
|
|
298
|
+
path?: string
|
|
299
|
+
domain?: string
|
|
300
|
+
sameSite?: 'strict' | 'lax' | 'none'
|
|
301
|
+
priority?: 'low' | 'medium' | 'high'
|
|
302
|
+
partitioned?: boolean
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Cookie to set - replaces `{ name: string, value: string, options: any }`
|
|
306
|
+
*/
|
|
307
|
+
export declare interface CookieToSet {
|
|
308
|
+
name: string
|
|
309
|
+
value: string
|
|
310
|
+
options: CookieOptions
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Cookie to delete - replaces `{ name: string, options: any }`
|
|
314
|
+
*/
|
|
315
|
+
export declare interface CookieToDelete {
|
|
316
|
+
name: string
|
|
317
|
+
options: Pick<CookieOptions, 'path' | 'domain'>
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* SSE connection info - replaces `sse?: { id: string, eventSource?: any }`
|
|
321
|
+
*/
|
|
322
|
+
export declare interface SSEConnection {
|
|
323
|
+
id: string
|
|
324
|
+
controller?: ReadableStreamDefaultController<Uint8Array>
|
|
325
|
+
eventSource?: unknown
|
|
326
|
+
lastEventId?: string
|
|
327
|
+
retryInterval?: number
|
|
328
|
+
connectedAt?: number
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Logger interface for middleware
|
|
332
|
+
*/
|
|
333
|
+
export declare interface Logger {
|
|
334
|
+
log: (message: string, ...args: unknown[]) => void
|
|
335
|
+
info: (message: string, ...args: unknown[]) => void
|
|
336
|
+
warn: (message: string, ...args: unknown[]) => void
|
|
337
|
+
error: (message: string, ...args: unknown[]) => void
|
|
338
|
+
debug: (message: string, ...args: unknown[]) => void
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Simple cache interface for middleware
|
|
342
|
+
*/
|
|
343
|
+
export declare interface SimpleCache {
|
|
344
|
+
get: <T = unknown>(key: string) => T | undefined
|
|
345
|
+
set: <T = unknown>(key: string, value: T, ttl?: number) => void
|
|
346
|
+
delete: (key: string) => boolean
|
|
347
|
+
has: (key: string) => boolean
|
|
348
|
+
clear: () => void
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Request context - replaces `context?: Record<string, any>`
|
|
352
|
+
*/
|
|
353
|
+
export declare interface RequestContext {
|
|
354
|
+
startTime?: number
|
|
355
|
+
requestId?: string
|
|
356
|
+
traceId?: string
|
|
357
|
+
spanId?: string
|
|
358
|
+
route?: string
|
|
359
|
+
routeName?: string
|
|
360
|
+
locale?: string
|
|
361
|
+
timezone?: string
|
|
362
|
+
logger?: Logger
|
|
363
|
+
cache?: SimpleCache
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Flash messages - replaces `flash?: Record<string, any>`
|
|
367
|
+
*/
|
|
368
|
+
export declare interface FlashMessages {
|
|
369
|
+
success?: string | string[]
|
|
370
|
+
error?: string | string[]
|
|
371
|
+
warning?: string | string[]
|
|
372
|
+
info?: string | string[]
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Form body - replaces `formBody?: Record<string, any>`
|
|
376
|
+
*/
|
|
377
|
+
export declare interface FormBody {
|
|
378
|
+
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Cache adapter interface - replaces custom adapter with `any`
|
|
382
|
+
*/
|
|
383
|
+
export declare interface CacheAdapter<T = unknown> {
|
|
384
|
+
get: (key: string) => Promise<T | null>
|
|
385
|
+
set: (key: string, value: T, ttl?: number) => Promise<void>
|
|
386
|
+
del: (key: string) => Promise<void>
|
|
387
|
+
clear?: () => Promise<void>
|
|
388
|
+
has?: (key: string) => Promise<boolean>
|
|
389
|
+
stats?: () => Promise<CacheStats>
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Cache statistics
|
|
393
|
+
*/
|
|
394
|
+
export declare interface CacheStats {
|
|
395
|
+
hits: number
|
|
396
|
+
misses: number
|
|
397
|
+
keys: number
|
|
398
|
+
size?: number
|
|
399
|
+
hitRate?: number
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* JWT Header - replaces `header?: Record<string, any>`
|
|
403
|
+
*/
|
|
404
|
+
export declare interface JwtHeader {
|
|
405
|
+
alg: 'HS256' | 'HS384' | 'HS512' | 'RS256' | 'RS384' | 'RS512' | 'ES256' | 'ES384' | 'ES512' | 'PS256' | 'PS384' | 'PS512' | 'none'
|
|
406
|
+
typ: 'JWT'
|
|
407
|
+
kid?: string
|
|
408
|
+
x5u?: string
|
|
409
|
+
x5c?: string[]
|
|
410
|
+
x5t?: string
|
|
411
|
+
cty?: string
|
|
412
|
+
crit?: string[]
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* JWT Payload - replaces index signature with `any`
|
|
416
|
+
*/
|
|
417
|
+
export declare interface JwtPayload {
|
|
418
|
+
iss?: string
|
|
419
|
+
sub?: string
|
|
420
|
+
aud?: string | string[]
|
|
421
|
+
exp?: number
|
|
422
|
+
nbf?: number
|
|
423
|
+
iat?: number
|
|
424
|
+
jti?: string
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Route metadata - replaces `meta?: Record<string, any>`
|
|
428
|
+
*/
|
|
429
|
+
export declare interface RouteMetadata {
|
|
430
|
+
description?: string
|
|
431
|
+
summary?: string
|
|
432
|
+
tags?: string[]
|
|
433
|
+
deprecated?: boolean
|
|
434
|
+
version?: string
|
|
435
|
+
permissions?: string[]
|
|
436
|
+
roles?: string[]
|
|
437
|
+
rateLimit?: string
|
|
438
|
+
cache?: {
|
|
439
|
+
enabled: boolean
|
|
440
|
+
ttl: number
|
|
441
|
+
tags?: string[]
|
|
442
|
+
}
|
|
443
|
+
openapi?: {
|
|
444
|
+
operationId?: string
|
|
445
|
+
requestBody?: unknown
|
|
446
|
+
responses?: Record<string, unknown>
|
|
447
|
+
parameters?: unknown[]
|
|
448
|
+
security?: unknown[]
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Error metadata - replaces `metadata?: Record<string, any>`
|
|
453
|
+
*/
|
|
454
|
+
export declare interface ErrorMetadata {
|
|
455
|
+
code?: string
|
|
456
|
+
field?: string
|
|
457
|
+
value?: unknown
|
|
458
|
+
constraint?: string
|
|
459
|
+
expected?: unknown
|
|
460
|
+
received?: unknown
|
|
461
|
+
path?: string[]
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Middleware params - replaces `params?: Record<string, any>`
|
|
465
|
+
*/
|
|
466
|
+
export declare interface MiddlewareParams {
|
|
467
|
+
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* File info - replaces `file: (name: string) => any`
|
|
471
|
+
*/
|
|
472
|
+
export declare interface FileInfo {
|
|
473
|
+
fieldName: string
|
|
474
|
+
originalName: string
|
|
475
|
+
filename: string
|
|
476
|
+
path: string
|
|
477
|
+
size: number
|
|
478
|
+
mimetype: string
|
|
479
|
+
buffer: ArrayBuffer
|
|
480
|
+
encoding?: string
|
|
481
|
+
hash?: string
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Typed ServerWebSocket
|
|
485
|
+
*/
|
|
486
|
+
export type TypedServerWebSocket<T extends WebSocketData = WebSocketData> = ServerWebSocket<T>
|
|
487
|
+
/**
|
|
488
|
+
* Template helper function signature - replaces `(...args: any[]) => any`
|
|
489
|
+
*/
|
|
490
|
+
export type TemplateHelper = (...args: unknown[]) => string | number | boolean | null | undefined
|
|
491
|
+
/**
|
|
492
|
+
* Template helpers map
|
|
493
|
+
*/
|
|
494
|
+
export type TemplateHelpers = Record<string, TemplateHelper>
|
|
495
|
+
/**
|
|
496
|
+
* Validated data - replaces `validated?: Record<string, any>`
|
|
497
|
+
*/
|
|
498
|
+
export type ValidatedData<T = Record<string, unknown>> = T
|
|
499
|
+
/**
|
|
500
|
+
* Bound models - replaces `models?: Record<string, any>`
|
|
501
|
+
*/
|
|
502
|
+
export type BoundModels<T extends Record<string, unknown> = Record<string, unknown>> = T
|
|
503
|
+
/**
|
|
504
|
+
* JSON body data type - replaces `jsonBody?: any`
|
|
505
|
+
*/
|
|
506
|
+
export type JsonBodyData<T = unknown> = T
|
|
507
|
+
/**
|
|
508
|
+
* Validated body - replaces `validatedBody?: any`
|
|
509
|
+
*/
|
|
510
|
+
export type ValidatedBody<T = unknown> = T
|
|
511
|
+
/**
|
|
512
|
+
* Static response body - replaces `body: any`
|
|
513
|
+
*/
|
|
514
|
+
export type StaticResponseBody = string | Record<string, unknown> | unknown[]
|
|
515
|
+
/**
|
|
516
|
+
* Fallback handler error - replaces `error: any`
|
|
517
|
+
*/
|
|
518
|
+
export type FallbackError = Error | { message: string, code?: string, status?: number }
|
|
519
|
+
/**
|
|
520
|
+
* Input value - replaces various `any` in input handling
|
|
521
|
+
*/
|
|
522
|
+
export type InputValue = string | number | boolean | null | undefined | InputValue[] | { [key: string]: InputValue }
|
|
523
|
+
/**
|
|
524
|
+
* Request input - replaces `all(): Record<string, any>`
|
|
525
|
+
*/
|
|
526
|
+
export type RequestInput = Record<string, InputValue>
|