@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
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import type { EnhancedRequest, RequestInput, } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Create a safe data wrapper
|
|
4
|
-
*/
|
|
5
|
-
export declare function createSafeData<T extends Record<string, unknown>>(data: T): SafeData<T>;
|
|
6
|
-
/**
|
|
7
|
-
* Enhance request with additional methods
|
|
8
|
-
*/
|
|
9
|
-
export declare function enhanceRequestWithMethods(request: EnhancedRequest): EnhancedRequest & EnhancedRequestMethods;
|
|
10
|
-
/**
|
|
11
|
-
* Middleware to enhance request with additional methods
|
|
12
|
-
*/
|
|
13
|
-
export declare function enhancedRequestMiddleware(): void;
|
|
14
|
-
/**
|
|
15
|
-
* Validation rule interface
|
|
16
|
-
*/
|
|
17
|
-
export declare interface ValidationRule {
|
|
18
|
-
name: string
|
|
19
|
-
validate: (value: unknown, parameters: string[], field: string, data: Record<string, unknown>) => Promise<boolean> | boolean
|
|
20
|
-
message: string | ((field: string, parameters: string[]) => string)
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Safe validated data wrapper
|
|
24
|
-
*/
|
|
25
|
-
export declare interface SafeData<T extends Record<string, unknown> = Record<string, unknown>> {
|
|
26
|
-
only: <K extends keyof T>(keys: K[]) => Pick<T, K>
|
|
27
|
-
except: <K extends keyof T>(keys: K[]) => Omit<T, K>
|
|
28
|
-
merge: <U extends Record<string, unknown>>(data: U) => T & U
|
|
29
|
-
all: () => T
|
|
30
|
-
has: (key: keyof T) => boolean
|
|
31
|
-
get: <K extends keyof T>(key: K) => T[K]
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Collection interface for array data
|
|
35
|
-
*/
|
|
36
|
-
export declare interface Collection<T> {
|
|
37
|
-
items: T[]
|
|
38
|
-
count: () => number
|
|
39
|
-
first: () => T | undefined
|
|
40
|
-
last: () => T | undefined
|
|
41
|
-
map: <U>(fn: (item: T, index: number) => U) => Collection<U>
|
|
42
|
-
filter: (fn: (item: T, index: number) => boolean) => Collection<T>
|
|
43
|
-
find: (fn: (item: T, index: number) => boolean) => T | undefined
|
|
44
|
-
reduce: <U>(fn: (acc: U, item: T, index: number) => U, initial: U) => U
|
|
45
|
-
forEach: (fn: (item: T, index: number) => void) => void
|
|
46
|
-
toArray: () => T[]
|
|
47
|
-
isEmpty: () => boolean
|
|
48
|
-
isNotEmpty: () => boolean
|
|
49
|
-
pluck: <K extends keyof T>(key: K) => Collection<T[K]>
|
|
50
|
-
unique: () => Collection<T>
|
|
51
|
-
sortBy: <K extends keyof T>(key: K, direction?: 'asc' | 'desc') => Collection<T>
|
|
52
|
-
groupBy: <K extends keyof T>(key: K) => Map<T[K], Collection<T>>
|
|
53
|
-
chunk: (size: number) => Collection<Collection<T>>
|
|
54
|
-
take: (count: number) => Collection<T>
|
|
55
|
-
skip: (count: number) => Collection<T>
|
|
56
|
-
reverse: () => Collection<T>
|
|
57
|
-
sum: (key?: keyof T) => number
|
|
58
|
-
avg: (key?: keyof T) => number
|
|
59
|
-
min: (key?: keyof T) => T | undefined
|
|
60
|
-
max: (key?: keyof T) => T | undefined
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Enhanced request methods interface
|
|
64
|
-
*/
|
|
65
|
-
export declare interface EnhancedRequestMethods {
|
|
66
|
-
validate: <T extends Record<string, unknown> = Record<string, unknown>>(
|
|
67
|
-
rules: ValidationRules,
|
|
68
|
-
messages?: Record<string, string>,
|
|
69
|
-
) => Promise<T>
|
|
70
|
-
getValidated: <T extends Record<string, unknown> = Record<string, unknown>>() => T
|
|
71
|
-
safe: <T extends Record<string, unknown> = Record<string, unknown>>() => SafeData<T>
|
|
72
|
-
whenHas: <T>(
|
|
73
|
-
key: string,
|
|
74
|
-
callback: (value: T) => void,
|
|
75
|
-
defaultCallback?: () => void,
|
|
76
|
-
) => void
|
|
77
|
-
whenFilled: <T>(
|
|
78
|
-
key: string,
|
|
79
|
-
callback: (value: T) => void,
|
|
80
|
-
defaultCallback?: () => void,
|
|
81
|
-
) => void
|
|
82
|
-
date: (key: string, format?: string) => Date | null
|
|
83
|
-
enum: <T extends Record<string, string | number>>(
|
|
84
|
-
key: string,
|
|
85
|
-
enumType: T,
|
|
86
|
-
) => T[keyof T] | null
|
|
87
|
-
collect: <T = unknown>(key: string) => Collection<T>
|
|
88
|
-
keys: () => string[]
|
|
89
|
-
string: (key: string, defaultValue?: string) => string
|
|
90
|
-
integer: (key: string, defaultValue?: number) => number
|
|
91
|
-
float: (key: string, defaultValue?: number) => number
|
|
92
|
-
boolean: (key: string, defaultValue?: boolean) => boolean
|
|
93
|
-
isValue: (key: string, value: unknown) => boolean
|
|
94
|
-
old: <T = unknown>(key: string, defaultValue?: T) => T
|
|
95
|
-
flashInput: (keys?: string[]) => void
|
|
96
|
-
flashInputOnly: (keys: string[]) => void
|
|
97
|
-
flashInputExcept: (keys: string[]) => void
|
|
98
|
-
array: <T = unknown>(key: string) => T[]
|
|
99
|
-
get: <T = unknown>(key: string, defaultValue?: T) => T
|
|
100
|
-
all: () => RequestInput
|
|
101
|
-
only: <T extends Record<string, unknown> = Record<string, unknown>>(keys: string[]) => T
|
|
102
|
-
except: <T extends Record<string, unknown> = Record<string, unknown>>(keys: string[]) => T
|
|
103
|
-
has: (key: string | string[]) => boolean
|
|
104
|
-
hasAny: (keys: string[]) => boolean
|
|
105
|
-
filled: (key: string | string[]) => boolean
|
|
106
|
-
missing: (key: string | string[]) => boolean
|
|
107
|
-
merge: (data: Record<string, unknown>) => void
|
|
108
|
-
input: <T = unknown>(key: string, defaultValue?: T) => T
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Validation rules type
|
|
112
|
-
*/
|
|
113
|
-
export type ValidationRules = Record<string, string | ValidationRule[]>
|
|
114
|
-
/**
|
|
115
|
-
* Collection class for array manipulation
|
|
116
|
-
*/
|
|
117
|
-
export declare class CollectionImpl<T> implements Collection<T> {
|
|
118
|
-
items: T[];
|
|
119
|
-
constructor(items: T[]);
|
|
120
|
-
count(): number;
|
|
121
|
-
first(): T | undefined;
|
|
122
|
-
last(): T | undefined;
|
|
123
|
-
map<U>(fn: (item: T, index: number) => U): Collection<U>;
|
|
124
|
-
filter(fn: (item: T, index: number) => boolean): Collection<T>;
|
|
125
|
-
find(fn: (item: T, index: number) => boolean): T | undefined;
|
|
126
|
-
reduce<U>(fn: (acc: U, item: T, index: number) => U, initial: U): U;
|
|
127
|
-
forEach(fn: (item: T, index: number) => void): void;
|
|
128
|
-
toArray(): T[];
|
|
129
|
-
isEmpty(): boolean;
|
|
130
|
-
isNotEmpty(): boolean;
|
|
131
|
-
pluck<K extends keyof T>(key: K): Collection<T[K]>;
|
|
132
|
-
unique(): Collection<T>;
|
|
133
|
-
sortBy<K extends keyof T>(key: K, direction?: 'asc' | 'desc'): Collection<T>;
|
|
134
|
-
groupBy<K extends keyof T>(key: K): Map<T[K], Collection<T>>;
|
|
135
|
-
chunk(size: number): Collection<Collection<T>>;
|
|
136
|
-
take(count: number): Collection<T>;
|
|
137
|
-
skip(count: number): Collection<T>;
|
|
138
|
-
reverse(): Collection<T>;
|
|
139
|
-
sum(key?: keyof T): number;
|
|
140
|
-
avg(key?: keyof T): number;
|
|
141
|
-
min(key?: keyof T): T | undefined;
|
|
142
|
-
max(key?: keyof T): T | undefined;
|
|
143
|
-
}
|
package/dist/request/macros.d.ts
DELETED
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
import type { EnhancedRequest } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Register all built-in macros
|
|
4
|
-
*/
|
|
5
|
-
export declare function registerBuiltInRequestMacros(): void;
|
|
6
|
-
/**
|
|
7
|
-
* Global request macro registry
|
|
8
|
-
*/
|
|
9
|
-
export declare const requestMacroRegistry: RequestMacroRegistry;
|
|
10
|
-
/**
|
|
11
|
-
* Built-in request macros
|
|
12
|
-
*/
|
|
13
|
-
export declare const BuiltInRequestMacros: {
|
|
14
|
-
/**
|
|
15
|
-
* Check if request wants JSON response
|
|
16
|
-
*/
|
|
17
|
-
wantsJson(this: EnhancedRequest): unknown;
|
|
18
|
-
/**
|
|
19
|
-
* Check if request wants HTML response
|
|
20
|
-
*/
|
|
21
|
-
wantsHtml(this: EnhancedRequest): unknown;
|
|
22
|
-
/**
|
|
23
|
-
* Check if request wants XML response
|
|
24
|
-
*/
|
|
25
|
-
wantsXml(this: EnhancedRequest): unknown;
|
|
26
|
-
/**
|
|
27
|
-
* Check if request expects JSON response
|
|
28
|
-
*/
|
|
29
|
-
expectsJson(this: EnhancedRequest): unknown;
|
|
30
|
-
/**
|
|
31
|
-
* Check if request is AJAX
|
|
32
|
-
*/
|
|
33
|
-
isAjax(this: EnhancedRequest): unknown;
|
|
34
|
-
/**
|
|
35
|
-
* Check if request is PJAX
|
|
36
|
-
*/
|
|
37
|
-
isPjax(this: EnhancedRequest): unknown;
|
|
38
|
-
/**
|
|
39
|
-
* Check if request is from mobile device
|
|
40
|
-
*/
|
|
41
|
-
isMobile(this: EnhancedRequest): unknown;
|
|
42
|
-
/**
|
|
43
|
-
* Check if request is from bot/crawler
|
|
44
|
-
*/
|
|
45
|
-
isBot(this: EnhancedRequest): unknown;
|
|
46
|
-
/**
|
|
47
|
-
* Check if request is secure (HTTPS)
|
|
48
|
-
*/
|
|
49
|
-
isSecure(this: EnhancedRequest): unknown;
|
|
50
|
-
/**
|
|
51
|
-
* Get client IP address
|
|
52
|
-
*/
|
|
53
|
-
ip(this: EnhancedRequest): unknown;
|
|
54
|
-
/**
|
|
55
|
-
* Get all client IPs (including proxies)
|
|
56
|
-
*/
|
|
57
|
-
ips(this: EnhancedRequest): unknown;
|
|
58
|
-
/**
|
|
59
|
-
* Get user agent
|
|
60
|
-
*/
|
|
61
|
-
userAgent(this: EnhancedRequest): unknown;
|
|
62
|
-
/**
|
|
63
|
-
* Get referer URL
|
|
64
|
-
*/
|
|
65
|
-
referer(this: EnhancedRequest): unknown;
|
|
66
|
-
/**
|
|
67
|
-
* Get authorization header
|
|
68
|
-
*/
|
|
69
|
-
bearerToken(this: EnhancedRequest): unknown;
|
|
70
|
-
/**
|
|
71
|
-
* Get basic auth credentials
|
|
72
|
-
*/
|
|
73
|
-
basicAuth(this: EnhancedRequest): {
|
|
74
|
-
username: unknown;
|
|
75
|
-
password: unknown
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* Check if request has specific header
|
|
79
|
-
*/
|
|
80
|
-
hasHeader(this: EnhancedRequest, name: string): unknown;
|
|
81
|
-
/**
|
|
82
|
-
* Get header value with default
|
|
83
|
-
*/
|
|
84
|
-
header(this: EnhancedRequest, name: string, defaultValue?: string): unknown;
|
|
85
|
-
/**
|
|
86
|
-
* Get all headers as object
|
|
87
|
-
*/
|
|
88
|
-
allHeaders(this: EnhancedRequest): unknown;
|
|
89
|
-
/**
|
|
90
|
-
* Get input value from query, body, or params
|
|
91
|
-
*/
|
|
92
|
-
input(this: EnhancedRequest, key: string, defaultValue?: any): unknown;
|
|
93
|
-
/**
|
|
94
|
-
* Get all input data
|
|
95
|
-
*/
|
|
96
|
-
all(this: EnhancedRequest): unknown;
|
|
97
|
-
/**
|
|
98
|
-
* Get only specified input keys
|
|
99
|
-
*/
|
|
100
|
-
only(this: EnhancedRequest, keys: string[]): unknown;
|
|
101
|
-
/**
|
|
102
|
-
* Get all input except specified keys
|
|
103
|
-
*/
|
|
104
|
-
except(this: EnhancedRequest, keys: string[]): unknown;
|
|
105
|
-
/**
|
|
106
|
-
* Check if input has specific key
|
|
107
|
-
*/
|
|
108
|
-
has(this: EnhancedRequest, key: string): unknown;
|
|
109
|
-
/**
|
|
110
|
-
* Check if input has any of the specified keys
|
|
111
|
-
*/
|
|
112
|
-
hasAny(this: EnhancedRequest, keys: string[]): unknown;
|
|
113
|
-
/**
|
|
114
|
-
* Check if input is missing specific key
|
|
115
|
-
*/
|
|
116
|
-
missing(this: EnhancedRequest, key: string): unknown;
|
|
117
|
-
/**
|
|
118
|
-
* Check if input is filled (not empty)
|
|
119
|
-
*/
|
|
120
|
-
filled(this: EnhancedRequest, key: string): unknown;
|
|
121
|
-
/**
|
|
122
|
-
* Get query parameter
|
|
123
|
-
*/
|
|
124
|
-
getQuery(this: EnhancedRequest, key?: string, defaultValue?: any): unknown;
|
|
125
|
-
/**
|
|
126
|
-
* Get route parameter
|
|
127
|
-
*/
|
|
128
|
-
param(this: EnhancedRequest, key: string, defaultValue?: any): unknown;
|
|
129
|
-
/**
|
|
130
|
-
* Get cookie value
|
|
131
|
-
*/
|
|
132
|
-
cookie(this: EnhancedRequest, name: string, defaultValue?: string): unknown;
|
|
133
|
-
/**
|
|
134
|
-
* Get all cookies
|
|
135
|
-
*/
|
|
136
|
-
cookies(this: EnhancedRequest): unknown;
|
|
137
|
-
/**
|
|
138
|
-
* Get file from upload
|
|
139
|
-
*/
|
|
140
|
-
file(this: EnhancedRequest, name: string): unknown;
|
|
141
|
-
/**
|
|
142
|
-
* Check if request has file upload
|
|
143
|
-
*/
|
|
144
|
-
hasFile(this: EnhancedRequest, name: string): unknown;
|
|
145
|
-
/**
|
|
146
|
-
* Get request path without query string
|
|
147
|
-
*/
|
|
148
|
-
path(this: EnhancedRequest): unknown;
|
|
149
|
-
/**
|
|
150
|
-
* Get request URL
|
|
151
|
-
*/
|
|
152
|
-
fullUrl(this: EnhancedRequest): unknown;
|
|
153
|
-
/**
|
|
154
|
-
* Get request root URL
|
|
155
|
-
*/
|
|
156
|
-
root(this: EnhancedRequest): unknown;
|
|
157
|
-
/**
|
|
158
|
-
* Check if path matches pattern
|
|
159
|
-
*/
|
|
160
|
-
is(this: EnhancedRequest, pattern: string): unknown;
|
|
161
|
-
/**
|
|
162
|
-
* Get route name (if available)
|
|
163
|
-
*/
|
|
164
|
-
route(this: EnhancedRequest): unknown;
|
|
165
|
-
/**
|
|
166
|
-
* Get request fingerprint for caching
|
|
167
|
-
*/
|
|
168
|
-
fingerprint(this: EnhancedRequest): unknown;
|
|
169
|
-
/**
|
|
170
|
-
* Get request signature for security
|
|
171
|
-
*/
|
|
172
|
-
signature(this: EnhancedRequest, secret: string): unknown;
|
|
173
|
-
/**
|
|
174
|
-
* Merge additional data into request
|
|
175
|
-
*/
|
|
176
|
-
merge(this: EnhancedRequest, data: Record<string, any>): unknown;
|
|
177
|
-
/**
|
|
178
|
-
* Replace request data
|
|
179
|
-
*/
|
|
180
|
-
replace(this: EnhancedRequest, data: Record<string, any>): unknown;
|
|
181
|
-
/**
|
|
182
|
-
* Get request age in milliseconds
|
|
183
|
-
*/
|
|
184
|
-
age(this: EnhancedRequest): unknown;
|
|
185
|
-
/**
|
|
186
|
-
* Check if request is from trusted proxy
|
|
187
|
-
*/
|
|
188
|
-
isFromTrustedProxy(this: EnhancedRequest, trustedProxies: string[] = []): unknown;
|
|
189
|
-
/**
|
|
190
|
-
* Get request content length
|
|
191
|
-
*/
|
|
192
|
-
contentLength(this: EnhancedRequest): unknown;
|
|
193
|
-
/**
|
|
194
|
-
* Get request content type
|
|
195
|
-
*/
|
|
196
|
-
contentType(this: EnhancedRequest): unknown;
|
|
197
|
-
/**
|
|
198
|
-
* Check if request content type matches
|
|
199
|
-
*/
|
|
200
|
-
isContentType(this: EnhancedRequest, type: string): unknown
|
|
201
|
-
};
|
|
202
|
-
/**
|
|
203
|
-
* Request macro factory functions
|
|
204
|
-
*/
|
|
205
|
-
export declare const RequestMacroFactory: {
|
|
206
|
-
/**
|
|
207
|
-
* Create input validation macro
|
|
208
|
-
*/
|
|
209
|
-
validateInput: (_rules: Record<string, string>) => unknown;
|
|
210
|
-
/**
|
|
211
|
-
* Create custom header checker macro
|
|
212
|
-
*/
|
|
213
|
-
hasCustomHeader: (headerName: string) => unknown;
|
|
214
|
-
/**
|
|
215
|
-
* Create role checker macro
|
|
216
|
-
*/
|
|
217
|
-
hasRole: (role: string) => unknown;
|
|
218
|
-
/**
|
|
219
|
-
* Create permission checker macro
|
|
220
|
-
*/
|
|
221
|
-
can: (permission: string) => unknown
|
|
222
|
-
};
|
|
223
|
-
/**
|
|
224
|
-
* Request helper utilities
|
|
225
|
-
*/
|
|
226
|
-
export declare const RequestHelpers: {
|
|
227
|
-
/**
|
|
228
|
-
* Apply macros to request
|
|
229
|
-
*/
|
|
230
|
-
withMacros: (request: EnhancedRequest) => any;
|
|
231
|
-
/**
|
|
232
|
-
* Create request from URL and options
|
|
233
|
-
*/
|
|
234
|
-
create: (url: string, options: RequestInit?) => any;
|
|
235
|
-
/**
|
|
236
|
-
* Parse query string to object
|
|
237
|
-
*/
|
|
238
|
-
parseQuery: (queryString: string) => unknown;
|
|
239
|
-
/**
|
|
240
|
-
* Parse cookies from header
|
|
241
|
-
*/
|
|
242
|
-
parseCookies: (cookieHeader: string) => unknown
|
|
243
|
-
};
|
|
244
|
-
export declare interface RequestMacro {
|
|
245
|
-
name: string
|
|
246
|
-
handler: (this: EnhancedRequest, ...args: any[]) => any
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Request macro registry
|
|
250
|
-
*/
|
|
251
|
-
declare class RequestMacroRegistry {
|
|
252
|
-
private macros: Map<string, RequestMacro>;
|
|
253
|
-
register(name: string, handler: (this: EnhancedRequest, ...args: any[]) => any): void;
|
|
254
|
-
get(name: string): RequestMacro | undefined;
|
|
255
|
-
has(name: string): boolean;
|
|
256
|
-
all(): RequestMacro[];
|
|
257
|
-
remove(name: string): boolean;
|
|
258
|
-
clear(): void;
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* Request class with macro support
|
|
262
|
-
*/
|
|
263
|
-
export declare class RequestWithMacros {
|
|
264
|
-
static macro(name: string, handler: (this: EnhancedRequest, ...args: any[]) => any): void;
|
|
265
|
-
static applyMacros(request: EnhancedRequest): EnhancedRequest;
|
|
266
|
-
static hasMacro(name: string): boolean;
|
|
267
|
-
}
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Register all built-in macros
|
|
3
|
-
*/
|
|
4
|
-
export declare function registerBuiltInResponseMacros(): void;
|
|
5
|
-
/**
|
|
6
|
-
* Global response macro registry
|
|
7
|
-
*/
|
|
8
|
-
export declare const responseMacroRegistry: ResponseMacroRegistry;
|
|
9
|
-
/**
|
|
10
|
-
* Built-in response macros
|
|
11
|
-
*/
|
|
12
|
-
export declare const BuiltInResponseMacros: {
|
|
13
|
-
/**
|
|
14
|
-
* Success response with data
|
|
15
|
-
*/
|
|
16
|
-
success: (data?: any, message?: string, status?) => any;
|
|
17
|
-
/**
|
|
18
|
-
* Error response with message and errors
|
|
19
|
-
*/
|
|
20
|
-
error: (message: string, errors?: Record<string, string[]>, status?) => any;
|
|
21
|
-
/**
|
|
22
|
-
* Validation error response
|
|
23
|
-
*/
|
|
24
|
-
validationError: (errors: Record<string, string[]>, message?) => any;
|
|
25
|
-
/**
|
|
26
|
-
* Not found response
|
|
27
|
-
*/
|
|
28
|
-
notFound: (message?) => any;
|
|
29
|
-
/**
|
|
30
|
-
* Unauthorized response
|
|
31
|
-
*/
|
|
32
|
-
unauthorized: (message?) => any;
|
|
33
|
-
/**
|
|
34
|
-
* Forbidden response
|
|
35
|
-
*/
|
|
36
|
-
forbidden: (message?) => any;
|
|
37
|
-
/**
|
|
38
|
-
* Internal server error response
|
|
39
|
-
*/
|
|
40
|
-
serverError: (message?) => any;
|
|
41
|
-
/**
|
|
42
|
-
* Created response
|
|
43
|
-
*/
|
|
44
|
-
created: (data?: any, message?) => any;
|
|
45
|
-
/**
|
|
46
|
-
* Updated response
|
|
47
|
-
*/
|
|
48
|
-
updated: (data?: any, message?) => any;
|
|
49
|
-
/**
|
|
50
|
-
* Deleted response
|
|
51
|
-
*/
|
|
52
|
-
deleted: (message?) => any;
|
|
53
|
-
/**
|
|
54
|
-
* No content response
|
|
55
|
-
*/
|
|
56
|
-
noContent: () => any;
|
|
57
|
-
/**
|
|
58
|
-
* Accepted response
|
|
59
|
-
*/
|
|
60
|
-
accepted: (data?: any, message?) => any;
|
|
61
|
-
/**
|
|
62
|
-
* Paginated response
|
|
63
|
-
*/
|
|
64
|
-
paginated: unknown;
|
|
65
|
-
/**
|
|
66
|
-
* JSON response with custom headers
|
|
67
|
-
*/
|
|
68
|
-
json: (data: any, status?, headers: Record<string, string> = {}) => any;
|
|
69
|
-
/**
|
|
70
|
-
* HTML response
|
|
71
|
-
*/
|
|
72
|
-
html: (content: string, status?, headers: Record<string, string> = {}) => any;
|
|
73
|
-
/**
|
|
74
|
-
* Plain text response
|
|
75
|
-
*/
|
|
76
|
-
text: (content: string, status?, headers: Record<string, string> = {}) => any;
|
|
77
|
-
/**
|
|
78
|
-
* XML response
|
|
79
|
-
*/
|
|
80
|
-
xml: (content: string, status?, headers: Record<string, string> = {}) => any;
|
|
81
|
-
/**
|
|
82
|
-
* Redirect response
|
|
83
|
-
*/
|
|
84
|
-
redirect: (url: string, status?) => any;
|
|
85
|
-
/**
|
|
86
|
-
* Permanent redirect response
|
|
87
|
-
*/
|
|
88
|
-
permanentRedirect: (url: string) => any;
|
|
89
|
-
/**
|
|
90
|
-
* Download response
|
|
91
|
-
*/
|
|
92
|
-
download: ( data: ArrayBuffer | Uint8Array | string, filename: string, contentType?, ) => any;
|
|
93
|
-
/**
|
|
94
|
-
* Stream response
|
|
95
|
-
*/
|
|
96
|
-
stream: ( stream: ReadableStream, contentType?, headers: Record<string, string> = {}, ) => any;
|
|
97
|
-
/**
|
|
98
|
-
* Cache response with headers
|
|
99
|
-
*/
|
|
100
|
-
cache: ( data: any, maxAge?, isPublic?, etag?: string, ) => any;
|
|
101
|
-
/**
|
|
102
|
-
* CORS response
|
|
103
|
-
*/
|
|
104
|
-
cors: ( data: any, origin?, methods?,POST,PUT,DELETE,OPTIONS', headers?,Authorization', ) => any;
|
|
105
|
-
/**
|
|
106
|
-
* Server-Sent Events response
|
|
107
|
-
*/
|
|
108
|
-
sse: (data: string, event?: string, id?: string) => any;
|
|
109
|
-
/**
|
|
110
|
-
* Health check response
|
|
111
|
-
*/
|
|
112
|
-
health: (status: 'healthy' | 'unhealthy' | 'degraded' = 'healthy', checks: Record<string, any> = {}) => any
|
|
113
|
-
};
|
|
114
|
-
/**
|
|
115
|
-
* Response macro factory functions
|
|
116
|
-
*/
|
|
117
|
-
export declare const ResponseMacroFactory: {
|
|
118
|
-
/**
|
|
119
|
-
* Create API response macro
|
|
120
|
-
*/
|
|
121
|
-
api: (defaultMeta?: Record<string, any>) => unknown;
|
|
122
|
-
/**
|
|
123
|
-
* Create versioned API response macro
|
|
124
|
-
*/
|
|
125
|
-
versionedApi: (version: string) => unknown;
|
|
126
|
-
/**
|
|
127
|
-
* Create custom error response macro
|
|
128
|
-
*/
|
|
129
|
-
customError: (defaultStatus: number?, defaultMessage: string?) => (message?: string, errors?: Record<string, string[]>, status?: number) => any
|
|
130
|
-
};
|
|
131
|
-
/**
|
|
132
|
-
* Response helper utilities
|
|
133
|
-
*/
|
|
134
|
-
export declare const ResponseHelpers: {
|
|
135
|
-
/**
|
|
136
|
-
* Check if response is successful
|
|
137
|
-
*/
|
|
138
|
-
isSuccess: (response: Response) => any;
|
|
139
|
-
/**
|
|
140
|
-
* Check if response is error
|
|
141
|
-
*/
|
|
142
|
-
isError: (response: Response) => any;
|
|
143
|
-
/**
|
|
144
|
-
* Get response body as JSON
|
|
145
|
-
*/
|
|
146
|
-
getJson: (response: Response) => Promise<any>;
|
|
147
|
-
/**
|
|
148
|
-
* Get response body as text
|
|
149
|
-
*/
|
|
150
|
-
getText: (response: Response) => Promise<string>;
|
|
151
|
-
/**
|
|
152
|
-
* Clone response with new headers
|
|
153
|
-
*/
|
|
154
|
-
withHeaders: (response: Response, headers: Record<string, string>) => any;
|
|
155
|
-
/**
|
|
156
|
-
* Clone response with new status
|
|
157
|
-
*/
|
|
158
|
-
withStatus: (response: Response, status: number, statusText?: string) => any
|
|
159
|
-
};
|
|
160
|
-
export declare interface ResponseMacro {
|
|
161
|
-
name: string
|
|
162
|
-
handler: (...args: any[]) => Response
|
|
163
|
-
}
|
|
164
|
-
export declare interface ApiResponse<T = any> {
|
|
165
|
-
data?: T
|
|
166
|
-
message?: string
|
|
167
|
-
error?: string
|
|
168
|
-
errors?: Record<string, string[]>
|
|
169
|
-
meta?: Record<string, any>
|
|
170
|
-
links?: Record<string, string>
|
|
171
|
-
timestamp?: string
|
|
172
|
-
}
|
|
173
|
-
export declare interface PaginatedResponse<T = any> extends ApiResponse<T[]> {
|
|
174
|
-
meta: {
|
|
175
|
-
current_page: number
|
|
176
|
-
per_page: number
|
|
177
|
-
total: number
|
|
178
|
-
last_page: number
|
|
179
|
-
from: number
|
|
180
|
-
to: number
|
|
181
|
-
path: string
|
|
182
|
-
first_page_url: string
|
|
183
|
-
last_page_url: string
|
|
184
|
-
next_page_url?: string
|
|
185
|
-
prev_page_url?: string
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Response macro registry
|
|
190
|
-
*/
|
|
191
|
-
declare class ResponseMacroRegistry {
|
|
192
|
-
private macros: Map<string, ResponseMacro>;
|
|
193
|
-
register(name: string, handler: (...args: any[]) => Response): void;
|
|
194
|
-
get(name: string): ResponseMacro | undefined;
|
|
195
|
-
has(name: string): boolean;
|
|
196
|
-
all(): ResponseMacro[];
|
|
197
|
-
remove(name: string): boolean;
|
|
198
|
-
clear(): void;
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Response class with macro support
|
|
202
|
-
*/
|
|
203
|
-
export declare class ResponseWithMacros extends Response {
|
|
204
|
-
static macro(name: string, handler: (...args: any[]) => Response): void;
|
|
205
|
-
static callMacro(name: string, args: any[]): Response;
|
|
206
|
-
static hasMacro(name: string): boolean;
|
|
207
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import type { ContentType, ResponseStatus } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Create a new response builder
|
|
4
|
-
*/
|
|
5
|
-
export declare function responseBuilder(): ResponseBuilder;
|
|
6
|
-
/**
|
|
7
|
-
* Response factory with common response helpers
|
|
8
|
-
*/
|
|
9
|
-
export declare const response: ResponseFactory;
|
|
10
|
-
/**
|
|
11
|
-
* JSON response options
|
|
12
|
-
*/
|
|
13
|
-
export declare interface JsonResponseOptions {
|
|
14
|
-
status?: ResponseStatus
|
|
15
|
-
headers?: Record<string, string>
|
|
16
|
-
pretty?: boolean
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Download response options
|
|
20
|
-
*/
|
|
21
|
-
export declare interface DownloadOptions {
|
|
22
|
-
filename?: string
|
|
23
|
-
headers?: Record<string, string>
|
|
24
|
-
disposition?: 'attachment' | 'inline'
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Stream download options
|
|
28
|
-
*/
|
|
29
|
-
export declare interface StreamDownloadOptions extends DownloadOptions {
|
|
30
|
-
contentType?: ContentType
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Cookie options for response
|
|
34
|
-
*/
|
|
35
|
-
export declare interface ResponseCookieOptions {
|
|
36
|
-
maxAge?: number
|
|
37
|
-
expires?: Date
|
|
38
|
-
httpOnly?: boolean
|
|
39
|
-
secure?: boolean
|
|
40
|
-
path?: string
|
|
41
|
-
domain?: string
|
|
42
|
-
sameSite?: 'strict' | 'lax' | 'none'
|
|
43
|
-
}
|
|
44
|
-
// ============================================================================
|
|
45
|
-
// Response Factory Interface
|
|
46
|
-
// ============================================================================
|
|
47
|
-
export declare interface ResponseFactory {
|
|
48
|
-
json: <T>(data: T, options?: JsonResponseOptions) => Response
|
|
49
|
-
noContent: (headers?: Record<string, string>) => Response
|
|
50
|
-
download: (filePath: string, filename?: string, headers?: Record<string, string>) => Promise<Response>
|
|
51
|
-
file: (filePath: string, headers?: Record<string, string>) => Promise<Response>
|
|
52
|
-
streamDownload: (generator: () => AsyncGenerator<string | Uint8Array, void, unknown>, filename: string, options?: StreamDownloadOptions) => Response
|
|
53
|
-
redirect: (url: string, status?: 301 | 302 | 303 | 307 | 308) => Response
|
|
54
|
-
redirectPermanent: (url: string) => Response
|
|
55
|
-
redirectTemporary: (url: string) => Response
|
|
56
|
-
back: (request: Request, fallback?: string) => Response
|
|
57
|
-
view: (html: string, status?: ResponseStatus, headers?: Record<string, string>) => Response
|
|
58
|
-
text: (text: string, status?: ResponseStatus, headers?: Record<string, string>) => Response
|
|
59
|
-
xml: (xml: string, status?: ResponseStatus, headers?: Record<string, string>) => Response
|
|
60
|
-
success: <T>(data?: T, message?: string, status?: ResponseStatus) => Response
|
|
61
|
-
error: (message: string, status?: ResponseStatus, errors?: Record<string, string[]>) => Response
|
|
62
|
-
paginate: <T>(data: T[], options: { page: number, perPage: number, total: number, path: string }) => Response
|
|
63
|
-
created: <T>(data?: T, location?: string) => Response
|
|
64
|
-
accepted: <T>(data?: T) => Response
|
|
65
|
-
notFound: (message?: string) => Response
|
|
66
|
-
unauthorized: (message?: string) => Response
|
|
67
|
-
forbidden: (message?: string) => Response
|
|
68
|
-
badRequest: (message?: string, errors?: Record<string, string[]>) => Response
|
|
69
|
-
validationError: (errors: Record<string, string[]>, message?: string) => Response
|
|
70
|
-
unprocessableEntity: (message?: string, errors?: Record<string, string[]>) => Response
|
|
71
|
-
serverError: (message?: string) => Response
|
|
72
|
-
tooManyRequests: (message?: string, retryAfter?: number) => Response
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Fluent response builder
|
|
76
|
-
*/
|
|
77
|
-
export declare class ResponseBuilder {
|
|
78
|
-
private _status: ResponseStatus;
|
|
79
|
-
private _headers: Record<string, string>;
|
|
80
|
-
private _cookies: Array<{ name: string, value: string, options: ResponseCookieOptions }>;
|
|
81
|
-
private _deleteCookies: Array<{ name: string, options: Pick<ResponseCookieOptions, 'path' | 'domain'> }>;
|
|
82
|
-
status(code: ResponseStatus): this;
|
|
83
|
-
header(name: string, value: string): this;
|
|
84
|
-
withHeaders(headers: Record<string, string>): this;
|
|
85
|
-
cookie(name: string, value: string, options?: ResponseCookieOptions): this;
|
|
86
|
-
withoutCookie(name: string, options?: Pick<ResponseCookieOptions, 'path' | 'domain'>): this;
|
|
87
|
-
json<T>(data: T): Response;
|
|
88
|
-
text(content: string): Response;
|
|
89
|
-
html(content: string): Response;
|
|
90
|
-
noContent(): Response;
|
|
91
|
-
private applyCookies(res: Response): Response;
|
|
92
|
-
private serializeCookie(name: string, value: string, options: ResponseCookieOptions): string;
|
|
93
|
-
}
|