qhttpx 2.1.0 → 2.3.1

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.
Files changed (267) hide show
  1. package/LICENSE +201 -21
  2. package/README.md +117 -221
  3. package/dist/chunk-QW72SEAS.mjs +98 -0
  4. package/dist/{src/cli/index.d.ts → cli.d.mts} +0 -1
  5. package/dist/cli.d.ts +1 -0
  6. package/dist/cli.js +287 -0
  7. package/dist/cli.mjs +209 -0
  8. package/dist/index.d.mts +433 -0
  9. package/dist/index.d.ts +433 -0
  10. package/dist/index.js +1955 -0
  11. package/dist/index.mjs +1863 -0
  12. package/dist/qhttpx-core-new.linux-x64-gnu.node +0 -0
  13. package/dist/qhttpx-core-new.node +0 -0
  14. package/dist/qhttpx-core-new.win32-x64-msvc.node +0 -0
  15. package/examples/benchmark.ts +67 -0
  16. package/examples/body_demo.ts +32 -0
  17. package/examples/chat_client.ts +36 -0
  18. package/examples/chat_demo.ts +41 -0
  19. package/examples/cluster_demo.ts +26 -0
  20. package/examples/cors_demo.ts +25 -0
  21. package/examples/db_auth_demo.ts +66 -0
  22. package/examples/demo.ts +52 -0
  23. package/examples/headers_demo.ts +24 -0
  24. package/examples/hello.ts +7 -0
  25. package/examples/http2_demo.ts +52 -0
  26. package/examples/magic-dev.ts +15 -0
  27. package/examples/middleware_demo.ts +34 -0
  28. package/examples/mongo_demo.ts +40 -0
  29. package/examples/native_policy_demo.ts +33 -0
  30. package/examples/observability_demo.ts +24 -0
  31. package/examples/public/1mb.dat +1 -0
  32. package/examples/query_demo.ts +29 -0
  33. package/examples/response_demo.ts +21 -0
  34. package/examples/routing_demo.ts +24 -0
  35. package/examples/server.ts +51 -0
  36. package/examples/static_demo.ts +29 -0
  37. package/examples/test_middleware_client.ts +33 -0
  38. package/examples/test_query_client.ts +34 -0
  39. package/examples/test_response_client.ts +30 -0
  40. package/examples/tls_demo.ts +32 -0
  41. package/examples/upload_demo.ts +43 -0
  42. package/examples/uploads/test.txt +1 -0
  43. package/examples/verify_upload.ts +69 -0
  44. package/examples/ws_client.ts +26 -0
  45. package/examples/ws_demo.ts +21 -0
  46. package/package.json +65 -81
  47. package/CHANGELOG.md +0 -285
  48. package/dist/examples/api-server.d.ts +0 -1
  49. package/dist/examples/api-server.js +0 -80
  50. package/dist/examples/basic.d.ts +0 -1
  51. package/dist/examples/basic.js +0 -9
  52. package/dist/examples/compression.d.ts +0 -1
  53. package/dist/examples/compression.js +0 -15
  54. package/dist/examples/cors.d.ts +0 -1
  55. package/dist/examples/cors.js +0 -18
  56. package/dist/examples/errors.d.ts +0 -1
  57. package/dist/examples/errors.js +0 -26
  58. package/dist/examples/file-upload.d.ts +0 -1
  59. package/dist/examples/file-upload.js +0 -22
  60. package/dist/examples/fusion.d.ts +0 -1
  61. package/dist/examples/fusion.js +0 -21
  62. package/dist/examples/rate-limiting.d.ts +0 -1
  63. package/dist/examples/rate-limiting.js +0 -17
  64. package/dist/examples/validation.d.ts +0 -1
  65. package/dist/examples/validation.js +0 -22
  66. package/dist/examples/websockets.d.ts +0 -1
  67. package/dist/examples/websockets.js +0 -19
  68. package/dist/package.json +0 -107
  69. package/dist/src/benchmarks/quantam-users.d.ts +0 -1
  70. package/dist/src/benchmarks/quantam-users.js +0 -56
  71. package/dist/src/benchmarks/quick-bench.d.ts +0 -1
  72. package/dist/src/benchmarks/quick-bench.js +0 -57
  73. package/dist/src/benchmarks/simple-json.d.ts +0 -1
  74. package/dist/src/benchmarks/simple-json.js +0 -171
  75. package/dist/src/benchmarks/ultra-mode.d.ts +0 -1
  76. package/dist/src/benchmarks/ultra-mode.js +0 -64
  77. package/dist/src/cli/index.js +0 -222
  78. package/dist/src/client/index.d.ts +0 -17
  79. package/dist/src/client/index.js +0 -72
  80. package/dist/src/core/batch.d.ts +0 -24
  81. package/dist/src/core/batch.js +0 -97
  82. package/dist/src/core/body-parser.d.ts +0 -15
  83. package/dist/src/core/body-parser.js +0 -121
  84. package/dist/src/core/buffer-pool.d.ts +0 -41
  85. package/dist/src/core/buffer-pool.js +0 -70
  86. package/dist/src/core/config.d.ts +0 -7
  87. package/dist/src/core/config.js +0 -50
  88. package/dist/src/core/context-pool.d.ts +0 -12
  89. package/dist/src/core/context-pool.js +0 -34
  90. package/dist/src/core/errors.d.ts +0 -34
  91. package/dist/src/core/errors.js +0 -70
  92. package/dist/src/core/fusion.d.ts +0 -20
  93. package/dist/src/core/fusion.js +0 -191
  94. package/dist/src/core/logger.d.ts +0 -22
  95. package/dist/src/core/logger.js +0 -49
  96. package/dist/src/core/metrics.d.ts +0 -50
  97. package/dist/src/core/metrics.js +0 -123
  98. package/dist/src/core/resources.d.ts +0 -9
  99. package/dist/src/core/resources.js +0 -25
  100. package/dist/src/core/scheduler.d.ts +0 -38
  101. package/dist/src/core/scheduler.js +0 -126
  102. package/dist/src/core/scope.d.ts +0 -41
  103. package/dist/src/core/scope.js +0 -107
  104. package/dist/src/core/serializer.d.ts +0 -10
  105. package/dist/src/core/serializer.js +0 -82
  106. package/dist/src/core/server.d.ts +0 -179
  107. package/dist/src/core/server.js +0 -1511
  108. package/dist/src/core/stream.d.ts +0 -15
  109. package/dist/src/core/stream.js +0 -71
  110. package/dist/src/core/tasks.d.ts +0 -29
  111. package/dist/src/core/tasks.js +0 -87
  112. package/dist/src/core/timer.d.ts +0 -11
  113. package/dist/src/core/timer.js +0 -29
  114. package/dist/src/core/types.d.ts +0 -225
  115. package/dist/src/core/types.js +0 -19
  116. package/dist/src/core/websocket.d.ts +0 -25
  117. package/dist/src/core/websocket.js +0 -86
  118. package/dist/src/core/worker-queue.d.ts +0 -41
  119. package/dist/src/core/worker-queue.js +0 -73
  120. package/dist/src/database/adapters/memory.d.ts +0 -21
  121. package/dist/src/database/adapters/memory.js +0 -90
  122. package/dist/src/database/adapters/mongo.d.ts +0 -11
  123. package/dist/src/database/adapters/mongo.js +0 -141
  124. package/dist/src/database/adapters/postgres.d.ts +0 -10
  125. package/dist/src/database/adapters/postgres.js +0 -111
  126. package/dist/src/database/adapters/sqlite.d.ts +0 -10
  127. package/dist/src/database/adapters/sqlite.js +0 -42
  128. package/dist/src/database/coalescer.d.ts +0 -14
  129. package/dist/src/database/coalescer.js +0 -134
  130. package/dist/src/database/manager.d.ts +0 -35
  131. package/dist/src/database/manager.js +0 -87
  132. package/dist/src/database/types.d.ts +0 -20
  133. package/dist/src/database/types.js +0 -2
  134. package/dist/src/index.d.ts +0 -52
  135. package/dist/src/index.js +0 -92
  136. package/dist/src/middleware/compression.d.ts +0 -2
  137. package/dist/src/middleware/compression.js +0 -133
  138. package/dist/src/middleware/cors.d.ts +0 -2
  139. package/dist/src/middleware/cors.js +0 -66
  140. package/dist/src/middleware/presets.d.ts +0 -15
  141. package/dist/src/middleware/presets.js +0 -52
  142. package/dist/src/middleware/rate-limit.d.ts +0 -14
  143. package/dist/src/middleware/rate-limit.js +0 -83
  144. package/dist/src/middleware/security.d.ts +0 -10
  145. package/dist/src/middleware/security.js +0 -74
  146. package/dist/src/middleware/static.d.ts +0 -11
  147. package/dist/src/middleware/static.js +0 -191
  148. package/dist/src/openapi/generator.d.ts +0 -19
  149. package/dist/src/openapi/generator.js +0 -149
  150. package/dist/src/router/radix-router.d.ts +0 -18
  151. package/dist/src/router/radix-router.js +0 -89
  152. package/dist/src/router/radix-tree.d.ts +0 -21
  153. package/dist/src/router/radix-tree.js +0 -175
  154. package/dist/src/router/router.d.ts +0 -37
  155. package/dist/src/router/router.js +0 -203
  156. package/dist/src/testing/index.d.ts +0 -25
  157. package/dist/src/testing/index.js +0 -84
  158. package/dist/src/utils/cookies.d.ts +0 -3
  159. package/dist/src/utils/cookies.js +0 -59
  160. package/dist/src/utils/logger.d.ts +0 -2
  161. package/dist/src/utils/logger.js +0 -45
  162. package/dist/src/utils/signals.d.ts +0 -6
  163. package/dist/src/utils/signals.js +0 -31
  164. package/dist/src/utils/sse.d.ts +0 -6
  165. package/dist/src/utils/sse.js +0 -32
  166. package/dist/src/validation/index.d.ts +0 -3
  167. package/dist/src/validation/index.js +0 -19
  168. package/dist/src/validation/simple.d.ts +0 -5
  169. package/dist/src/validation/simple.js +0 -102
  170. package/dist/src/validation/types.d.ts +0 -32
  171. package/dist/src/validation/types.js +0 -12
  172. package/dist/src/validation/zod.d.ts +0 -4
  173. package/dist/src/validation/zod.js +0 -18
  174. package/dist/src/views/index.d.ts +0 -1
  175. package/dist/src/views/index.js +0 -17
  176. package/dist/src/views/types.d.ts +0 -3
  177. package/dist/src/views/types.js +0 -2
  178. package/dist/tests/adapters.test.d.ts +0 -1
  179. package/dist/tests/adapters.test.js +0 -106
  180. package/dist/tests/batch.test.d.ts +0 -1
  181. package/dist/tests/batch.test.js +0 -117
  182. package/dist/tests/body-parser.test.d.ts +0 -1
  183. package/dist/tests/body-parser.test.js +0 -52
  184. package/dist/tests/compression-sse.test.d.ts +0 -1
  185. package/dist/tests/compression-sse.test.js +0 -87
  186. package/dist/tests/cookies.test.d.ts +0 -1
  187. package/dist/tests/cookies.test.js +0 -63
  188. package/dist/tests/cors.test.d.ts +0 -1
  189. package/dist/tests/cors.test.js +0 -55
  190. package/dist/tests/database.test.d.ts +0 -1
  191. package/dist/tests/database.test.js +0 -80
  192. package/dist/tests/dx.test.d.ts +0 -1
  193. package/dist/tests/dx.test.js +0 -114
  194. package/dist/tests/ecosystem.test.d.ts +0 -1
  195. package/dist/tests/ecosystem.test.js +0 -133
  196. package/dist/tests/features.test.d.ts +0 -1
  197. package/dist/tests/features.test.js +0 -47
  198. package/dist/tests/fusion.test.d.ts +0 -1
  199. package/dist/tests/fusion.test.js +0 -92
  200. package/dist/tests/http-basic.test.d.ts +0 -1
  201. package/dist/tests/http-basic.test.js +0 -124
  202. package/dist/tests/logger.test.d.ts +0 -1
  203. package/dist/tests/logger.test.js +0 -33
  204. package/dist/tests/middleware.test.d.ts +0 -1
  205. package/dist/tests/middleware.test.js +0 -109
  206. package/dist/tests/observability.test.d.ts +0 -1
  207. package/dist/tests/observability.test.js +0 -59
  208. package/dist/tests/openapi.test.d.ts +0 -1
  209. package/dist/tests/openapi.test.js +0 -64
  210. package/dist/tests/plugin.test.d.ts +0 -1
  211. package/dist/tests/plugin.test.js +0 -65
  212. package/dist/tests/plugins.test.d.ts +0 -1
  213. package/dist/tests/plugins.test.js +0 -71
  214. package/dist/tests/rate-limit.test.d.ts +0 -1
  215. package/dist/tests/rate-limit.test.js +0 -77
  216. package/dist/tests/resources.test.d.ts +0 -1
  217. package/dist/tests/resources.test.js +0 -47
  218. package/dist/tests/scheduler.test.d.ts +0 -1
  219. package/dist/tests/scheduler.test.js +0 -46
  220. package/dist/tests/schema-routes.test.d.ts +0 -1
  221. package/dist/tests/schema-routes.test.js +0 -79
  222. package/dist/tests/security.test.d.ts +0 -1
  223. package/dist/tests/security.test.js +0 -83
  224. package/dist/tests/server-db.test.d.ts +0 -1
  225. package/dist/tests/server-db.test.js +0 -72
  226. package/dist/tests/smoke.test.d.ts +0 -1
  227. package/dist/tests/smoke.test.js +0 -10
  228. package/dist/tests/sqlite-fusion.test.d.ts +0 -1
  229. package/dist/tests/sqlite-fusion.test.js +0 -92
  230. package/dist/tests/static.test.d.ts +0 -1
  231. package/dist/tests/static.test.js +0 -102
  232. package/dist/tests/stream.test.d.ts +0 -1
  233. package/dist/tests/stream.test.js +0 -44
  234. package/dist/tests/task-metrics.test.d.ts +0 -1
  235. package/dist/tests/task-metrics.test.js +0 -53
  236. package/dist/tests/tasks.test.d.ts +0 -1
  237. package/dist/tests/tasks.test.js +0 -62
  238. package/dist/tests/testing.test.d.ts +0 -1
  239. package/dist/tests/testing.test.js +0 -47
  240. package/dist/tests/validation.test.d.ts +0 -1
  241. package/dist/tests/validation.test.js +0 -107
  242. package/dist/tests/websocket.test.d.ts +0 -1
  243. package/dist/tests/websocket.test.js +0 -146
  244. package/dist/vitest.config.d.ts +0 -2
  245. package/dist/vitest.config.js +0 -9
  246. package/docs/AEGIS.md +0 -91
  247. package/docs/API_REFERENCE.md +0 -749
  248. package/docs/BENCHMARKS.md +0 -39
  249. package/docs/CAPABILITIES.md +0 -70
  250. package/docs/CLI.md +0 -43
  251. package/docs/DATABASE.md +0 -142
  252. package/docs/ECOSYSTEM.md +0 -146
  253. package/docs/ERRORS.md +0 -112
  254. package/docs/FUSION.md +0 -87
  255. package/docs/MIDDLEWARE.md +0 -65
  256. package/docs/MIGRATION_1.9_TO_2.0.md +0 -495
  257. package/docs/NEXT_STEPS.md +0 -99
  258. package/docs/OPENAPI.md +0 -99
  259. package/docs/PLUGINS.md +0 -59
  260. package/docs/PRODUCTION_DEPLOYMENT.md +0 -798
  261. package/docs/REAL_WORLD_EXAMPLES.md +0 -109
  262. package/docs/ROADMAP.md +0 -366
  263. package/docs/ROUTING.md +0 -78
  264. package/docs/SECURITY.md +0 -876
  265. package/docs/STATIC.md +0 -61
  266. package/docs/VALIDATION.md +0 -114
  267. package/docs/WEBSOCKETS.md +0 -76
