@stacksjs/bun-router 0.0.13 → 0.0.14
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/CHANGELOG.md +770 -0
- package/README.md +584 -261
- package/package.json +43 -47
- package/bin/cli.ts +0 -9
- package/dist/auth.d.ts +0 -134
- package/dist/cache/lru-cache.d.ts +0 -139
- package/dist/cache/middleware-memoization.d.ts +0 -151
- package/dist/cache/route-cache-warmer.d.ts +0 -161
- package/dist/cache/sqlite-cache.d.ts +0 -209
- package/dist/cache/streaming-cache.d.ts +0 -132
- package/dist/chunk-1mvtv6jw.js +0 -13012
- package/dist/cli/colors.d.ts +0 -15
- 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 -29
- package/dist/cli/utils.d.ts +0 -74
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +0 -3195
- package/dist/config.d.ts +0 -7
- package/dist/container/container.d.ts +0 -273
- package/dist/container/contextual-binding.d.ts +0 -240
- package/dist/container/decorators.d.ts +0 -141
- package/dist/container/service-provider.d.ts +0 -285
- package/dist/development/hot-reload.d.ts +0 -187
- package/dist/development/index.d.ts +0 -167
- package/dist/development/performance-profiler.d.ts +0 -217
- package/dist/development/route-debugger.d.ts +0 -154
- package/dist/development/route-inspector.d.ts +0 -211
- package/dist/development/typescript-utilities.d.ts +0 -209
- package/dist/docs.d.ts +0 -11
- package/dist/errors/circuit-breaker.d.ts +0 -195
- package/dist/errors/error-handler.d.ts +0 -88
- package/dist/errors/error-reporting.d.ts +0 -144
- package/dist/errors/exceptions.d.ts +0 -184
- package/dist/errors/graceful-degradation.d.ts +0 -154
- package/dist/errors/index.d.ts +0 -9
- package/dist/errors/router-errors.d.ts +0 -110
- package/dist/file-serving/static-files.d.ts +0 -143
- package/dist/index.d.ts +0 -14
- package/dist/index.js +0 -13933
- package/dist/middleware/auth.d.ts +0 -63
- package/dist/middleware/content_security_policy.d.ts +0 -53
- package/dist/middleware/cors.d.ts +0 -5
- package/dist/middleware/csrf.d.ts +0 -7
- package/dist/middleware/ddos_protection.d.ts +0 -39
- package/dist/middleware/file_security.d.ts +0 -26
- package/dist/middleware/file_upload.d.ts +0 -38
- package/dist/middleware/helmet.d.ts +0 -54
- package/dist/middleware/index.d.ts +0 -44
- package/dist/middleware/input_validation.d.ts +0 -45
- package/dist/middleware/json_body.d.ts +0 -4
- package/dist/middleware/performance_alerting.d.ts +0 -87
- package/dist/middleware/performance_dashboard.d.ts +0 -87
- package/dist/middleware/performance_monitor.d.ts +0 -209
- package/dist/middleware/pipeline.d.ts +0 -131
- package/dist/middleware/rate_limit.d.ts +0 -36
- package/dist/middleware/request_id.d.ts +0 -4
- package/dist/middleware/request_signing.d.ts +0 -153
- package/dist/middleware/request_tracer.d.ts +0 -72
- package/dist/middleware/response_cache.d.ts +0 -97
- package/dist/middleware/security.d.ts +0 -69
- package/dist/middleware/security_suite.d.ts +0 -46
- package/dist/middleware/session.d.ts +0 -23
- package/dist/model-binding/index.d.ts +0 -2
- package/dist/model-binding/model-middleware.d.ts +0 -118
- package/dist/model-binding/model-registry.d.ts +0 -164
- package/dist/model-binding.d.ts +0 -185
- package/dist/model-resolver-factory.d.ts +0 -31
- package/dist/observability/correlation.d.ts +0 -187
- package/dist/observability/health-checks.d.ts +0 -186
- package/dist/observability/index.d.ts +0 -60
- package/dist/observability/integration.d.ts +0 -147
- package/dist/observability/metrics.d.ts +0 -184
- package/dist/observability/tracing.d.ts +0 -187
- package/dist/optimization/bun-utilities.d.ts +0 -224
- package/dist/query-builder-integration.d.ts +0 -36
- package/dist/request/context.d.ts +0 -34
- package/dist/request/enhanced-request.d.ts +0 -213
- package/dist/request/macros.d.ts +0 -300
- package/dist/response/macros.d.ts +0 -245
- package/dist/response/response-factory.d.ts +0 -133
- package/dist/router/api-routes.d.ts +0 -5
- package/dist/router/file-based-routing.d.ts +0 -118
- package/dist/router/file-streaming.d.ts +0 -5
- package/dist/router/fluent-router.d.ts +0 -315
- package/dist/router/fluent-routing.d.ts +0 -271
- package/dist/router/group-organization.d.ts +0 -5
- package/dist/router/handler-resolver.d.ts +0 -24
- package/dist/router/http-methods.d.ts +0 -10
- package/dist/router/index.d.ts +0 -114
- package/dist/router/middleware-groups.d.ts +0 -94
- package/dist/router/middleware-integration.d.ts +0 -112
- package/dist/router/middleware.d.ts +0 -5
- package/dist/router/model-binding.d.ts +0 -5
- 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 -153
- package/dist/router/route-matching.d.ts +0 -5
- package/dist/router/route-trie.d.ts +0 -114
- package/dist/router/router.d.ts +0 -294
- package/dist/router/server.d.ts +0 -5
- package/dist/router/validation-integration.d.ts +0 -170
- 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 -129
- package/dist/routing/route-throttling.d.ts +0 -150
- package/dist/routing/subdomain-routing.d.ts +0 -206
- package/dist/session/database-store.d.ts +0 -51
- package/dist/session/file-store.d.ts +0 -22
- package/dist/session/index.d.ts +0 -106
- package/dist/session/memory-store.d.ts +0 -21
- package/dist/session/redis-store.d.ts +0 -31
- package/dist/streaming/index.d.ts +0 -3
- package/dist/streaming/sse-handler.d.ts +0 -138
- package/dist/streaming/stream-handler.d.ts +0 -114
- package/dist/testing/auth-testing.d.ts +0 -156
- package/dist/testing/file-upload-testing.d.ts +0 -190
- package/dist/testing/index.d.ts +0 -10
- package/dist/testing/middleware-testing.d.ts +0 -138
- package/dist/testing/model-binding-testing.d.ts +0 -186
- package/dist/testing/performance-testing.d.ts +0 -235
- package/dist/testing/test-client.d.ts +0 -117
- package/dist/testing/test-request.d.ts +0 -85
- package/dist/testing/test-response.d.ts +0 -90
- package/dist/testing/types.d.ts +0 -207
- package/dist/testing/websocket-testing.d.ts +0 -227
- package/dist/types/controller-types.d.ts +0 -208
- package/dist/types/core.d.ts +0 -543
- package/dist/types/middleware-types.d.ts +0 -227
- package/dist/types/request-response-augmentation.d.ts +0 -261
- package/dist/types/route-inference.d.ts +0 -168
- package/dist/types.d.ts +0 -1782
- package/dist/url.d.ts +0 -56
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/query-preservation.d.ts +0 -48
- package/dist/utils.d.ts +0 -69
- package/dist/validation/validator.d.ts +0 -140
- package/dist/websocket/clustering.d.ts +0 -185
- package/src/auth.ts +0 -469
- package/src/cache/lru-cache.ts +0 -457
- package/src/cache/middleware-memoization.ts +0 -531
- package/src/cache/route-cache-warmer.ts +0 -486
- package/src/cache/sqlite-cache.ts +0 -783
- package/src/cache/streaming-cache.ts +0 -572
- package/src/cli/colors.ts +0 -29
- package/src/cli/index.ts +0 -287
- package/src/cli/middleware.ts +0 -291
- package/src/cli/openapi.ts +0 -407
- package/src/cli/router.ts +0 -188
- package/src/cli/routes.ts +0 -265
- package/src/cli/utils.ts +0 -531
- package/src/cli.ts +0 -5
- package/src/config.ts +0 -322
- package/src/container/container.ts +0 -740
- package/src/container/contextual-binding.ts +0 -603
- package/src/container/decorators.ts +0 -359
- package/src/container/service-provider.ts +0 -596
- package/src/development/hot-reload.ts +0 -673
- package/src/development/index.ts +0 -499
- package/src/development/performance-profiler.ts +0 -717
- package/src/development/route-debugger.ts +0 -527
- package/src/development/route-inspector.ts +0 -749
- package/src/development/typescript-utilities.ts +0 -682
- package/src/docs.ts +0 -397
- package/src/errors/circuit-breaker.ts +0 -732
- package/src/errors/error-handler.ts +0 -569
- package/src/errors/error-reporting.ts +0 -672
- package/src/errors/exceptions.ts +0 -536
- package/src/errors/graceful-degradation.ts +0 -621
- package/src/errors/index.ts +0 -21
- package/src/errors/router-errors.ts +0 -632
- package/src/file-serving/static-files.ts +0 -581
- package/src/index.ts +0 -14
- package/src/middleware/auth.ts +0 -219
- package/src/middleware/content_security_policy.ts +0 -215
- package/src/middleware/cors.ts +0 -74
- package/src/middleware/csrf.ts +0 -108
- package/src/middleware/ddos_protection.ts +0 -255
- package/src/middleware/file_security.ts +0 -191
- package/src/middleware/file_upload.ts +0 -264
- package/src/middleware/helmet.ts +0 -268
- package/src/middleware/index.ts +0 -117
- package/src/middleware/input_validation.ts +0 -449
- package/src/middleware/json_body.ts +0 -37
- package/src/middleware/performance_alerting.ts +0 -538
- package/src/middleware/performance_dashboard.ts +0 -661
- package/src/middleware/performance_monitor.ts +0 -943
- package/src/middleware/pipeline.ts +0 -489
- package/src/middleware/rate_limit.ts +0 -245
- package/src/middleware/request_id.ts +0 -36
- package/src/middleware/request_signing.ts +0 -636
- package/src/middleware/request_tracer.ts +0 -636
- package/src/middleware/response_cache.ts +0 -743
- package/src/middleware/security.ts +0 -482
- package/src/middleware/security_suite.ts +0 -257
- package/src/middleware/session.ts +0 -91
- package/src/model-binding/index.ts +0 -18
- package/src/model-binding/model-middleware.ts +0 -425
- package/src/model-binding/model-registry.ts +0 -550
- package/src/model-binding.ts +0 -370
- package/src/model-resolver-factory.ts +0 -106
- package/src/observability/correlation.ts +0 -691
- package/src/observability/health-checks.ts +0 -729
- package/src/observability/index.ts +0 -184
- package/src/observability/integration.ts +0 -548
- package/src/observability/metrics.ts +0 -753
- package/src/observability/tracing.ts +0 -638
- package/src/optimization/bun-utilities.ts +0 -778
- package/src/query-builder-integration.ts +0 -137
- package/src/request/context.ts +0 -62
- package/src/request/enhanced-request.ts +0 -857
- package/src/request/macros.ts +0 -688
- package/src/response/macros.ts +0 -612
- package/src/response/response-factory.ts +0 -596
- package/src/router/api-routes.ts +0 -243
- package/src/router/file-based-routing.ts +0 -670
- package/src/router/file-streaming.ts +0 -372
- package/src/router/fluent-router.ts +0 -927
- package/src/router/fluent-routing.ts +0 -797
- package/src/router/group-organization.ts +0 -213
- package/src/router/handler-resolver.ts +0 -291
- package/src/router/http-methods.ts +0 -377
- package/src/router/index.ts +0 -187
- package/src/router/middleware-groups.ts +0 -222
- package/src/router/middleware-integration.ts +0 -399
- package/src/router/middleware.ts +0 -231
- package/src/router/model-binding.ts +0 -215
- package/src/router/optimized-route-matching.ts +0 -253
- package/src/router/route-building.ts +0 -212
- package/src/router/route-compiler.ts +0 -702
- package/src/router/route-matching.ts +0 -349
- package/src/router/route-trie.ts +0 -464
- package/src/router/router.ts +0 -1581
- package/src/router/server.ts +0 -462
- package/src/router/validation-integration.ts +0 -443
- package/src/router/view-rendering.ts +0 -233
- package/src/router/websocket.ts +0 -100
- package/src/routing/route-caching.ts +0 -402
- package/src/routing/route-throttling.ts +0 -469
- package/src/routing/subdomain-routing.ts +0 -492
- package/src/session/database-store.ts +0 -109
- package/src/session/file-store.ts +0 -148
- package/src/session/index.ts +0 -244
- package/src/session/memory-store.ts +0 -88
- package/src/session/redis-store.ts +0 -93
- package/src/streaming/index.ts +0 -17
- package/src/streaming/sse-handler.ts +0 -482
- package/src/streaming/stream-handler.ts +0 -552
- package/src/testing/auth-testing.ts +0 -446
- package/src/testing/file-upload-testing.ts +0 -543
- package/src/testing/index.ts +0 -10
- package/src/testing/middleware-testing.ts +0 -322
- package/src/testing/model-binding-testing.ts +0 -645
- package/src/testing/performance-testing.ts +0 -738
- package/src/testing/test-client.ts +0 -310
- package/src/testing/test-request.ts +0 -315
- package/src/testing/test-response.ts +0 -332
- package/src/testing/types.ts +0 -224
- package/src/testing/websocket-testing.ts +0 -590
- package/src/types/controller-types.ts +0 -385
- package/src/types/core.ts +0 -683
- package/src/types/middleware-types.ts +0 -419
- package/src/types/request-response-augmentation.ts +0 -489
- package/src/types/route-inference.ts +0 -357
- package/src/types.ts +0 -2055
- package/src/url.ts +0 -126
- package/src/utils/index.ts +0 -1
- package/src/utils/query-preservation.ts +0 -201
- package/src/utils.ts +0 -327
- package/src/validation/validator.ts +0 -685
- package/src/websocket/clustering.ts +0 -762
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import type { EnhancedRequest } from '../types';
|
|
2
|
-
import type { TestFile, TestRequestOptions } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Creates a mock EnhancedRequest for testing
|
|
5
|
-
*/
|
|
6
|
-
export declare class TestRequestBuilder {
|
|
7
|
-
private request;
|
|
8
|
-
private url;
|
|
9
|
-
constructor(method: string, path: string, options?: TestRequestOptions);
|
|
10
|
-
private parseQuery;
|
|
11
|
-
private convertTestFiles;
|
|
12
|
-
private handleBody;
|
|
13
|
-
/**
|
|
14
|
-
* Set route parameters
|
|
15
|
-
*/
|
|
16
|
-
params(params: Record<string, string>): TestRequestBuilder;
|
|
17
|
-
/**
|
|
18
|
-
* Set request headers
|
|
19
|
-
*/
|
|
20
|
-
headers(headers: Record<string, string>): TestRequestBuilder;
|
|
21
|
-
/**
|
|
22
|
-
* Set authorization header
|
|
23
|
-
*/
|
|
24
|
-
auth(token: string, type?: 'Bearer' | 'Basic'): TestRequestBuilder;
|
|
25
|
-
/**
|
|
26
|
-
* Set user context
|
|
27
|
-
*/
|
|
28
|
-
user(user: any): TestRequestBuilder;
|
|
29
|
-
/**
|
|
30
|
-
* Set session data
|
|
31
|
-
*/
|
|
32
|
-
session(session: any): TestRequestBuilder;
|
|
33
|
-
/**
|
|
34
|
-
* Set cookies
|
|
35
|
-
*/
|
|
36
|
-
cookies(cookies: Record<string, string>): TestRequestBuilder;
|
|
37
|
-
/**
|
|
38
|
-
* Set context data
|
|
39
|
-
*/
|
|
40
|
-
context(context: Record<string, any>): TestRequestBuilder;
|
|
41
|
-
/**
|
|
42
|
-
* Set JSON body
|
|
43
|
-
*/
|
|
44
|
-
json(data: any): TestRequestBuilder;
|
|
45
|
-
/**
|
|
46
|
-
* Set form body
|
|
47
|
-
*/
|
|
48
|
-
form(data: Record<string, any>): TestRequestBuilder;
|
|
49
|
-
/**
|
|
50
|
-
* Add uploaded files
|
|
51
|
-
*/
|
|
52
|
-
files(files: TestFile[]): TestRequestBuilder;
|
|
53
|
-
/**
|
|
54
|
-
* Set IP address
|
|
55
|
-
*/
|
|
56
|
-
ip(ip: string): TestRequestBuilder;
|
|
57
|
-
/**
|
|
58
|
-
* Set user agent
|
|
59
|
-
*/
|
|
60
|
-
userAgent(userAgent: string): TestRequestBuilder;
|
|
61
|
-
/**
|
|
62
|
-
* Set CSRF token
|
|
63
|
-
*/
|
|
64
|
-
csrf(token: string): TestRequestBuilder;
|
|
65
|
-
/**
|
|
66
|
-
* Build the final request object
|
|
67
|
-
*/
|
|
68
|
-
build(): EnhancedRequest;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Helper functions for creating test requests
|
|
72
|
-
*/
|
|
73
|
-
export declare const testRequest: {
|
|
74
|
-
get: (path: string, options?: TestRequestOptions) => TestRequestBuilder;
|
|
75
|
-
post: (path: string, options?: TestRequestOptions) => TestRequestBuilder;
|
|
76
|
-
put: (path: string, options?: TestRequestOptions) => TestRequestBuilder;
|
|
77
|
-
patch: (path: string, options?: TestRequestOptions) => TestRequestBuilder;
|
|
78
|
-
delete: (path: string, options?: TestRequestOptions) => TestRequestBuilder;
|
|
79
|
-
options: (path: string, options?: TestRequestOptions) => TestRequestBuilder;
|
|
80
|
-
head: (path: string, options?: TestRequestOptions) => TestRequestBuilder;
|
|
81
|
-
};
|
|
82
|
-
/**
|
|
83
|
-
* Create a mock request with minimal setup
|
|
84
|
-
*/
|
|
85
|
-
export declare function createMockRequest(method?: string, path?: string, options?: TestRequestOptions): EnhancedRequest;
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import type { TestResponse } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Test response wrapper with assertion helpers
|
|
4
|
-
*/
|
|
5
|
-
export declare class TestResponseWrapper implements TestResponse {
|
|
6
|
-
status: number;
|
|
7
|
-
statusText: string;
|
|
8
|
-
headers: Record<string, string>;
|
|
9
|
-
body: any;
|
|
10
|
-
text: string;
|
|
11
|
-
json: any;
|
|
12
|
-
cookies: Record<string, string>;
|
|
13
|
-
redirected: boolean;
|
|
14
|
-
url: string;
|
|
15
|
-
ok: boolean;
|
|
16
|
-
type: string;
|
|
17
|
-
private originalResponse;
|
|
18
|
-
constructor(response: Response, body?: any);
|
|
19
|
-
private parseHeaders;
|
|
20
|
-
private parseCookies;
|
|
21
|
-
/**
|
|
22
|
-
* Assert response status
|
|
23
|
-
*/
|
|
24
|
-
expectStatus(status: number): TestResponseWrapper;
|
|
25
|
-
/**
|
|
26
|
-
* Assert response is successful (2xx)
|
|
27
|
-
*/
|
|
28
|
-
expectSuccess(): TestResponseWrapper;
|
|
29
|
-
/**
|
|
30
|
-
* Assert response has specific header
|
|
31
|
-
*/
|
|
32
|
-
expectHeader(name: string, value?: string): TestResponseWrapper;
|
|
33
|
-
/**
|
|
34
|
-
* Assert response body matches
|
|
35
|
-
*/
|
|
36
|
-
expectBody(expectedBody: any): TestResponseWrapper;
|
|
37
|
-
/**
|
|
38
|
-
* Assert response JSON matches
|
|
39
|
-
*/
|
|
40
|
-
expectJson(expectedJson: any): TestResponseWrapper;
|
|
41
|
-
/**
|
|
42
|
-
* Assert response JSON contains specific properties
|
|
43
|
-
*/
|
|
44
|
-
expectJsonContains(properties: Record<string, any>): TestResponseWrapper;
|
|
45
|
-
/**
|
|
46
|
-
* Assert response has specific cookie
|
|
47
|
-
*/
|
|
48
|
-
expectCookie(name: string, value?: string): TestResponseWrapper;
|
|
49
|
-
/**
|
|
50
|
-
* Assert response is a redirect
|
|
51
|
-
*/
|
|
52
|
-
expectRedirect(url?: string): TestResponseWrapper;
|
|
53
|
-
/**
|
|
54
|
-
* Assert response contains validation errors
|
|
55
|
-
*/
|
|
56
|
-
expectValidationError(field?: string, message?: string): TestResponseWrapper;
|
|
57
|
-
/**
|
|
58
|
-
* Assert response content type
|
|
59
|
-
*/
|
|
60
|
-
expectContentType(contentType: string): TestResponseWrapper;
|
|
61
|
-
/**
|
|
62
|
-
* Assert response body contains text
|
|
63
|
-
*/
|
|
64
|
-
expectBodyContains(text: string): TestResponseWrapper;
|
|
65
|
-
/**
|
|
66
|
-
* Assert response body matches regex
|
|
67
|
-
*/
|
|
68
|
-
expectBodyMatches(pattern: RegExp): TestResponseWrapper;
|
|
69
|
-
/**
|
|
70
|
-
* Assert response JSON has specific structure
|
|
71
|
-
*/
|
|
72
|
-
expectJsonStructure(structure: any): TestResponseWrapper;
|
|
73
|
-
private validateStructure;
|
|
74
|
-
/**
|
|
75
|
-
* Get the original Response object
|
|
76
|
-
*/
|
|
77
|
-
getOriginalResponse(): Response;
|
|
78
|
-
/**
|
|
79
|
-
* Convert to JSON for easy inspection
|
|
80
|
-
*/
|
|
81
|
-
toJSON(): any;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Create a test response from a Response object
|
|
85
|
-
*/
|
|
86
|
-
export declare function createTestResponse(response: Response): Promise<TestResponseWrapper>;
|
|
87
|
-
/**
|
|
88
|
-
* Create a mock response for testing
|
|
89
|
-
*/
|
|
90
|
-
export declare function createMockResponse(status?: number, body?: any, headers?: Record<string, string>): TestResponseWrapper;
|
package/dist/testing/types.d.ts
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import type { EnhancedRequest, MiddlewareHandler } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Test client configuration options
|
|
4
|
-
*/
|
|
5
|
-
export interface TestClientConfig {
|
|
6
|
-
baseUrl?: string;
|
|
7
|
-
defaultHeaders?: Record<string, string>;
|
|
8
|
-
timeout?: number;
|
|
9
|
-
followRedirects?: boolean;
|
|
10
|
-
validateStatus?: (status: number) => boolean;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Test request options
|
|
14
|
-
*/
|
|
15
|
-
export interface TestRequestOptions {
|
|
16
|
-
headers?: Record<string, string>;
|
|
17
|
-
query?: Record<string, string | string[]>;
|
|
18
|
-
body?: any;
|
|
19
|
-
files?: TestFile[];
|
|
20
|
-
cookies?: Record<string, string>;
|
|
21
|
-
session?: any;
|
|
22
|
-
user?: any;
|
|
23
|
-
context?: Record<string, any>;
|
|
24
|
-
timeout?: number;
|
|
25
|
-
followRedirects?: boolean;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Test file for upload testing
|
|
29
|
-
*/
|
|
30
|
-
export interface TestFile {
|
|
31
|
-
fieldName: string;
|
|
32
|
-
filename: string;
|
|
33
|
-
content: string | ArrayBuffer | Uint8Array;
|
|
34
|
-
mimetype?: string;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Test response interface
|
|
38
|
-
*/
|
|
39
|
-
export interface TestResponse {
|
|
40
|
-
status: number;
|
|
41
|
-
statusText: string;
|
|
42
|
-
headers: Record<string, string>;
|
|
43
|
-
body: any;
|
|
44
|
-
text: string;
|
|
45
|
-
json: any;
|
|
46
|
-
cookies: Record<string, string>;
|
|
47
|
-
redirected: boolean;
|
|
48
|
-
url: string;
|
|
49
|
-
ok: boolean;
|
|
50
|
-
type: string;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Middleware test context
|
|
54
|
-
*/
|
|
55
|
-
export interface MiddlewareTestContext {
|
|
56
|
-
request: EnhancedRequest;
|
|
57
|
-
response?: Response;
|
|
58
|
-
next: ReturnType<typeof import('bun:test').mock<() => Promise<Response | null>>>;
|
|
59
|
-
error?: Error;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Authentication test user
|
|
63
|
-
*/
|
|
64
|
-
export interface TestUser {
|
|
65
|
-
id: string | number;
|
|
66
|
-
email?: string;
|
|
67
|
-
username?: string;
|
|
68
|
-
roles?: string[];
|
|
69
|
-
permissions?: string[];
|
|
70
|
-
[key: string]: any;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* JWT test options
|
|
74
|
-
*/
|
|
75
|
-
export interface JWTTestOptions {
|
|
76
|
-
secret?: string;
|
|
77
|
-
expiresIn?: string;
|
|
78
|
-
algorithm?: 'HS256' | 'HS384' | 'HS512' | 'RS256';
|
|
79
|
-
payload?: Record<string, any>;
|
|
80
|
-
headers?: Record<string, any>;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Session test options
|
|
84
|
-
*/
|
|
85
|
-
export interface SessionTestOptions {
|
|
86
|
-
sessionId?: string;
|
|
87
|
-
data?: Record<string, any>;
|
|
88
|
-
maxAge?: number;
|
|
89
|
-
secure?: boolean;
|
|
90
|
-
httpOnly?: boolean;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Model binding test options
|
|
94
|
-
*/
|
|
95
|
-
export interface ModelBindingTestOptions {
|
|
96
|
-
modelClass?: any;
|
|
97
|
-
routeKey?: string;
|
|
98
|
-
constraints?: Record<string, any>;
|
|
99
|
-
customResolver?: (value: string) => Promise<any>;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Performance test metrics
|
|
103
|
-
*/
|
|
104
|
-
export interface PerformanceMetrics {
|
|
105
|
-
responseTime: number;
|
|
106
|
-
memoryUsage: {
|
|
107
|
-
heapUsed: number;
|
|
108
|
-
heapTotal: number;
|
|
109
|
-
external: number;
|
|
110
|
-
rss: number;
|
|
111
|
-
};
|
|
112
|
-
cpuUsage: {
|
|
113
|
-
user: number;
|
|
114
|
-
system: number;
|
|
115
|
-
};
|
|
116
|
-
requestsPerSecond?: number;
|
|
117
|
-
concurrentRequests?: number;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Load test configuration
|
|
121
|
-
*/
|
|
122
|
-
export interface LoadTestConfig {
|
|
123
|
-
duration: number;
|
|
124
|
-
concurrency: number;
|
|
125
|
-
rampUp?: number;
|
|
126
|
-
rampDown?: number;
|
|
127
|
-
requestsPerSecond?: number;
|
|
128
|
-
maxRequests?: number;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* WebSocket test message
|
|
132
|
-
*/
|
|
133
|
-
export interface WSTestMessage {
|
|
134
|
-
type: 'text' | 'binary';
|
|
135
|
-
data: string | ArrayBuffer | Uint8Array;
|
|
136
|
-
timestamp?: number;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* WebSocket test client
|
|
140
|
-
*/
|
|
141
|
-
export interface WSTestClient {
|
|
142
|
-
send: (message: string | ArrayBuffer | Uint8Array) => void;
|
|
143
|
-
close: (code?: number, reason?: string) => void;
|
|
144
|
-
ping: (data?: Uint8Array) => void;
|
|
145
|
-
pong: (data?: Uint8Array) => void;
|
|
146
|
-
messages: WSTestMessage[];
|
|
147
|
-
isConnected: boolean;
|
|
148
|
-
readyState: number;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Test assertion helpers
|
|
152
|
-
*/
|
|
153
|
-
export interface TestAssertions {
|
|
154
|
-
toHaveStatus: (status: number) => void;
|
|
155
|
-
toHaveHeader: (name: string, value?: string) => void;
|
|
156
|
-
toHaveBody: (body: any) => void;
|
|
157
|
-
toHaveJson: (json: any) => void;
|
|
158
|
-
toHaveCookie: (name: string, value?: string) => void;
|
|
159
|
-
toBeRedirected: (url?: string) => void;
|
|
160
|
-
toHaveValidationError: (field?: string, message?: string) => void;
|
|
161
|
-
toBeAuthenticated: (user?: any) => void;
|
|
162
|
-
toBeUnauthenticated: () => void;
|
|
163
|
-
toHaveMiddleware: (middleware: string | MiddlewareHandler) => void;
|
|
164
|
-
toHaveModel: (model: any) => void;
|
|
165
|
-
toHaveUploadedFile: (fieldName: string, filename?: string) => void;
|
|
166
|
-
toRespondWithin: (milliseconds: number) => void;
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Mock factory options
|
|
170
|
-
*/
|
|
171
|
-
export interface MockFactoryOptions {
|
|
172
|
-
count?: number;
|
|
173
|
-
overrides?: Record<string, any>;
|
|
174
|
-
relations?: Record<string, any>;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Database test helpers
|
|
178
|
-
*/
|
|
179
|
-
export interface DatabaseTestHelpers {
|
|
180
|
-
seed: (data: any[]) => Promise<void>;
|
|
181
|
-
truncate: (tables?: string[]) => Promise<void>;
|
|
182
|
-
factory: <T>(model: string, options?: MockFactoryOptions) => T[];
|
|
183
|
-
create: <T>(model: string, data?: Partial<T>) => Promise<T>;
|
|
184
|
-
transaction: <T>(callback: () => Promise<T>) => Promise<T>;
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Test environment configuration
|
|
188
|
-
*/
|
|
189
|
-
export interface TestEnvironment {
|
|
190
|
-
database?: DatabaseTestHelpers;
|
|
191
|
-
cache?: {
|
|
192
|
-
clear: () => Promise<void>;
|
|
193
|
-
get: (key: string) => Promise<any>;
|
|
194
|
-
set: (key: string, value: any, ttl?: number) => Promise<void>;
|
|
195
|
-
};
|
|
196
|
-
storage?: {
|
|
197
|
-
clear: () => Promise<void>;
|
|
198
|
-
put: (path: string, content: string | ArrayBuffer) => Promise<void>;
|
|
199
|
-
get: (path: string) => Promise<string | ArrayBuffer | null>;
|
|
200
|
-
delete: (path: string) => Promise<void>;
|
|
201
|
-
};
|
|
202
|
-
queue?: {
|
|
203
|
-
clear: () => Promise<void>;
|
|
204
|
-
push: (job: any) => Promise<void>;
|
|
205
|
-
process: () => Promise<void>;
|
|
206
|
-
};
|
|
207
|
-
}
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import type { ServerWebSocket } from 'bun';
|
|
2
|
-
import type { WSTestClient, WSTestMessage } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* WebSocket testing utilities
|
|
5
|
-
*/
|
|
6
|
-
export declare class WebSocketTester {
|
|
7
|
-
private messages;
|
|
8
|
-
private isConnected;
|
|
9
|
-
private readyState;
|
|
10
|
-
private eventHandlers;
|
|
11
|
-
constructor();
|
|
12
|
-
private setupEventHandlers;
|
|
13
|
-
/**
|
|
14
|
-
* Simulate WebSocket connection
|
|
15
|
-
*/
|
|
16
|
-
connect(): WebSocketTester;
|
|
17
|
-
/**
|
|
18
|
-
* Simulate WebSocket disconnection
|
|
19
|
-
*/
|
|
20
|
-
disconnect(code?: number, reason?: string): WebSocketTester;
|
|
21
|
-
/**
|
|
22
|
-
* Simulate sending a message
|
|
23
|
-
*/
|
|
24
|
-
send(data: string | ArrayBuffer | Uint8Array): WebSocketTester;
|
|
25
|
-
/**
|
|
26
|
-
* Simulate receiving a message
|
|
27
|
-
*/
|
|
28
|
-
receive(data: string | ArrayBuffer | Uint8Array): WebSocketTester;
|
|
29
|
-
/**
|
|
30
|
-
* Simulate ping
|
|
31
|
-
*/
|
|
32
|
-
ping(data?: Uint8Array): WebSocketTester;
|
|
33
|
-
/**
|
|
34
|
-
* Simulate pong
|
|
35
|
-
*/
|
|
36
|
-
pong(data?: Uint8Array): WebSocketTester;
|
|
37
|
-
/**
|
|
38
|
-
* Add event listener
|
|
39
|
-
*/
|
|
40
|
-
on(event: string, handler: (...args: any[]) => any): WebSocketTester;
|
|
41
|
-
/**
|
|
42
|
-
* Remove event listener
|
|
43
|
-
*/
|
|
44
|
-
off(event: string, handler: (...args: any[]) => any): WebSocketTester;
|
|
45
|
-
/**
|
|
46
|
-
* Emit event
|
|
47
|
-
*/
|
|
48
|
-
private emit;
|
|
49
|
-
/**
|
|
50
|
-
* Get all sent messages
|
|
51
|
-
*/
|
|
52
|
-
getSentMessages(): WSTestMessage[];
|
|
53
|
-
/**
|
|
54
|
-
* Get messages of specific type
|
|
55
|
-
*/
|
|
56
|
-
getMessagesByType(type: 'text' | 'binary'): WSTestMessage[];
|
|
57
|
-
/**
|
|
58
|
-
* Clear message history
|
|
59
|
-
*/
|
|
60
|
-
clearMessages(): WebSocketTester;
|
|
61
|
-
/**
|
|
62
|
-
* Get connection state
|
|
63
|
-
*/
|
|
64
|
-
getState(): {
|
|
65
|
-
isConnected: boolean;
|
|
66
|
-
readyState: number;
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* Create a test client interface
|
|
70
|
-
*/
|
|
71
|
-
getTestClient(): WSTestClient;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Mock ServerWebSocket for testing
|
|
75
|
-
*/
|
|
76
|
-
export declare class MockServerWebSocket {
|
|
77
|
-
private tester;
|
|
78
|
-
private _data;
|
|
79
|
-
constructor(data?: any);
|
|
80
|
-
send(message: string | ArrayBuffer | Uint8Array): void;
|
|
81
|
-
close(code?: number, reason?: string): void;
|
|
82
|
-
ping(data?: Uint8Array): void;
|
|
83
|
-
pong(data?: Uint8Array): void;
|
|
84
|
-
publish(topic: string, message: string | ArrayBuffer | Uint8Array): void;
|
|
85
|
-
subscribe(_topic: string): void;
|
|
86
|
-
unsubscribe(_topic: string): void;
|
|
87
|
-
isSubscribed(_topic: string): boolean;
|
|
88
|
-
cork(callback: () => void): void;
|
|
89
|
-
get readyState(): number;
|
|
90
|
-
get data(): any;
|
|
91
|
-
set data(value: any);
|
|
92
|
-
getTester(): WebSocketTester;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* WebSocket handler testing utilities
|
|
96
|
-
*/
|
|
97
|
-
export declare const wsHandlerMocks: {
|
|
98
|
-
/**
|
|
99
|
-
* Mock WebSocket open handler
|
|
100
|
-
*/
|
|
101
|
-
onOpen: () => any;
|
|
102
|
-
/**
|
|
103
|
-
* Mock WebSocket message handler
|
|
104
|
-
*/
|
|
105
|
-
onMessage: (response?: string | ArrayBuffer | Uint8Array) => any;
|
|
106
|
-
/**
|
|
107
|
-
* Mock WebSocket close handler
|
|
108
|
-
*/
|
|
109
|
-
onClose: () => any;
|
|
110
|
-
/**
|
|
111
|
-
* Mock WebSocket error handler
|
|
112
|
-
*/
|
|
113
|
-
onError: () => any;
|
|
114
|
-
/**
|
|
115
|
-
* Mock echo handler
|
|
116
|
-
*/
|
|
117
|
-
echo: () => any;
|
|
118
|
-
/**
|
|
119
|
-
* Mock broadcast handler
|
|
120
|
-
*/
|
|
121
|
-
broadcast: (clients: ServerWebSocket<any>[]) => any;
|
|
122
|
-
/**
|
|
123
|
-
* Mock chat room handler
|
|
124
|
-
*/
|
|
125
|
-
chatRoom: (room: string) => any;
|
|
126
|
-
};
|
|
127
|
-
/**
|
|
128
|
-
* WebSocket test scenarios
|
|
129
|
-
*/
|
|
130
|
-
export declare const wsTestScenarios: {
|
|
131
|
-
/**
|
|
132
|
-
* Test basic connection and message exchange
|
|
133
|
-
*/
|
|
134
|
-
basicConnection: () => WebSocketTester;
|
|
135
|
-
/**
|
|
136
|
-
* Test connection failure
|
|
137
|
-
*/
|
|
138
|
-
connectionFailure: () => WebSocketTester;
|
|
139
|
-
/**
|
|
140
|
-
* Test message broadcasting
|
|
141
|
-
*/
|
|
142
|
-
messageBroadcast: (clientCount?: number) => WebSocketTester[];
|
|
143
|
-
/**
|
|
144
|
-
* Test ping/pong mechanism
|
|
145
|
-
*/
|
|
146
|
-
pingPong: () => WebSocketTester;
|
|
147
|
-
/**
|
|
148
|
-
* Test connection timeout
|
|
149
|
-
*/
|
|
150
|
-
connectionTimeout: () => WebSocketTester;
|
|
151
|
-
};
|
|
152
|
-
/**
|
|
153
|
-
* WebSocket assertion helpers
|
|
154
|
-
*/
|
|
155
|
-
export declare const wsAssertions: {
|
|
156
|
-
/**
|
|
157
|
-
* Assert WebSocket is connected
|
|
158
|
-
*/
|
|
159
|
-
isConnected: (tester: WebSocketTester) => void;
|
|
160
|
-
/**
|
|
161
|
-
* Assert WebSocket is disconnected
|
|
162
|
-
*/
|
|
163
|
-
isDisconnected: (tester: WebSocketTester) => void;
|
|
164
|
-
/**
|
|
165
|
-
* Assert message was sent
|
|
166
|
-
*/
|
|
167
|
-
messageSent: (tester: WebSocketTester, expectedMessage: string | ArrayBuffer | Uint8Array) => void;
|
|
168
|
-
/**
|
|
169
|
-
* Assert number of messages sent
|
|
170
|
-
*/
|
|
171
|
-
messageCount: (tester: WebSocketTester, expectedCount: number) => void;
|
|
172
|
-
/**
|
|
173
|
-
* Assert message type
|
|
174
|
-
*/
|
|
175
|
-
messageType: (tester: WebSocketTester, index: number, expectedType: "text" | "binary") => void;
|
|
176
|
-
/**
|
|
177
|
-
* Assert ready state
|
|
178
|
-
*/
|
|
179
|
-
readyState: (tester: WebSocketTester, expectedState: number) => void;
|
|
180
|
-
};
|
|
181
|
-
/**
|
|
182
|
-
* WebSocket performance testing
|
|
183
|
-
*/
|
|
184
|
-
export declare const wsPerformance: {
|
|
185
|
-
/**
|
|
186
|
-
* Test message throughput
|
|
187
|
-
*/
|
|
188
|
-
testThroughput: (messageCount?: number, messageSize?: number) => Promise<{
|
|
189
|
-
messagesPerSecond: number;
|
|
190
|
-
totalTime: number;
|
|
191
|
-
averageLatency: number;
|
|
192
|
-
}>;
|
|
193
|
-
/**
|
|
194
|
-
* Test concurrent connections
|
|
195
|
-
*/
|
|
196
|
-
testConcurrentConnections: (connectionCount?: number) => Promise<{
|
|
197
|
-
successfulConnections: number;
|
|
198
|
-
failedConnections: number;
|
|
199
|
-
averageConnectionTime: number;
|
|
200
|
-
}>;
|
|
201
|
-
};
|
|
202
|
-
/**
|
|
203
|
-
* Factory functions
|
|
204
|
-
*/
|
|
205
|
-
export declare function createWebSocketTester(): WebSocketTester;
|
|
206
|
-
export declare function createMockServerWebSocket(data?: any): MockServerWebSocket;
|
|
207
|
-
/**
|
|
208
|
-
* WebSocket test utilities
|
|
209
|
-
*/
|
|
210
|
-
export declare const wsTestUtils: {
|
|
211
|
-
/**
|
|
212
|
-
* Create multiple connected clients
|
|
213
|
-
*/
|
|
214
|
-
createClients: (count: number) => WebSocketTester[];
|
|
215
|
-
/**
|
|
216
|
-
* Simulate network latency
|
|
217
|
-
*/
|
|
218
|
-
withLatency: (tester: WebSocketTester, latencyMs: number) => WebSocketTester;
|
|
219
|
-
/**
|
|
220
|
-
* Simulate packet loss
|
|
221
|
-
*/
|
|
222
|
-
withPacketLoss: (tester: WebSocketTester, lossRate: number) => WebSocketTester;
|
|
223
|
-
/**
|
|
224
|
-
* Create message generator
|
|
225
|
-
*/
|
|
226
|
-
messageGenerator(count: number, prefix?: string): Generator<string>;
|
|
227
|
-
};
|