@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.
- package/dist/{chunk-r15a48wc.js → chunk-cjdekj87.js} +536 -98
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.js +454 -119
- package/package.json +6 -8
- package/dist/auth.d.ts +0 -77
- package/dist/cache/lru-cache.d.ts +0 -88
- package/dist/cache/middleware-memoization.d.ts +0 -101
- package/dist/cache/route-cache-warmer.d.ts +0 -125
- package/dist/cache/sqlite-cache.d.ts +0 -114
- package/dist/cache/streaming-cache.d.ts +0 -86
- package/dist/cli/colors.d.ts +0 -12
- package/dist/cli/index.d.ts +0 -10
- package/dist/cli/middleware.d.ts +0 -31
- package/dist/cli/openapi.d.ts +0 -17
- package/dist/cli/router.d.ts +0 -15
- package/dist/cli/routes.d.ts +0 -30
- package/dist/cli/utils.d.ts +0 -68
- package/dist/config.d.ts +0 -274
- package/dist/container/container.d.ts +0 -141
- package/dist/container/contextual-binding.d.ts +0 -112
- package/dist/container/decorators.d.ts +0 -114
- package/dist/container/service-provider.d.ts +0 -221
- package/dist/development/hot-reload.d.ts +0 -129
- package/dist/development/index.d.ts +0 -144
- package/dist/development/performance-profiler.d.ts +0 -152
- package/dist/development/route-debugger.d.ts +0 -102
- package/dist/development/route-inspector.d.ts +0 -142
- package/dist/development/typescript-utilities.d.ts +0 -116
- package/dist/docs.d.ts +0 -10
- package/dist/errors/circuit-breaker.d.ts +0 -138
- package/dist/errors/error-handler.d.ts +0 -57
- package/dist/errors/error-reporting.d.ts +0 -135
- package/dist/errors/exceptions.d.ts +0 -178
- package/dist/errors/graceful-degradation.d.ts +0 -130
- package/dist/errors/index.d.ts +0 -6
- package/dist/errors/router-errors.d.ts +0 -97
- package/dist/file-serving/static-files.d.ts +0 -98
- package/dist/middleware/auth.d.ts +0 -34
- package/dist/middleware/content_security_policy.d.ts +0 -54
- package/dist/middleware/cors.d.ts +0 -5
- package/dist/middleware/csrf.d.ts +0 -7
- package/dist/middleware/ddos_protection.d.ts +0 -47
- package/dist/middleware/file_security.d.ts +0 -23
- package/dist/middleware/file_upload.d.ts +0 -41
- package/dist/middleware/helmet.d.ts +0 -54
- package/dist/middleware/index.d.ts +0 -55
- package/dist/middleware/input_validation.d.ts +0 -46
- package/dist/middleware/json_body.d.ts +0 -4
- package/dist/middleware/performance_alerting.d.ts +0 -88
- package/dist/middleware/performance_dashboard.d.ts +0 -97
- package/dist/middleware/performance_monitor.d.ts +0 -236
- package/dist/middleware/pipeline.d.ts +0 -90
- package/dist/middleware/rate_limit.d.ts +0 -33
- package/dist/middleware/request_id.d.ts +0 -4
- package/dist/middleware/request_signing.d.ts +0 -96
- package/dist/middleware/request_tracer.d.ts +0 -76
- package/dist/middleware/response_cache.d.ts +0 -90
- package/dist/middleware/security.d.ts +0 -70
- package/dist/middleware/security_suite.d.ts +0 -46
- package/dist/middleware/session.d.ts +0 -7
- package/dist/model-binding/index.d.ts +0 -17
- package/dist/model-binding/model-middleware.d.ts +0 -80
- package/dist/model-binding/model-registry.d.ts +0 -125
- package/dist/model-binding.d.ts +0 -123
- package/dist/model-resolver-factory.d.ts +0 -31
- package/dist/observability/correlation.d.ts +0 -131
- package/dist/observability/health-checks.d.ts +0 -129
- package/dist/observability/index.d.ts +0 -92
- package/dist/observability/integration.d.ts +0 -112
- package/dist/observability/metrics.d.ts +0 -135
- package/dist/observability/tracing.d.ts +0 -112
- package/dist/optimization/bun-utilities.d.ts +0 -106
- package/dist/query-builder-integration.d.ts +0 -24
- package/dist/request/enhanced-request.d.ts +0 -143
- package/dist/request/macros.d.ts +0 -267
- package/dist/response/macros.d.ts +0 -207
- package/dist/response/response-factory.d.ts +0 -93
- package/dist/router/file-based-routing.d.ts +0 -40
- package/dist/router/file-streaming.d.ts +0 -6
- package/dist/router/fluent-router.d.ts +0 -179
- package/dist/router/fluent-routing.d.ts +0 -198
- package/dist/router/group-organization.d.ts +0 -5
- package/dist/router/handler-resolver.d.ts +0 -13
- package/dist/router/http-methods.d.ts +0 -10
- package/dist/router/index.d.ts +0 -114
- package/dist/router/middleware-integration.d.ts +0 -86
- package/dist/router/middleware.d.ts +0 -5
- package/dist/router/model-binding.d.ts +0 -7
- package/dist/router/optimized-route-matching.d.ts +0 -6
- package/dist/router/route-building.d.ts +0 -5
- package/dist/router/route-compiler.d.ts +0 -67
- package/dist/router/route-matching.d.ts +0 -5
- package/dist/router/route-trie.d.ts +0 -69
- package/dist/router/router.d.ts +0 -133
- package/dist/router/server.d.ts +0 -5
- package/dist/router/validation-integration.d.ts +0 -116
- package/dist/router/view-rendering.d.ts +0 -5
- package/dist/router/websocket.d.ts +0 -5
- package/dist/routing/route-caching.d.ts +0 -105
- package/dist/routing/route-throttling.d.ts +0 -112
- package/dist/routing/subdomain-routing.d.ts +0 -159
- package/dist/streaming/index.d.ts +0 -15
- package/dist/streaming/sse-handler.d.ts +0 -81
- package/dist/streaming/stream-handler.d.ts +0 -81
- package/dist/testing/auth-testing.d.ts +0 -107
- package/dist/testing/file-upload-testing.d.ts +0 -139
- package/dist/testing/index.d.ts +0 -10
- package/dist/testing/middleware-testing.d.ts +0 -99
- package/dist/testing/model-binding-testing.d.ts +0 -132
- package/dist/testing/performance-testing.d.ts +0 -202
- package/dist/testing/test-client.d.ts +0 -58
- package/dist/testing/test-request.d.ts +0 -43
- package/dist/testing/test-response.d.ts +0 -45
- package/dist/testing/types.d.ts +0 -206
- package/dist/testing/websocket-testing.d.ts +0 -170
- package/dist/types/controller-types.d.ts +0 -303
- package/dist/types/core.d.ts +0 -526
- package/dist/types/middleware-types.d.ts +0 -315
- package/dist/types/request-response-augmentation.d.ts +0 -373
- package/dist/types/route-inference.d.ts +0 -287
- package/dist/types.d.ts +0 -1620
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/query-preservation.d.ts +0 -31
- package/dist/utils.d.ts +0 -69
- package/dist/validation/validator.d.ts +0 -169
- package/dist/websocket/clustering.d.ts +0 -114
package/dist/cli/openapi.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generate OpenAPI specification for API routes
|
|
3
|
-
*/
|
|
4
|
-
export declare function generateOpenAPISpec(options: OpenAPIOptions): Promise<void>;
|
|
5
|
-
/**
|
|
6
|
-
* Options for the openapi command
|
|
7
|
-
*/
|
|
8
|
-
export declare interface OpenAPIOptions {
|
|
9
|
-
output?: string
|
|
10
|
-
title?: string
|
|
11
|
-
version?: string
|
|
12
|
-
description?: string
|
|
13
|
-
basePath?: string
|
|
14
|
-
servers?: string
|
|
15
|
-
tags?: boolean
|
|
16
|
-
security?: boolean
|
|
17
|
-
}
|
package/dist/cli/router.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generate TypeScript types for router extensions
|
|
3
|
-
*/
|
|
4
|
-
export declare function generateRouterTypes(outputPath: string): Promise<void>;
|
|
5
|
-
/**
|
|
6
|
-
* Watch for changes in router files and regenerate types
|
|
7
|
-
*/
|
|
8
|
-
export declare function watchRouterFiles(outputPath: string): Promise<void>;
|
|
9
|
-
/**
|
|
10
|
-
* Options for the router:types command
|
|
11
|
-
*/
|
|
12
|
-
export declare interface GenerateRouterTypesOptions {
|
|
13
|
-
output?: string
|
|
14
|
-
watch?: boolean
|
|
15
|
-
}
|
package/dist/cli/routes.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
/**
|
|
3
|
-
* Display all registered routes in a formatted table
|
|
4
|
-
*/
|
|
5
|
-
export declare function displayRoutes(options: RouteListOptions): Promise<void>;
|
|
6
|
-
/**
|
|
7
|
-
* Generate TypeScript types for route names
|
|
8
|
-
*/
|
|
9
|
-
export declare function generateRouteTypes(outputPath: string): Promise<void>;
|
|
10
|
-
/**
|
|
11
|
-
* Watch for changes in the routes directory and regenerate types
|
|
12
|
-
*/
|
|
13
|
-
export declare function watchRoutesDirectory(outputPath: string): Promise<void>;
|
|
14
|
-
/**
|
|
15
|
-
* Options for the route:list command
|
|
16
|
-
*/
|
|
17
|
-
export declare interface RouteListOptions {
|
|
18
|
-
verbose?: boolean
|
|
19
|
-
extraVerbose?: boolean
|
|
20
|
-
path?: string
|
|
21
|
-
exceptVendor?: boolean
|
|
22
|
-
onlyVendor?: boolean
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Options for the route:types command
|
|
26
|
-
*/
|
|
27
|
-
export declare interface GenerateRouteTypesOptions {
|
|
28
|
-
output?: string
|
|
29
|
-
watch?: boolean
|
|
30
|
-
}
|
package/dist/cli/utils.d.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Load router instance from the application
|
|
3
|
-
*/
|
|
4
|
-
export declare function loadRouter(): Promise<any>;
|
|
5
|
-
/**
|
|
6
|
-
* Setup a debounced file watcher
|
|
7
|
-
*/
|
|
8
|
-
export declare function setupDebouncedWatcher(callback: () => Promise<void>, _debounceTime?: any): { timeoutId: NodeJS.Timeout | null };
|
|
9
|
-
/**
|
|
10
|
-
* Utility to get method color for console output
|
|
11
|
-
*/
|
|
12
|
-
export declare function getMethodColor(method: string): string;
|
|
13
|
-
/**
|
|
14
|
-
* Pad a string to a specified length
|
|
15
|
-
*/
|
|
16
|
-
export declare function padString(str: string, length: number): string;
|
|
17
|
-
/**
|
|
18
|
-
* Check router health and configuration
|
|
19
|
-
*/
|
|
20
|
-
export declare function checkRouterHealth(options: { verbose?: boolean }): Promise<void>;
|
|
21
|
-
/**
|
|
22
|
-
* Test routes by making HTTP requests
|
|
23
|
-
*/
|
|
24
|
-
export declare function testRoutes(options: {
|
|
25
|
-
baseUrl?: string
|
|
26
|
-
filter?: string
|
|
27
|
-
method?: string
|
|
28
|
-
timeout?: number
|
|
29
|
-
}): Promise<void>;
|
|
30
|
-
/**
|
|
31
|
-
* Debug route matching for a specific path
|
|
32
|
-
*/
|
|
33
|
-
export declare function debugRoute(path: string, options: {
|
|
34
|
-
method?: string
|
|
35
|
-
verbose?: boolean
|
|
36
|
-
}): Promise<void>;
|
|
37
|
-
/**
|
|
38
|
-
* Clear route caches
|
|
39
|
-
*/
|
|
40
|
-
export declare function clearCaches(options: { stats?: boolean }): Promise<void>;
|
|
41
|
-
/**
|
|
42
|
-
* Validate route definitions and configuration
|
|
43
|
-
*/
|
|
44
|
-
export declare function validateRoutes(options: {
|
|
45
|
-
strict?: boolean
|
|
46
|
-
fix?: boolean
|
|
47
|
-
}): Promise<void>;
|
|
48
|
-
/**
|
|
49
|
-
* Formats console output with consistent styling
|
|
50
|
-
*/
|
|
51
|
-
export declare const format: {
|
|
52
|
-
success: (message: string) => any;
|
|
53
|
-
info: (message: string) => any;
|
|
54
|
-
warning: (message: string) => any;
|
|
55
|
-
error: (message: string) => any;
|
|
56
|
-
dim: (message: string) => any;
|
|
57
|
-
bold: (message: string) => any
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* Logger for CLI commands with consistent styling
|
|
61
|
-
*/
|
|
62
|
-
export declare const logger: {
|
|
63
|
-
success: (message: string) => any;
|
|
64
|
-
info: (message: string) => any;
|
|
65
|
-
warning: (message: string) => any;
|
|
66
|
-
error: (message: string) => any;
|
|
67
|
-
debug: (message: string) => any
|
|
68
|
-
};
|
package/dist/config.d.ts
DELETED
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
import type { RouterConfig } from './types';
|
|
2
|
-
export declare function getConfig(): Promise<RouterConfig>;
|
|
3
|
-
/**
|
|
4
|
-
* Default configuration for the router
|
|
5
|
-
*/
|
|
6
|
-
export declare const defaultConfig: {
|
|
7
|
-
// General settings
|
|
8
|
-
verbose: false;
|
|
9
|
-
// Route paths
|
|
10
|
-
routesPath: 'routes';
|
|
11
|
-
apiRoutesPath: 'routes/api.ts';
|
|
12
|
-
webRoutesPath: 'routes/web.ts';
|
|
13
|
-
// URL prefixes
|
|
14
|
-
apiPrefix: '/api';
|
|
15
|
-
webPrefix: '';
|
|
16
|
-
// Default middleware configuration
|
|
17
|
-
defaultMiddleware: {
|
|
18
|
-
api: readonly ['security', 'helmet', 'cors', 'rate_limit', 'json_body', 'request_id'];
|
|
19
|
-
web: readonly ['security', 'helmet', 'ddos_protection', 'session', 'csrf']
|
|
20
|
-
};
|
|
21
|
-
// Documentation settings
|
|
22
|
-
docs: {
|
|
23
|
-
output: 'api-reference.md';
|
|
24
|
-
groupBy: 'path';
|
|
25
|
-
includeExamples: true;
|
|
26
|
-
title: 'API Reference';
|
|
27
|
-
description: 'API documentation for the application.';
|
|
28
|
-
version: '1.0.0';
|
|
29
|
-
baseUrl: 'http://localhost:3000';
|
|
30
|
-
contact: {
|
|
31
|
-
name: 'API Support';
|
|
32
|
-
email: 'support@example.com';
|
|
33
|
-
url: 'https://example.com/support'
|
|
34
|
-
};
|
|
35
|
-
security: {
|
|
36
|
-
bearer: {
|
|
37
|
-
type: 'http';
|
|
38
|
-
scheme: 'bearer';
|
|
39
|
-
bearerFormat: 'JWT'
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
// Server settings
|
|
44
|
-
server: {
|
|
45
|
-
port: 3000;
|
|
46
|
-
hostname: 'localhost';
|
|
47
|
-
development: unknown;
|
|
48
|
-
cors: {
|
|
49
|
-
enabled: true;
|
|
50
|
-
origin: '*';
|
|
51
|
-
methods: readonly ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'];
|
|
52
|
-
allowedHeaders: readonly ['Content-Type', 'Authorization'];
|
|
53
|
-
exposedHeaders: readonly ['X-Request-Id'];
|
|
54
|
-
credentials: false;
|
|
55
|
-
maxAge: 86400
|
|
56
|
-
};
|
|
57
|
-
rateLimit: {
|
|
58
|
-
enabled: true;
|
|
59
|
-
max: 100;
|
|
60
|
-
timeWindow: 60000;
|
|
61
|
-
// 1 minute
|
|
62
|
-
message: 'Too many requests, please try again later'
|
|
63
|
-
};
|
|
64
|
-
compression: {
|
|
65
|
-
enabled: true;
|
|
66
|
-
level: 6;
|
|
67
|
-
threshold: 1024
|
|
68
|
-
};
|
|
69
|
-
static: {
|
|
70
|
-
enabled: true;
|
|
71
|
-
dir: 'public';
|
|
72
|
-
maxAge: 86400
|
|
73
|
-
};
|
|
74
|
-
performance: {
|
|
75
|
-
cache: {
|
|
76
|
-
enabled: false;
|
|
77
|
-
type: 'memory';
|
|
78
|
-
ttl: 3600
|
|
79
|
-
};
|
|
80
|
-
prefetch: {
|
|
81
|
-
enabled: false;
|
|
82
|
-
paths: Array<never>;
|
|
83
|
-
maxConcurrent: 5
|
|
84
|
-
};
|
|
85
|
-
optimization: {
|
|
86
|
-
minify: false;
|
|
87
|
-
compress: false;
|
|
88
|
-
treeshake: false;
|
|
89
|
-
lazyLoad: false;
|
|
90
|
-
chunkSize: 50000
|
|
91
|
-
};
|
|
92
|
-
monitoring: {
|
|
93
|
-
enabled: false;
|
|
94
|
-
metrics: {
|
|
95
|
-
responseTime: true;
|
|
96
|
-
memoryUsage: true;
|
|
97
|
-
cpuUsage: true;
|
|
98
|
-
errorRate: true;
|
|
99
|
-
requestRate: true;
|
|
100
|
-
cacheStats: true
|
|
101
|
-
};
|
|
102
|
-
tracing: {
|
|
103
|
-
enabled: false;
|
|
104
|
-
sampleRate: 0.1;
|
|
105
|
-
// @ts-expect-error - Extended tracing config supports exporters array
|
|
106
|
-
exporters: readonly ['console'];
|
|
107
|
-
propagation: readonly ['w3c']
|
|
108
|
-
};
|
|
109
|
-
logging: {
|
|
110
|
-
level: 'info';
|
|
111
|
-
format: 'json';
|
|
112
|
-
destination: 'console'
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
security: {
|
|
117
|
-
schemes: {};
|
|
118
|
-
rateLimit: {
|
|
119
|
-
enabled: true;
|
|
120
|
-
max: 100;
|
|
121
|
-
timeWindow: 60000
|
|
122
|
-
};
|
|
123
|
-
cors: {
|
|
124
|
-
enabled: true;
|
|
125
|
-
origin: '*';
|
|
126
|
-
methods: readonly ['GET', 'POST', 'PUT', 'DELETE', 'PATCH']
|
|
127
|
-
};
|
|
128
|
-
csrf: {
|
|
129
|
-
enabled: true;
|
|
130
|
-
secret: 'csrf-secret';
|
|
131
|
-
cookie: {
|
|
132
|
-
name: 'csrf-token';
|
|
133
|
-
options: {
|
|
134
|
-
httpOnly: true;
|
|
135
|
-
secure: true;
|
|
136
|
-
sameSite: 'strict'
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
helmet: {
|
|
141
|
-
enabled: true;
|
|
142
|
-
contentSecurityPolicy: {
|
|
143
|
-
directives: {
|
|
144
|
-
'default-src': readonly ['\'self\''];
|
|
145
|
-
'script-src': readonly ['\'self\'', '\'unsafe-inline\''];
|
|
146
|
-
'style-src': readonly ['\'self\'', '\'unsafe-inline\''];
|
|
147
|
-
'img-src': readonly ['\'self\'', 'data:', 'https:'];
|
|
148
|
-
'font-src': readonly ['\'self\''];
|
|
149
|
-
'connect-src': readonly ['\'self\''];
|
|
150
|
-
'media-src': readonly ['\'self\''];
|
|
151
|
-
'object-src': readonly ['\'none\''];
|
|
152
|
-
'child-src': readonly ['\'self\''];
|
|
153
|
-
'worker-src': readonly ['\'self\''];
|
|
154
|
-
'frame-ancestors': readonly ['\'none\''];
|
|
155
|
-
'form-action': readonly ['\'self\''];
|
|
156
|
-
'base-uri': readonly ['\'self\''];
|
|
157
|
-
'manifest-src': readonly ['\'self\'']
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
xssFilter: true;
|
|
161
|
-
noSniff: true;
|
|
162
|
-
frameOptions: 'DENY';
|
|
163
|
-
hidePoweredBy: true;
|
|
164
|
-
hsts: {
|
|
165
|
-
maxAge: 31536000;
|
|
166
|
-
includeSubDomains: true;
|
|
167
|
-
preload: true
|
|
168
|
-
};
|
|
169
|
-
referrerPolicy: 'strict-origin-when-cross-origin'
|
|
170
|
-
};
|
|
171
|
-
ddos: {
|
|
172
|
-
enabled: true;
|
|
173
|
-
maxRequestsPerSecond: 10;
|
|
174
|
-
maxRequestsPerMinute: 100;
|
|
175
|
-
maxRequestsPerHour: 1000;
|
|
176
|
-
burstLimit: 20;
|
|
177
|
-
windowSize: 60000;
|
|
178
|
-
blockDuration: 300000;
|
|
179
|
-
whitelistedIPs: Array<never>;
|
|
180
|
-
blacklistedIPs: Array<never>;
|
|
181
|
-
trustProxy: true;
|
|
182
|
-
store: 'memory'
|
|
183
|
-
};
|
|
184
|
-
inputValidation: {
|
|
185
|
-
enabled: true;
|
|
186
|
-
sanitizeByDefault: true;
|
|
187
|
-
strictMode: false;
|
|
188
|
-
allowUnknownFields: true;
|
|
189
|
-
maxDepth: 10
|
|
190
|
-
};
|
|
191
|
-
attackPrevention: {
|
|
192
|
-
enabled: true;
|
|
193
|
-
sqlInjection: true;
|
|
194
|
-
xss: true;
|
|
195
|
-
pathTraversal: true;
|
|
196
|
-
commandInjection: true;
|
|
197
|
-
ldapInjection: true;
|
|
198
|
-
xxe: true;
|
|
199
|
-
customPatterns: Array<never>
|
|
200
|
-
};
|
|
201
|
-
requestFiltering: {
|
|
202
|
-
enabled: true;
|
|
203
|
-
blockSuspiciousPatterns: true;
|
|
204
|
-
maxRequestsPerMinute: 1000;
|
|
205
|
-
blockUserAgents: readonly ['sqlmap', 'nikto', 'nessus', 'openvas', 'nmap', 'masscan', 'zap', 'w3af'];
|
|
206
|
-
allowedMethods: readonly ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'];
|
|
207
|
-
requireUserAgent: false;
|
|
208
|
-
maxBodySize: 10485760;
|
|
209
|
-
// 10MB
|
|
210
|
-
maxUrlLength: 2048;
|
|
211
|
-
maxHeaderSize: 8192;
|
|
212
|
-
allowedContentTypes: readonly ['application/json', 'application/x-www-form-urlencoded', 'multipart/form-data', 'text/plain', 'text/html', 'application/xml', 'text/xml']
|
|
213
|
-
};
|
|
214
|
-
ipFiltering: {
|
|
215
|
-
enabled: false;
|
|
216
|
-
whitelist: Array<never>;
|
|
217
|
-
blacklist: Array<never>;
|
|
218
|
-
blockPrivateIPs: false;
|
|
219
|
-
blockCloudProviders: false;
|
|
220
|
-
geoBlocking: {
|
|
221
|
-
enabled: false;
|
|
222
|
-
allowedCountries: Array<never>;
|
|
223
|
-
blockedCountries: Array<never>
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
responseSecurity: {
|
|
227
|
-
enabled: true;
|
|
228
|
-
removeServerHeaders: true;
|
|
229
|
-
addSecurityHeaders: true;
|
|
230
|
-
sanitizeErrors: true;
|
|
231
|
-
preventInfoDisclosure: true
|
|
232
|
-
};
|
|
233
|
-
auth: {
|
|
234
|
-
jwt: {
|
|
235
|
-
secret: 'jwt-secret';
|
|
236
|
-
expiresIn: '1h';
|
|
237
|
-
algorithm: 'HS256'
|
|
238
|
-
};
|
|
239
|
-
session: {
|
|
240
|
-
enabled: false;
|
|
241
|
-
secret: 'session-secret';
|
|
242
|
-
name: 'session';
|
|
243
|
-
resave: false;
|
|
244
|
-
rolling: true;
|
|
245
|
-
saveUninitialized: false;
|
|
246
|
-
cookie: {
|
|
247
|
-
maxAge: 86400000;
|
|
248
|
-
secure: true;
|
|
249
|
-
httpOnly: true;
|
|
250
|
-
sameSite: 'strict'
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
};
|
|
255
|
-
cluster: {
|
|
256
|
-
enabled: false;
|
|
257
|
-
workers: 'auto';
|
|
258
|
-
sticky: true
|
|
259
|
-
};
|
|
260
|
-
gracefulShutdown: {
|
|
261
|
-
enabled: true;
|
|
262
|
-
timeout: 30000;
|
|
263
|
-
signals: readonly ['SIGTERM', 'SIGINT'];
|
|
264
|
-
forceTimeout: 10000
|
|
265
|
-
};
|
|
266
|
-
middleware: {
|
|
267
|
-
order: Array<never>;
|
|
268
|
-
global: Array<never>
|
|
269
|
-
};
|
|
270
|
-
hooks: {}
|
|
271
|
-
}
|
|
272
|
-
};
|
|
273
|
-
// For backwards compatibility - synchronous access with default fallback
|
|
274
|
-
export declare const config: RouterConfig;
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get or create global container
|
|
3
|
-
*/
|
|
4
|
-
export declare function getContainer(): Container;
|
|
5
|
-
/**
|
|
6
|
-
* Set global container
|
|
7
|
-
*/
|
|
8
|
-
export declare function setContainer(container: Container): void;
|
|
9
|
-
/**
|
|
10
|
-
* Create new container
|
|
11
|
-
*/
|
|
12
|
-
export declare function createContainer(options?: ContainerOptions): Container;
|
|
13
|
-
// Dependency injection decorators
|
|
14
|
-
export declare const INJECTABLE_METADATA_KEY: unique symbol;
|
|
15
|
-
export declare const INJECT_METADATA_KEY: unique symbol;
|
|
16
|
-
export declare const OPTIONAL_METADATA_KEY: unique symbol;
|
|
17
|
-
export declare const TAGGED_METADATA_KEY: unique symbol;
|
|
18
|
-
export declare interface BindingMetadata {
|
|
19
|
-
scope: BindingScope
|
|
20
|
-
tags?: string[]
|
|
21
|
-
when?: (context: ResolutionContext) => boolean
|
|
22
|
-
factory?: (...args: any[]) => any
|
|
23
|
-
dependencies?: Token[]
|
|
24
|
-
lazy?: boolean
|
|
25
|
-
decorators?: ((...args: any[]) => any)[]
|
|
26
|
-
}
|
|
27
|
-
export declare interface Binding<T = any> {
|
|
28
|
-
token: Token
|
|
29
|
-
implementation?: new (...args: any[]) => T
|
|
30
|
-
instance?: T
|
|
31
|
-
factory?: (...args: any[]) => T
|
|
32
|
-
value?: T
|
|
33
|
-
metadata: BindingMetadata
|
|
34
|
-
}
|
|
35
|
-
export declare interface ResolutionContext {
|
|
36
|
-
container: Container
|
|
37
|
-
token: Token
|
|
38
|
-
parent?: ResolutionContext
|
|
39
|
-
environment?: string
|
|
40
|
-
requestId?: string
|
|
41
|
-
depth: number
|
|
42
|
-
resolving: Set<Token>
|
|
43
|
-
}
|
|
44
|
-
export declare interface ContainerOptions {
|
|
45
|
-
autoRegister?: boolean
|
|
46
|
-
strictMode?: boolean
|
|
47
|
-
maxDepth?: number
|
|
48
|
-
enableDecorators?: boolean
|
|
49
|
-
enableInterception?: boolean
|
|
50
|
-
defaultScope?: BindingScope
|
|
51
|
-
}
|
|
52
|
-
// Decorator metadata
|
|
53
|
-
export declare interface InjectableMetadata {
|
|
54
|
-
token?: string | symbol
|
|
55
|
-
scope?: BindingScope
|
|
56
|
-
tags?: string[]
|
|
57
|
-
}
|
|
58
|
-
export declare interface InjectMetadata {
|
|
59
|
-
token: Token
|
|
60
|
-
optional?: boolean
|
|
61
|
-
tags?: string[]
|
|
62
|
-
when?: (context: ResolutionContext) => boolean
|
|
63
|
-
}
|
|
64
|
-
// Container binding types
|
|
65
|
-
export type BindingScope = 'singleton' | 'transient' | 'scoped' | 'request'
|
|
66
|
-
// Token can be a string, symbol, function, constructor, or generic Function
|
|
67
|
-
// eslint-disable-next-line ts/no-unsafe-function-type
|
|
68
|
-
export type Token = string | symbol | ((...args: any[]) => any) | (new (...args: any[]) => any) | Function
|
|
69
|
-
/**
|
|
70
|
-
* Main IoC Container implementation
|
|
71
|
-
*/
|
|
72
|
-
export declare class Container {
|
|
73
|
-
private bindings: any;
|
|
74
|
-
private instances: any;
|
|
75
|
-
private scopedInstances: any;
|
|
76
|
-
private interceptors: any;
|
|
77
|
-
private parent?: Container;
|
|
78
|
-
private children: any;
|
|
79
|
-
private options: Required<ContainerOptions>;
|
|
80
|
-
constructor(options?: ContainerOptions);
|
|
81
|
-
bind<T>(token: Token): BindingBuilder<T>;
|
|
82
|
-
register<T>(binding: Binding<T>): this;
|
|
83
|
-
singleton<T>(token: Token, implementation: new (...args: any[]) => T): Container;
|
|
84
|
-
transient<T>(token: Token, implementation: new (...args: any[]) => T): Container;
|
|
85
|
-
value<T>(token: Token, value: T): Container;
|
|
86
|
-
factory<T>(token: Token, factory: (...args: any[]) => T): Container;
|
|
87
|
-
resolve<T>(token: Token, context?: Partial<ResolutionContext>): T;
|
|
88
|
-
resolveAll<T>(token: Token): T[];
|
|
89
|
-
resolveTagged<T>(tag: string): T[];
|
|
90
|
-
getTaggedBindings<T>(tag: string): Binding<T>[];
|
|
91
|
-
addInterceptor<T>(token: Token, interceptor: (service: T) => T): void;
|
|
92
|
-
registerController(controller: new (...args: any[]) => any): void;
|
|
93
|
-
getController<T>(controller: new (...args: any[]) => T): T;
|
|
94
|
-
isBound(token: Token): boolean;
|
|
95
|
-
unbind(token: Token): this;
|
|
96
|
-
createChild(options?: ContainerOptions): Container;
|
|
97
|
-
createScope(scopeId: string): Container;
|
|
98
|
-
getBindings(): Map<Token, Binding>;
|
|
99
|
-
clear(): this;
|
|
100
|
-
intercept<T>(token: string | symbol | ((...args: any[]) => any), interceptor: (instance: T, context: ResolutionContext) => T): this;
|
|
101
|
-
private resolveInternal<T>(token: Token, context: ResolutionContext): T;
|
|
102
|
-
protected createInstance<T>(binding: Binding<T>, context: ResolutionContext): T;
|
|
103
|
-
private createNewInstance<T>(binding: Binding<T>, context: ResolutionContext): T;
|
|
104
|
-
private createInstanceFromConstructor<T>(constructor: new (...args: any[]) => T, context: ResolutionContext): T;
|
|
105
|
-
private getConstructorDependencies(constructor: ((...args: any[]) => any) | (new (...args: any[]) => any)): Token[];
|
|
106
|
-
private parseConstructorDependencies(constructor: ((...args: any[]) => any) | (new (...args: any[]) => any)): string[];
|
|
107
|
-
private resolveDependencies(dependencies: Token[], context: ResolutionContext): any[];
|
|
108
|
-
private autoRegisterAndResolve<T>(constructor: new (...args: any[]) => T, context: ResolutionContext): T;
|
|
109
|
-
private applyDecorators(instance: any, constructor: ((...args: any[]) => any) | (new (...args: any[]) => any)): void;
|
|
110
|
-
private hasTag(binding: Binding, tag: string): boolean;
|
|
111
|
-
private tokenToString(token: Token): string;
|
|
112
|
-
private generateRequestId(): string;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Fluent binding builder
|
|
116
|
-
*/
|
|
117
|
-
export declare class BindingBuilder<T> {
|
|
118
|
-
private binding: Partial<Binding<T>>;
|
|
119
|
-
private container: Container;
|
|
120
|
-
constructor(container: Container, token: Token);
|
|
121
|
-
to(implementation: new (...args: any[]) => T): this;
|
|
122
|
-
toValue(value: T): this;
|
|
123
|
-
toFactory(factory: (...args: any[]) => T): this;
|
|
124
|
-
toInstance(instance: T): this;
|
|
125
|
-
inSingletonScope(): this;
|
|
126
|
-
inTransientScope(): this;
|
|
127
|
-
inScopedScope(): this;
|
|
128
|
-
inRequestScope(): this;
|
|
129
|
-
withTags(tags: string[]): this;
|
|
130
|
-
when(condition: (context: ResolutionContext) => boolean): this;
|
|
131
|
-
lazy(): this;
|
|
132
|
-
build(): Container;
|
|
133
|
-
}
|
|
134
|
-
// Extend Reflect with metadata methods
|
|
135
|
-
declare namespace global {
|
|
136
|
-
namespace Reflect {
|
|
137
|
-
function getMetadata(metadataKey: any, target: any, propertyKey?: string | symbol): any;
|
|
138
|
-
function defineMetadata(metadataKey: any, metadataValue: any, target: any, propertyKey?: string | symbol): void;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
export { Container as DIContainer };
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { Container } from './container';
|
|
2
|
-
import type { Binding, ResolutionContext, Token } from './container';
|
|
3
|
-
// Contextual binding interfaces
|
|
4
|
-
export declare interface ContextualBinding<T = any> extends Binding<T> {
|
|
5
|
-
conditions: BindingCondition[]
|
|
6
|
-
priority: number
|
|
7
|
-
fallback?: Binding<T>
|
|
8
|
-
}
|
|
9
|
-
export declare interface BindingCondition {
|
|
10
|
-
type: 'environment' | 'custom' | 'tag' | 'parent' | 'request'
|
|
11
|
-
predicate: (context: ResolutionContext) => boolean
|
|
12
|
-
description?: string
|
|
13
|
-
}
|
|
14
|
-
export declare interface EnvironmentConfig {
|
|
15
|
-
name: string
|
|
16
|
-
variables: Record<string, any>
|
|
17
|
-
services: Record<string, any>
|
|
18
|
-
features: string[]
|
|
19
|
-
}
|
|
20
|
-
export declare interface ContextualBindingBuilder<T> {
|
|
21
|
-
to: (implementation: new (...args: any[]) => T) => ContextualBindingBuilder<T>
|
|
22
|
-
toValue: (value: T) => ContextualBindingBuilder<T>
|
|
23
|
-
toFactory: (factory: (...args: any[]) => T) => ContextualBindingBuilder<T>
|
|
24
|
-
when: (condition: BindingCondition) => ContextualBindingBuilder<T>
|
|
25
|
-
whenEnvironment: (...environments: string[]) => ContextualBindingBuilder<T>
|
|
26
|
-
whenTag: (tag: string) => ContextualBindingBuilder<T>
|
|
27
|
-
whenParent: (parentToken: string | symbol | ((...args: any[]) => any)) => ContextualBindingBuilder<T>
|
|
28
|
-
whenRequest: (predicate: (context: ResolutionContext) => boolean) => ContextualBindingBuilder<T>
|
|
29
|
-
withPriority: (priority: number) => ContextualBindingBuilder<T>
|
|
30
|
-
withFallback: (fallback: Binding<T>) => ContextualBindingBuilder<T>
|
|
31
|
-
build: () => Container
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Environment manager for handling different deployment contexts
|
|
35
|
-
*/
|
|
36
|
-
export declare class EnvironmentManager {
|
|
37
|
-
private environments: any;
|
|
38
|
-
private currentEnvironment: string;
|
|
39
|
-
private variables: any;
|
|
40
|
-
constructor(defaultEnvironment?: string);
|
|
41
|
-
register(config: EnvironmentConfig): this;
|
|
42
|
-
setEnvironment(name: string): this;
|
|
43
|
-
getCurrentEnvironment(): string;
|
|
44
|
-
getEnvironment(name?: string): EnvironmentConfig | undefined;
|
|
45
|
-
is(environments: string[]): boolean;
|
|
46
|
-
get(key: string, defaultValue?: any): any;
|
|
47
|
-
set(key: string, value: any): this;
|
|
48
|
-
hasFeature(feature: string): boolean;
|
|
49
|
-
private loadEnvironmentVariables(): void;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Contextual binding builder implementation
|
|
53
|
-
*/
|
|
54
|
-
export declare class DefaultContextualBindingBuilder<T> implements ContextualBindingBuilder<T> {
|
|
55
|
-
private binding: Partial<ContextualBinding<T>>;
|
|
56
|
-
private container: ContextualContainer;
|
|
57
|
-
constructor(container: ContextualContainer, token: Token);
|
|
58
|
-
when(condition: BindingCondition): ContextualBindingBuilder<T>;
|
|
59
|
-
whenEnvironment(environments: string[]): ContextualBindingBuilder<T>;
|
|
60
|
-
whenTag(tag: string): ContextualBindingBuilder<T>;
|
|
61
|
-
whenParent(parentToken: string | symbol | ((...args: any[]) => any)): ContextualBindingBuilder<T>;
|
|
62
|
-
whenRequest(predicate: (context: ResolutionContext) => boolean): ContextualBindingBuilder<T>;
|
|
63
|
-
withPriority(priority: number): ContextualBindingBuilder<T>;
|
|
64
|
-
withFallback(fallback: Binding<T>): ContextualBindingBuilder<T>;
|
|
65
|
-
to(implementation: new (...args: any[]) => T): this;
|
|
66
|
-
toValue(value: T): this;
|
|
67
|
-
toFactory(factory: (...args: any[]) => T): this;
|
|
68
|
-
inSingletonScope(): this;
|
|
69
|
-
inTransientScope(): this;
|
|
70
|
-
build(): Container;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Enhanced container with contextual binding support
|
|
74
|
-
*/
|
|
75
|
-
export declare class ContextualContainer extends Container {
|
|
76
|
-
private contextualBindings: any;
|
|
77
|
-
private environmentManager: EnvironmentManager;
|
|
78
|
-
constructor(options?: any);
|
|
79
|
-
bindContextual<T>(token: Token): ContextualBindingBuilder<T>;
|
|
80
|
-
registerContextualBinding<T>(binding: ContextualBinding<T>): this;
|
|
81
|
-
getEnvironmentManager(): EnvironmentManager;
|
|
82
|
-
forDevelopment<T>(token: Token): ContextualBindingBuilder<T>;
|
|
83
|
-
forProduction<T>(token: Token): ContextualBindingBuilder<T>;
|
|
84
|
-
forTesting<T>(token: Token): ContextualBindingBuilder<T>;
|
|
85
|
-
forStaging<T>(token: Token): ContextualBindingBuilder<T>;
|
|
86
|
-
resolve<T>(token: Token, context?: Partial<ResolutionContext>): T;
|
|
87
|
-
private findContextualBinding(token: Token, context: ResolutionContext): ContextualBinding | undefined;
|
|
88
|
-
private evaluateConditions(conditions: BindingCondition[], context: ResolutionContext): boolean;
|
|
89
|
-
private createInstanceFromContextualBinding<T>(binding: ContextualBinding<T>, context: ResolutionContext): T;
|
|
90
|
-
private generateContextualRequestId(): string;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Pre-configured environment setups
|
|
94
|
-
*/
|
|
95
|
-
export declare class EnvironmentPresets {
|
|
96
|
-
static development(): EnvironmentConfig;
|
|
97
|
-
static production(): EnvironmentConfig;
|
|
98
|
-
static testing(): EnvironmentConfig;
|
|
99
|
-
static staging(): EnvironmentConfig;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Contextual binding conditions factory
|
|
103
|
-
*/
|
|
104
|
-
export declare class BindingConditions {
|
|
105
|
-
static environment(environments: string[]): BindingCondition;
|
|
106
|
-
static feature(featureName: string): BindingCondition;
|
|
107
|
-
static envVar(key: string, value: any): BindingCondition;
|
|
108
|
-
static requestPattern(pattern: RegExp): BindingCondition;
|
|
109
|
-
static timeRange(startHour: number, endHour: number): BindingCondition;
|
|
110
|
-
static custom(predicate: (context: ResolutionContext) => boolean, description?: string): BindingCondition;
|
|
111
|
-
}
|
|
112
|
-
export { ContextualContainer as DIContainer };
|