@@ -0,0 +1,433 @@
1
+ interface RequestContext {
2
+ /** Unique Request ID (UUID v7) */
3
+ id: string;
4
+ method: string;
5
+ path: string;
6
+ status(code: number): this;
7
+ readonly statusCode: number;
8
+ send(data: any): void;
9
+ html(content: string): void;
10
+ req: {
11
+ json<T = any>(): T;
12
+ text(): string;
13
+ param(key: string): string;
14
+ query(key: string): string | undefined;
15
+ queries(key: string): string[] | undefined;
16
+ header(key: string): string | undefined;
17
+ };
18
+ query: Record<string, string | string[]>;
19
+ params: Record<string, string>;
20
+ json<T = any>(data?: any, status?: number): T | void;
21
+ text(): string;
22
+ /** High-performance parsed URL */
23
+ url: URL;
24
+ /** Read-only headers (zero-copy view) */
25
+ headers: ReadonlyMap<string, string>;
26
+ /** Environment variables (injected) */
27
+ env?: EnvContext;
28
+ /** Database Access Layer */
29
+ db?: DatabaseContext;
30
+ /** Performance metrics for this request */
31
+ perf?: RequestMetrics;
32
+ snapshot(): RequestSnapshot;
33
+ }
34
+ interface RequestSnapshot {
35
+ id: string;
36
+ method: string;
37
+ url: string;
38
+ path: string;
39
+ params: Record<string, string>;
40
+ query: Record<string, string | string[]>;
41
+ headers: Record<string, string>;
42
+ body: any;
43
+ env?: EnvContext;
44
+ perf?: RequestMetrics;
45
+ }
46
+ interface RequestMetrics {
47
+ startTime: number;
48
+ dbDuration: number;
49
+ parseDuration: number;
50
+ allocations: number;
51
+ }
52
+ interface EnvContext {
53
+ [key: string]: string | number | boolean;
54
+ }
55
+ interface DatabaseContext {
56
+ query(sql: string, ttl?: number): Promise<string>;
57
+ queryWithParams(sql: string, params: any[], ttl?: number): Promise<string>;
58
+ mongo(db: string, collection: string): {
59
+ find(query: any): Promise<any[]>;
60
+ };
61
+ [table: string]: any;
62
+ }
63
+ type NextFunction = () => Promise<void>;
64
+ type Middleware = (ctx: RequestContext, next: NextFunction) => Promise<void | any>;
65
+ interface UploadConfig {
66
+ dir: string;
67
+ handler?: Handler;
68
+ }
69
+ type RouteConfig = {
70
+ text?: string;
71
+ json?: any;
72
+ upload?: UploadConfig;
73
+ };
74
+ type Handler = ((ctx: RequestContext) => void | Promise<void> | Response | Promise<Response> | any | Promise<any>) | RouteConfig;
75
+ interface RouteOptions {
76
+ rateLimit?: {
77
+ limit: number;
78
+ window: number;
79
+ };
80
+ cache?: {
81
+ ttl: number;
82
+ };
83
+ jwt?: boolean;
84
+ schema?: any;
85
+ querySchema?: any;
86
+ responseSchema?: any;
87
+ priority?: 'critical' | 'interactive' | 'background';
88
+ sloTarget?: number;
89
+ }
90
+ interface Route {
91
+ method: string;
92
+ path: string;
93
+ handler?: Handler;
94
+ middlewares: Middleware[];
95
+ options?: RouteOptions;
96
+ routeConfig?: RouteConfig;
97
+ }
98
+ interface RouteBuilder {
99
+ desc(description: string): this;
100
+ auth(strategy?: string): this;
101
+ jwt(): this;
102
+ cache(options: {
103
+ ttl: number;
104
+ key?: string;
105
+ }): this;
106
+ rateLimit(options: {
107
+ limit: number;
108
+ window: number;
109
+ }): this;
110
+ query(schemaBuilder: (q: QueryBuilder) => void): this;
111
+ schema(def: any): this;
112
+ responseSchema(def: any): this;
113
+ priority(level: 'critical' | 'interactive' | 'background'): this;
114
+ slo(targetMs: number): this;
115
+ respond(handler: Handler): void;
116
+ }
117
+ interface WebSocket {
118
+ send(message: string): void;
119
+ subscribe(room: string): void;
120
+ unsubscribe(room: string): void;
121
+ publish(room: string, message: string): void;
122
+ }
123
+ interface WsHandler {
124
+ open?: (ws: WebSocket) => void;
125
+ message?: (ws: WebSocket, message: string) => void;
126
+ close?: (ws: WebSocket) => void;
127
+ }
128
+ interface QueryBuilder {
129
+ string(name: string): QueryField;
130
+ int(name: string): QueryField;
131
+ bool(name: string): QueryField;
132
+ }
133
+ interface QueryField {
134
+ default(val: any): this;
135
+ optional(): this;
136
+ max(val: number): this;
137
+ min(val: number): this;
138
+ }
139
+ interface ListenOptions {
140
+ port: number;
141
+ tls?: {
142
+ cert: string;
143
+ key: string;
144
+ };
145
+ callback?: () => void;
146
+ }
147
+ interface FluentBuilder$1 {
148
+ validate(schema: Record<string, string>): this;
149
+ schema(def: any): this;
150
+ responseSchema(def: any): this;
151
+ query(schemaBuilder: (q: QueryBuilder) => void): this;
152
+ use(fn: (ctx: RequestContext, state: any) => Promise<any> | any): this;
153
+ transform(fn: (data: any) => Promise<any> | any): this;
154
+ hash(field?: string): this;
155
+ insert(table: string): this;
156
+ find(table: string, by: string): this;
157
+ ensure(condition: (state: any) => boolean, errorMsg?: string, status?: number): this;
158
+ verifyPassword(field?: string): this;
159
+ jwt(options?: {
160
+ secret?: string;
161
+ expiresIn?: string;
162
+ }): this;
163
+ respond(status?: number): void;
164
+ secure(): this;
165
+ autoFilter(table: string, allow: string[], options?: {
166
+ sort?: string[];
167
+ select?: string[];
168
+ defaultSort?: string;
169
+ defaultDirection?: 'ASC' | 'DESC';
170
+ maxLimit?: number;
171
+ pageParam?: string;
172
+ limitParam?: string;
173
+ sortParam?: string;
174
+ fieldsParam?: string;
175
+ }): this;
176
+ list(table: string, options?: {
177
+ where?: Record<string, string>;
178
+ limit?: number;
179
+ }): this;
180
+ update(table: string, options: {
181
+ where: Record<string, string>;
182
+ fields?: string[];
183
+ }): this;
184
+ delete(table: string, options: {
185
+ where: Record<string, string>;
186
+ }): this;
187
+ }
188
+ interface App$1 {
189
+ enableLogging(): void;
190
+ getMetrics(): string;
191
+ onError(handler: (err: unknown, ctx?: RequestContext) => void): this;
192
+ gracefulShutdown(signals?: string[]): this;
193
+ flow(method: string, path: string): FluentBuilder$1;
194
+ db: {
195
+ connectPostgres(url: string): Promise<void>;
196
+ connectSqlite(url: string): Promise<void>;
197
+ connectRedis(url: string): void;
198
+ connectMongo(url: string): Promise<void>;
199
+ query(sql: string, ttl?: number): Promise<string>;
200
+ redis: {
201
+ set(key: string, value: string, ttl?: number): Promise<void>;
202
+ get(key: string): Promise<string | null>;
203
+ };
204
+ mongo(db: string, collection: string): {
205
+ find(query: any): Promise<any[]>;
206
+ };
207
+ };
208
+ auth: {
209
+ setJwtSecret(secret: string): void;
210
+ };
211
+ get(path: string, config: RouteConfig): RouteBuilder;
212
+ get(path: string, handler: Handler): RouteBuilder;
213
+ get(path: string): RouteBuilder;
214
+ post(path: string, config: RouteConfig): RouteBuilder;
215
+ post(path: string, handler: Handler): RouteBuilder;
216
+ post(path: string): RouteBuilder;
217
+ put(path: string, config: RouteConfig): RouteBuilder;
218
+ put(path: string, handler: Handler): RouteBuilder;
219
+ put(path: string): RouteBuilder;
220
+ delete(path: string, config: RouteConfig): RouteBuilder;
221
+ delete(path: string, handler: Handler): RouteBuilder;
222
+ delete(path: string): RouteBuilder;
223
+ listen(port: number, callback?: () => void): void;
224
+ listen(options: ListenOptions): void;
225
+ stop(): void;
226
+ ws(path: string, handler: WsHandler): void;
227
+ static(prefix: string, root: string): this;
228
+ use(middleware: Middleware): this;
229
+ cors(config?: {
230
+ origin?: string;
231
+ methods?: string[];
232
+ headers?: string[];
233
+ credentials?: boolean;
234
+ }): this;
235
+ }
236
+
237
+ declare function loadEnv(filePath?: string): boolean;
238
+ declare function env(key: string, defaultValue?: string): string;
239
+
240
+ declare class TestClient {
241
+ private app;
242
+ port: number;
243
+ baseUrl: string;
244
+ private running;
245
+ constructor(app: App$1);
246
+ start(): Promise<void>;
247
+ stop(): Promise<void>;
248
+ get(path: string, headers?: Record<string, string>): Promise<Response>;
249
+ post(path: string, body: any, headers?: Record<string, string>): Promise<Response>;
250
+ put(path: string, body: any, headers?: Record<string, string>): Promise<Response>;
251
+ delete(path: string, headers?: Record<string, string>): Promise<Response>;
252
+ }
253
+ declare function createTestClient(app: App$1): TestClient;
254
+
255
+ declare class FluentBuilder {
256
+ private app;
257
+ private method;
258
+ private path;
259
+ private steps;
260
+ private requestSchema?;
261
+ private responseSchemaDef?;
262
+ private queryBuilder?;
263
+ constructor(app: App$1, method: string, path: string);
264
+ desc(description: string): this;
265
+ auth(strategy?: string): this;
266
+ cache(options: {
267
+ ttl: number;
268
+ key?: string;
269
+ }): this;
270
+ rateLimit(options: {
271
+ limit: number;
272
+ window: number;
273
+ }): this;
274
+ status(statusCode: number): this;
275
+ priority(level: 'critical' | 'interactive' | 'background'): this;
276
+ slo(targetMs: number): this;
277
+ validate(schema: Record<string, string>): this;
278
+ schema(def: any): this;
279
+ responseSchema(def: any): this;
280
+ query(schemaBuilder: (q: any) => void): this;
281
+ queryState(fields?: string[]): this;
282
+ use(fn: (ctx: RequestContext, state: any) => Promise<any> | any): this;
283
+ sql(query: string, params?: any[] | ((state: any) => any[])): this;
284
+ transform(fn: (data: any) => Promise<any> | any): this;
285
+ hash(field?: string): this;
286
+ insert(table: string): this;
287
+ find(table: string, by: string): this;
288
+ ensure(condition: (state: any) => boolean, errorMsg?: string, status?: number): this;
289
+ verifyPassword(field?: string): this;
290
+ jwt(options?: {
291
+ secret?: string;
292
+ expiresIn?: string;
293
+ }): this;
294
+ respond(handlerOrStatus?: Handler | number): void;
295
+ private applyOptionsToRoute;
296
+ private useJwt;
297
+ secure(): this;
298
+ select(fields: string[]): this;
299
+ sort(field: string, direction?: 'ASC' | 'DESC'): this;
300
+ paginate(options: {
301
+ page: number;
302
+ limit: number;
303
+ }): this;
304
+ autoFilter(table: string, allow: string[], options?: {
305
+ sort?: string[];
306
+ select?: string[];
307
+ defaultSort?: string;
308
+ defaultDirection?: 'ASC' | 'DESC';
309
+ maxLimit?: number;
310
+ pageParam?: string;
311
+ limitParam?: string;
312
+ sortParam?: string;
313
+ fieldsParam?: string;
314
+ }): this;
315
+ list(table: string, options?: {
316
+ where?: Record<string, string>;
317
+ limit?: number;
318
+ }): this;
319
+ update(table: string, options: {
320
+ where: Record<string, string>;
321
+ fields?: string[];
322
+ }): this;
323
+ softDelete(table: string, options: {
324
+ where: Record<string, string>;
325
+ }): this;
326
+ delete(table: string, options: {
327
+ where: Record<string, string>;
328
+ }): this;
329
+ }
330
+
331
+ declare class Q {
332
+ static env: typeof env;
333
+ static loadEnv: typeof loadEnv;
334
+ static app(config?: any): App;
335
+ static schema(def: any): any;
336
+ static string(): SchemaBuilder;
337
+ static int(): SchemaBuilder;
338
+ static email(): SchemaBuilder;
339
+ static enum(...values: string[]): SchemaBuilder;
340
+ }
341
+ declare namespace Q {
342
+ type Context = RequestContext;
343
+ type Handler = Handler;
344
+ }
345
+ declare class SchemaBuilder {
346
+ private def;
347
+ constructor(type: string);
348
+ min(val: number): this;
349
+ max(val: number): this;
350
+ format(fmt: string): this;
351
+ enum(values: string[]): this;
352
+ toJSON(): any;
353
+ }
354
+ declare namespace App {
355
+ type Context = RequestContext;
356
+ }
357
+ declare class App implements App$1 {
358
+ private config?;
359
+ private engine;
360
+ private routes;
361
+ private handlers;
362
+ private handlerCounter;
363
+ private middlewares;
364
+ private staticRoutes;
365
+ private wsHandlers;
366
+ private activeSockets;
367
+ private corsConfig;
368
+ private loggingEnabled;
369
+ private errorHandler;
370
+ private errorHooksRegistered;
371
+ private shutdownHooksRegistered;
372
+ flow(method: string, path: string): FluentBuilder;
373
+ doc(path: string): this;
374
+ exportClient(outputPath: string): void;
375
+ private generateOpenApiSpec;
376
+ enableLogging(): void;
377
+ getMetrics(): string;
378
+ onError(handler: (err: unknown, ctx?: RequestContext) => void): this;
379
+ gracefulShutdown(signals?: string[]): this;
380
+ security(): this;
381
+ private pendingSecurity;
382
+ private registerErrorHooks;
383
+ private handleError;
384
+ db: {
385
+ connectPostgres(url: string): Promise<void>;
386
+ connectSqlite(url: string): Promise<void>;
387
+ connectRedis(url: string): void;
388
+ connectMongo(url: string): Promise<void>;
389
+ query(sql: string, ttl?: number): Promise<string>;
390
+ redis: {
391
+ set(key: string, value: string, ttl?: number): Promise<void>;
392
+ get(key: string): Promise<string | null>;
393
+ };
394
+ mongo(db: string, collection: string): {
395
+ find(query: any): Promise<any[]>;
396
+ };
397
+ };
398
+ auth: {
399
+ setJwtSecret(secret: string): void;
400
+ };
401
+ constructor(config?: any | undefined);
402
+ static(prefix: string, root: string): this;
403
+ use(fn: Middleware): this;
404
+ ws(path: string, handler: WsHandler): void;
405
+ cors(config?: {
406
+ origin?: string;
407
+ methods?: string[];
408
+ headers?: string[];
409
+ credentials?: boolean;
410
+ }): this;
411
+ get(path: string, config: RouteConfig): FluentBuilder;
412
+ get(path: string, handler: Handler): FluentBuilder;
413
+ get(path: string, options: RouteOptions, handler: Handler): FluentBuilder;
414
+ get(path: string): FluentBuilder;
415
+ post(path: string, config: RouteConfig): FluentBuilder;
416
+ post(path: string, handler: Handler): FluentBuilder;
417
+ post(path: string, options: RouteOptions, handler: Handler): FluentBuilder;
418
+ post(path: string): FluentBuilder;
419
+ put(path: string, config: RouteConfig): FluentBuilder;
420
+ put(path: string, handler: Handler): FluentBuilder;
421
+ put(path: string, options: RouteOptions, handler: Handler): FluentBuilder;
422
+ put(path: string): FluentBuilder;
423
+ delete(path: string, config: RouteConfig): FluentBuilder;
424
+ delete(path: string, handler: Handler): FluentBuilder;
425
+ delete(path: string, options: RouteOptions, handler: Handler): FluentBuilder;
426
+ delete(path: string): FluentBuilder;
427
+ private addRoute;
428
+ registerHandler(handler: Handler, serializer?: (doc: any) => string): number;
429
+ listen(portOrOptions: number | ListenOptions, cb?: () => void): void;
430
+ stop(): void;
431
+ }
432
+
433
+ export { App, type DatabaseContext, type EnvContext, FluentBuilder, type Handler, type ListenOptions, type Middleware, type NextFunction, Q, type QueryBuilder, type QueryField, type RequestContext, type RequestMetrics, type RequestSnapshot, type Route, type RouteBuilder, type RouteConfig, type RouteOptions, TestClient, type UploadConfig, type WebSocket, type WsHandler, createTestClient };