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