balda 0.0.48 → 0.0.50
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/lib/cli.js +33 -33
- package/lib/cli.js.map +1 -1
- package/lib/index.cjs +38 -38
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +48 -12
- package/lib/index.d.ts +48 -12
- package/lib/index.js +38 -38
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.d.cts
CHANGED
|
@@ -222,9 +222,10 @@ declare class Request<Params extends Record<string, string> = any, TBody = unkno
|
|
|
222
222
|
*/
|
|
223
223
|
method: string;
|
|
224
224
|
/**
|
|
225
|
-
* The headers of the request
|
|
225
|
+
* The headers of the request — lazily constructed from raw Node.js headers.
|
|
226
226
|
*/
|
|
227
|
-
headers: globalThis.Headers;
|
|
227
|
+
get headers(): globalThis.Headers;
|
|
228
|
+
set headers(value: globalThis.Headers);
|
|
228
229
|
/**
|
|
229
230
|
* The signal for aborting the request
|
|
230
231
|
*/
|
|
@@ -320,7 +321,7 @@ declare class Request<Params extends Record<string, string> = any, TBody = unkno
|
|
|
320
321
|
* The file of the request.
|
|
321
322
|
* @fileParser middleware is required
|
|
322
323
|
*/
|
|
323
|
-
file
|
|
324
|
+
file(fieldName: string): FormFile | null;
|
|
324
325
|
/**
|
|
325
326
|
* The cookies of the request.
|
|
326
327
|
* @cookie middleware is required
|
|
@@ -330,7 +331,7 @@ declare class Request<Params extends Record<string, string> = any, TBody = unkno
|
|
|
330
331
|
* The cookie of the request.
|
|
331
332
|
* @cookie middleware is required
|
|
332
333
|
*/
|
|
333
|
-
cookie
|
|
334
|
+
cookie(name: string): string | undefined;
|
|
334
335
|
/**
|
|
335
336
|
* tells if the request has timed out.
|
|
336
337
|
* @timeout middleware is required
|
|
@@ -342,6 +343,11 @@ declare class Request<Params extends Record<string, string> = any, TBody = unkno
|
|
|
342
343
|
* @session middleware is required
|
|
343
344
|
*/
|
|
344
345
|
session?: Record<string, any>;
|
|
346
|
+
/**
|
|
347
|
+
* Shared no-op async function to avoid per-instance closure allocation.
|
|
348
|
+
* @internal
|
|
349
|
+
*/
|
|
350
|
+
private static readonly _noopAsync;
|
|
345
351
|
/**
|
|
346
352
|
* The session of the request. Uses cookies to send the session id
|
|
347
353
|
* @cookie middleware is required
|
|
@@ -354,11 +360,8 @@ declare class Request<Params extends Record<string, string> = any, TBody = unkno
|
|
|
354
360
|
* @session middleware is required
|
|
355
361
|
*/
|
|
356
362
|
destroySession: () => Promise<void>;
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
* Tries to get the ip address from the `x-forwarded-for` header. If not available, it will use the remote address from the request.
|
|
360
|
-
*/
|
|
361
|
-
ip?: string;
|
|
363
|
+
get ip(): string | undefined;
|
|
364
|
+
set ip(value: string | undefined);
|
|
362
365
|
/**
|
|
363
366
|
* The files of the request. Only available for multipart/form-data requests and if the file parser middleware is used.
|
|
364
367
|
*/
|
|
@@ -443,6 +446,31 @@ declare class Request<Params extends Record<string, string> = any, TBody = unkno
|
|
|
443
446
|
* @param throwErrorOnValidationFail - If true, throws ValidationError on validation failure. If false, returns the original data.
|
|
444
447
|
*/
|
|
445
448
|
validateAll<T extends RequestSchema>(inputSchema: T, throwErrorOnValidationFail?: boolean): ValidatedData<T>;
|
|
449
|
+
/**
|
|
450
|
+
* Sets a lazy IP extractor function.
|
|
451
|
+
* IP will only be extracted when `.ip` is first accessed.
|
|
452
|
+
* @param req - The Node.js IncomingMessage
|
|
453
|
+
* @internal
|
|
454
|
+
*/
|
|
455
|
+
setIpExtractor(req: IncomingMessage): void;
|
|
456
|
+
/**
|
|
457
|
+
* Sets a lazy IP extractor for Bun runtime.
|
|
458
|
+
* @internal
|
|
459
|
+
*/
|
|
460
|
+
setBunIpExtractor(req: globalThis.Request, server: any): void;
|
|
461
|
+
/**
|
|
462
|
+
* Sets a lazy IP extractor for Deno runtime.
|
|
463
|
+
* @internal
|
|
464
|
+
*/
|
|
465
|
+
setDenoIpExtractor(req: globalThis.Request, info: any): void;
|
|
466
|
+
/**
|
|
467
|
+
* Sets raw Node.js headers for lazy Headers construction.
|
|
468
|
+
* Avoids creating a Web API Headers object until first access.
|
|
469
|
+
* @param headers - Raw Node.js IncomingMessage headers
|
|
470
|
+
* @param needsFiltering - Whether HTTP/2 pseudo-header filtering is needed
|
|
471
|
+
* @internal
|
|
472
|
+
*/
|
|
473
|
+
setRawHeaders(headers: IncomingMessage["headers"], needsFiltering: boolean): void;
|
|
446
474
|
/**
|
|
447
475
|
* Sets the Node.js IncomingMessage for lazy body reading.
|
|
448
476
|
* Used internally by the Node.js server implementation.
|
|
@@ -1590,7 +1618,7 @@ declare class Router {
|
|
|
1590
1618
|
body?: RequestSchema;
|
|
1591
1619
|
query?: RequestSchema;
|
|
1592
1620
|
all?: RequestSchema;
|
|
1593
|
-
}, swaggerOptions?: SwaggerRouteOptions, responses?: Record<number, RequestSchema
|
|
1621
|
+
}, swaggerOptions?: SwaggerRouteOptions, responses?: Record<number, RequestSchema>, allowUpdate?: boolean): void;
|
|
1594
1622
|
/**
|
|
1595
1623
|
* Find the matching route for the given HTTP method and path.
|
|
1596
1624
|
* Returns the resolved middleware chain, handler, extracted params, and response schemas; or null if not found.
|
|
@@ -1752,7 +1780,11 @@ declare class Server<H extends NodeHttpClient = NodeHttpClient> implements Serve
|
|
|
1752
1780
|
setNotFoundHandler(notFoundHandler?: ServerRouteHandler): void;
|
|
1753
1781
|
beforeStart(hook: ServerHook): void;
|
|
1754
1782
|
listen(cb?: ServerListenCallback): void;
|
|
1755
|
-
waitUntilListening(): Promise<
|
|
1783
|
+
waitUntilListening(): Promise<{
|
|
1784
|
+
port: number;
|
|
1785
|
+
host: string;
|
|
1786
|
+
url: string;
|
|
1787
|
+
}>;
|
|
1756
1788
|
/**
|
|
1757
1789
|
* Closes the server and frees the port
|
|
1758
1790
|
* This method is idempotent and can be called multiple times safely
|
|
@@ -2536,7 +2568,11 @@ interface ServerInterface {
|
|
|
2536
2568
|
* Use `listen` instead if you want to initialize the server without blocking the event loop
|
|
2537
2569
|
* @warning All routes defined with decorators are defined on this method just before the server starts listening for requests
|
|
2538
2570
|
*/
|
|
2539
|
-
waitUntilListening: () => Promise<
|
|
2571
|
+
waitUntilListening: () => Promise<{
|
|
2572
|
+
port: number;
|
|
2573
|
+
host: string;
|
|
2574
|
+
url: string;
|
|
2575
|
+
}>;
|
|
2540
2576
|
/**
|
|
2541
2577
|
* Closes the server and frees the port
|
|
2542
2578
|
* This method is idempotent and can be called multiple times safely
|
package/lib/index.d.ts
CHANGED
|
@@ -222,9 +222,10 @@ declare class Request<Params extends Record<string, string> = any, TBody = unkno
|
|
|
222
222
|
*/
|
|
223
223
|
method: string;
|
|
224
224
|
/**
|
|
225
|
-
* The headers of the request
|
|
225
|
+
* The headers of the request — lazily constructed from raw Node.js headers.
|
|
226
226
|
*/
|
|
227
|
-
headers: globalThis.Headers;
|
|
227
|
+
get headers(): globalThis.Headers;
|
|
228
|
+
set headers(value: globalThis.Headers);
|
|
228
229
|
/**
|
|
229
230
|
* The signal for aborting the request
|
|
230
231
|
*/
|
|
@@ -320,7 +321,7 @@ declare class Request<Params extends Record<string, string> = any, TBody = unkno
|
|
|
320
321
|
* The file of the request.
|
|
321
322
|
* @fileParser middleware is required
|
|
322
323
|
*/
|
|
323
|
-
file
|
|
324
|
+
file(fieldName: string): FormFile | null;
|
|
324
325
|
/**
|
|
325
326
|
* The cookies of the request.
|
|
326
327
|
* @cookie middleware is required
|
|
@@ -330,7 +331,7 @@ declare class Request<Params extends Record<string, string> = any, TBody = unkno
|
|
|
330
331
|
* The cookie of the request.
|
|
331
332
|
* @cookie middleware is required
|
|
332
333
|
*/
|
|
333
|
-
cookie
|
|
334
|
+
cookie(name: string): string | undefined;
|
|
334
335
|
/**
|
|
335
336
|
* tells if the request has timed out.
|
|
336
337
|
* @timeout middleware is required
|
|
@@ -342,6 +343,11 @@ declare class Request<Params extends Record<string, string> = any, TBody = unkno
|
|
|
342
343
|
* @session middleware is required
|
|
343
344
|
*/
|
|
344
345
|
session?: Record<string, any>;
|
|
346
|
+
/**
|
|
347
|
+
* Shared no-op async function to avoid per-instance closure allocation.
|
|
348
|
+
* @internal
|
|
349
|
+
*/
|
|
350
|
+
private static readonly _noopAsync;
|
|
345
351
|
/**
|
|
346
352
|
* The session of the request. Uses cookies to send the session id
|
|
347
353
|
* @cookie middleware is required
|
|
@@ -354,11 +360,8 @@ declare class Request<Params extends Record<string, string> = any, TBody = unkno
|
|
|
354
360
|
* @session middleware is required
|
|
355
361
|
*/
|
|
356
362
|
destroySession: () => Promise<void>;
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
* Tries to get the ip address from the `x-forwarded-for` header. If not available, it will use the remote address from the request.
|
|
360
|
-
*/
|
|
361
|
-
ip?: string;
|
|
363
|
+
get ip(): string | undefined;
|
|
364
|
+
set ip(value: string | undefined);
|
|
362
365
|
/**
|
|
363
366
|
* The files of the request. Only available for multipart/form-data requests and if the file parser middleware is used.
|
|
364
367
|
*/
|
|
@@ -443,6 +446,31 @@ declare class Request<Params extends Record<string, string> = any, TBody = unkno
|
|
|
443
446
|
* @param throwErrorOnValidationFail - If true, throws ValidationError on validation failure. If false, returns the original data.
|
|
444
447
|
*/
|
|
445
448
|
validateAll<T extends RequestSchema>(inputSchema: T, throwErrorOnValidationFail?: boolean): ValidatedData<T>;
|
|
449
|
+
/**
|
|
450
|
+
* Sets a lazy IP extractor function.
|
|
451
|
+
* IP will only be extracted when `.ip` is first accessed.
|
|
452
|
+
* @param req - The Node.js IncomingMessage
|
|
453
|
+
* @internal
|
|
454
|
+
*/
|
|
455
|
+
setIpExtractor(req: IncomingMessage): void;
|
|
456
|
+
/**
|
|
457
|
+
* Sets a lazy IP extractor for Bun runtime.
|
|
458
|
+
* @internal
|
|
459
|
+
*/
|
|
460
|
+
setBunIpExtractor(req: globalThis.Request, server: any): void;
|
|
461
|
+
/**
|
|
462
|
+
* Sets a lazy IP extractor for Deno runtime.
|
|
463
|
+
* @internal
|
|
464
|
+
*/
|
|
465
|
+
setDenoIpExtractor(req: globalThis.Request, info: any): void;
|
|
466
|
+
/**
|
|
467
|
+
* Sets raw Node.js headers for lazy Headers construction.
|
|
468
|
+
* Avoids creating a Web API Headers object until first access.
|
|
469
|
+
* @param headers - Raw Node.js IncomingMessage headers
|
|
470
|
+
* @param needsFiltering - Whether HTTP/2 pseudo-header filtering is needed
|
|
471
|
+
* @internal
|
|
472
|
+
*/
|
|
473
|
+
setRawHeaders(headers: IncomingMessage["headers"], needsFiltering: boolean): void;
|
|
446
474
|
/**
|
|
447
475
|
* Sets the Node.js IncomingMessage for lazy body reading.
|
|
448
476
|
* Used internally by the Node.js server implementation.
|
|
@@ -1590,7 +1618,7 @@ declare class Router {
|
|
|
1590
1618
|
body?: RequestSchema;
|
|
1591
1619
|
query?: RequestSchema;
|
|
1592
1620
|
all?: RequestSchema;
|
|
1593
|
-
}, swaggerOptions?: SwaggerRouteOptions, responses?: Record<number, RequestSchema
|
|
1621
|
+
}, swaggerOptions?: SwaggerRouteOptions, responses?: Record<number, RequestSchema>, allowUpdate?: boolean): void;
|
|
1594
1622
|
/**
|
|
1595
1623
|
* Find the matching route for the given HTTP method and path.
|
|
1596
1624
|
* Returns the resolved middleware chain, handler, extracted params, and response schemas; or null if not found.
|
|
@@ -1752,7 +1780,11 @@ declare class Server<H extends NodeHttpClient = NodeHttpClient> implements Serve
|
|
|
1752
1780
|
setNotFoundHandler(notFoundHandler?: ServerRouteHandler): void;
|
|
1753
1781
|
beforeStart(hook: ServerHook): void;
|
|
1754
1782
|
listen(cb?: ServerListenCallback): void;
|
|
1755
|
-
waitUntilListening(): Promise<
|
|
1783
|
+
waitUntilListening(): Promise<{
|
|
1784
|
+
port: number;
|
|
1785
|
+
host: string;
|
|
1786
|
+
url: string;
|
|
1787
|
+
}>;
|
|
1756
1788
|
/**
|
|
1757
1789
|
* Closes the server and frees the port
|
|
1758
1790
|
* This method is idempotent and can be called multiple times safely
|
|
@@ -2536,7 +2568,11 @@ interface ServerInterface {
|
|
|
2536
2568
|
* Use `listen` instead if you want to initialize the server without blocking the event loop
|
|
2537
2569
|
* @warning All routes defined with decorators are defined on this method just before the server starts listening for requests
|
|
2538
2570
|
*/
|
|
2539
|
-
waitUntilListening: () => Promise<
|
|
2571
|
+
waitUntilListening: () => Promise<{
|
|
2572
|
+
port: number;
|
|
2573
|
+
host: string;
|
|
2574
|
+
url: string;
|
|
2575
|
+
}>;
|
|
2540
2576
|
/**
|
|
2541
2577
|
* Closes the server and frees the port
|
|
2542
2578
|
* This method is idempotent and can be called multiple times safely
|