balda 0.0.38 → 0.0.39
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 +24 -24
- package/lib/cli.js.map +1 -1
- package/lib/index.cjs +52 -52
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +81 -119
- package/lib/index.d.ts +81 -119
- package/lib/index.js +52 -52
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { schedule, TaskContext } from 'node-cron';
|
|
2
2
|
import { TSchema, Static } from '@sinclair/typebox';
|
|
3
|
-
import {
|
|
3
|
+
import { ZodType, z } from 'zod';
|
|
4
4
|
import { Ajv } from 'ajv';
|
|
5
5
|
import { IncomingMessage, ServerResponse, Server as Server$2 } from 'node:http';
|
|
6
6
|
import { Http2Server } from 'node:http2';
|
|
@@ -114,8 +114,8 @@ declare const flag: {
|
|
|
114
114
|
type AjvInstance = InstanceType<typeof Ajv>;
|
|
115
115
|
type AjvCompileParams = Parameters<AjvInstance["compile"]>;
|
|
116
116
|
|
|
117
|
-
type RequestSchema =
|
|
118
|
-
type ValidatedData<T extends RequestSchema> = T extends
|
|
117
|
+
type RequestSchema = ZodType | TSchema | AjvCompileParams[0];
|
|
118
|
+
type ValidatedData<T extends RequestSchema> = T extends ZodType ? z.infer<T> : T extends TSchema ? Static<T> : T extends AjvCompileParams[0] ? any : any;
|
|
119
119
|
interface CustomValidationError {
|
|
120
120
|
status?: number;
|
|
121
121
|
message?: string;
|
|
@@ -241,13 +241,13 @@ type SwaggerGlobalOptions = (SwaggerGlobalOptionsBase & {
|
|
|
241
241
|
/**
|
|
242
242
|
* Route-specific documentation options (for individual endpoints)
|
|
243
243
|
*/
|
|
244
|
-
type SwaggerRouteOptions = {
|
|
244
|
+
type SwaggerRouteOptions<TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>> = {
|
|
245
245
|
/** Service category where the route belongs to */
|
|
246
246
|
service?: string;
|
|
247
247
|
/** Name of the route */
|
|
248
248
|
name?: string;
|
|
249
249
|
/** Responses for this route */
|
|
250
|
-
responses?:
|
|
250
|
+
responses?: TResponses;
|
|
251
251
|
/** Errors for this route */
|
|
252
252
|
errors?: Record<number, RequestSchema>;
|
|
253
253
|
/** Security requirements for this route */
|
|
@@ -748,13 +748,38 @@ type CookieMiddlewareOptions = {
|
|
|
748
748
|
};
|
|
749
749
|
|
|
750
750
|
/**
|
|
751
|
-
*
|
|
752
|
-
*
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
751
|
+
* Extracts parameter names from a path string and creates a typed object
|
|
752
|
+
* @example ExtractParams<"/users/:id/posts/:postId"> → { id: string; postId: string }
|
|
753
|
+
*/
|
|
754
|
+
type ExtractParams<T extends string> = T extends `${infer _Start}:${infer Param}/${infer Rest}` ? {
|
|
755
|
+
[K in Param | keyof ExtractParams<Rest>]: string;
|
|
756
|
+
} : T extends `${infer _Start}:${infer Param}` ? {
|
|
757
|
+
[K in Param]: string;
|
|
758
|
+
} : Record<string, never>;
|
|
759
|
+
/**
|
|
760
|
+
* Helper type to infer the output type from a Zod schema, TypeBox schema, or any schema with _output
|
|
761
|
+
*/
|
|
762
|
+
type InferSchemaType<T> = T extends ZodType ? z.infer<T> : T extends TSchema ? Static<T> : any;
|
|
763
|
+
/**
|
|
764
|
+
* Maps a responses object (e.g. { 200: ZodSchema, 404: TypeBoxSchema }) to
|
|
765
|
+
* an inferred type map (e.g. { 200: InferredType200, 404: InferredType404 }).
|
|
766
|
+
*/
|
|
767
|
+
type InferResponseMap<T extends Record<number, RequestSchema>> = {
|
|
768
|
+
[K in keyof T]: InferSchemaType<T[K]>;
|
|
769
|
+
};
|
|
770
|
+
/**
|
|
771
|
+
* Extracts the body type for a specific HTTP status code from a response map.
|
|
772
|
+
* Defaults to `any` when the status code is not present in the map.
|
|
773
|
+
*/
|
|
774
|
+
type ResponseBodyForStatus<TMap, TStatus extends number> = TStatus extends keyof TMap ? TMap[TStatus] : any;
|
|
775
|
+
|
|
776
|
+
/**
|
|
777
|
+
* The response object with per-status-code type-safe response bodies.
|
|
778
|
+
* When response schemas are provided (e.g. via swagger.responses), each shorthand
|
|
779
|
+
* method (ok, created, notFound, etc.) is typed to its corresponding status code schema.
|
|
780
|
+
* @template TResponseMap - Maps HTTP status codes to their inferred body types (defaults to Record<number, any>)
|
|
756
781
|
*/
|
|
757
|
-
declare class Response$1<
|
|
782
|
+
declare class Response$1<TResponseMap extends Record<number, any> = Record<number, any>> {
|
|
758
783
|
#private;
|
|
759
784
|
static toWebResponse(response: Response$1): globalThis.Response;
|
|
760
785
|
/**
|
|
@@ -792,7 +817,7 @@ declare class Response$1<TBody = any> {
|
|
|
792
817
|
* Send a response with the given body, tries to determine the content type based on the body type, status defaults to 200
|
|
793
818
|
* @warning If cannot determine the content type, it will be sent as is
|
|
794
819
|
*/
|
|
795
|
-
send(body:
|
|
820
|
+
send(body: TResponseMap[keyof TResponseMap]): void;
|
|
796
821
|
/**
|
|
797
822
|
* Send a response with the given body without any content type or encoding (as is), status defaults to 200
|
|
798
823
|
*/
|
|
@@ -806,13 +831,7 @@ declare class Response$1<TBody = any> {
|
|
|
806
831
|
* @param body - The response body to serialize
|
|
807
832
|
* @param schema - Optional schema for fast-json-stringify. When provided, enables fast serialization
|
|
808
833
|
*/
|
|
809
|
-
json(body:
|
|
810
|
-
/**
|
|
811
|
-
* Converts any schema type to JSON Schema format with appropriate prefix.
|
|
812
|
-
* @param schema - The schema to convert
|
|
813
|
-
* @returns Object with JSON Schema and prefix
|
|
814
|
-
*/
|
|
815
|
-
private getJsonSchemaWithPrefix;
|
|
834
|
+
json(body: TResponseMap[keyof TResponseMap], schema?: RequestSchema): void;
|
|
816
835
|
/**
|
|
817
836
|
* Send a response with the given HTML, status defaults to 200
|
|
818
837
|
*/
|
|
@@ -839,15 +858,15 @@ declare class Response$1<TBody = any> {
|
|
|
839
858
|
/**
|
|
840
859
|
* 200 OK
|
|
841
860
|
*/
|
|
842
|
-
ok(body?:
|
|
861
|
+
ok(body?: ResponseBodyForStatus<TResponseMap, 200>): void;
|
|
843
862
|
/**
|
|
844
863
|
* 201 Created
|
|
845
864
|
*/
|
|
846
|
-
created(body?:
|
|
865
|
+
created(body?: ResponseBodyForStatus<TResponseMap, 201>): void;
|
|
847
866
|
/**
|
|
848
867
|
* 202 Accepted
|
|
849
868
|
*/
|
|
850
|
-
accepted(body?:
|
|
869
|
+
accepted(body?: ResponseBodyForStatus<TResponseMap, 202>): void;
|
|
851
870
|
/**
|
|
852
871
|
* 204 No Content
|
|
853
872
|
*/
|
|
@@ -855,7 +874,7 @@ declare class Response$1<TBody = any> {
|
|
|
855
874
|
/**
|
|
856
875
|
* 206 Partial Content
|
|
857
876
|
*/
|
|
858
|
-
partialContent(body?:
|
|
877
|
+
partialContent(body?: ResponseBodyForStatus<TResponseMap, 206>): void;
|
|
859
878
|
/**
|
|
860
879
|
* 3XX Redirection
|
|
861
880
|
*/
|
|
@@ -894,75 +913,75 @@ declare class Response$1<TBody = any> {
|
|
|
894
913
|
/**
|
|
895
914
|
* 400 Bad Request
|
|
896
915
|
*/
|
|
897
|
-
badRequest(body?:
|
|
916
|
+
badRequest(body?: ResponseBodyForStatus<TResponseMap, 400>): void;
|
|
898
917
|
/**
|
|
899
918
|
* 401 Unauthorized
|
|
900
919
|
*/
|
|
901
|
-
unauthorized(body?:
|
|
920
|
+
unauthorized(body?: ResponseBodyForStatus<TResponseMap, 401>): void;
|
|
902
921
|
/**
|
|
903
922
|
* 403 Forbidden
|
|
904
923
|
*/
|
|
905
|
-
forbidden(body?:
|
|
924
|
+
forbidden(body?: ResponseBodyForStatus<TResponseMap, 403>): void;
|
|
906
925
|
/**
|
|
907
926
|
* 404 Not Found
|
|
908
927
|
*/
|
|
909
|
-
notFound(body?:
|
|
928
|
+
notFound(body?: ResponseBodyForStatus<TResponseMap, 404>): void;
|
|
910
929
|
/**
|
|
911
930
|
* 405 Method Not Allowed
|
|
912
931
|
*/
|
|
913
|
-
methodNotAllowed(body?:
|
|
932
|
+
methodNotAllowed(body?: ResponseBodyForStatus<TResponseMap, 405>): void;
|
|
914
933
|
/**
|
|
915
934
|
* 406 Not Acceptable
|
|
916
935
|
*/
|
|
917
|
-
notAcceptable(body?:
|
|
936
|
+
notAcceptable(body?: ResponseBodyForStatus<TResponseMap, 406>): void;
|
|
918
937
|
/**
|
|
919
938
|
* 409 Conflict
|
|
920
939
|
*/
|
|
921
|
-
conflict(body?:
|
|
940
|
+
conflict(body?: ResponseBodyForStatus<TResponseMap, 409>): void;
|
|
922
941
|
/**
|
|
923
942
|
* 410 Gone
|
|
924
943
|
*/
|
|
925
|
-
gone(body?:
|
|
944
|
+
gone(body?: ResponseBodyForStatus<TResponseMap, 410>): void;
|
|
926
945
|
/**
|
|
927
946
|
* 413 Payload Too Large
|
|
928
947
|
*/
|
|
929
|
-
payloadTooLarge(body?:
|
|
948
|
+
payloadTooLarge(body?: ResponseBodyForStatus<TResponseMap, 413>): void;
|
|
930
949
|
/**
|
|
931
950
|
* 415 Unsupported Media Type
|
|
932
951
|
*/
|
|
933
|
-
unsupportedMediaType(body?:
|
|
952
|
+
unsupportedMediaType(body?: ResponseBodyForStatus<TResponseMap, 415>): void;
|
|
934
953
|
/**
|
|
935
954
|
* 422 Unprocessable Entity
|
|
936
955
|
*/
|
|
937
|
-
unprocessableEntity(body?:
|
|
956
|
+
unprocessableEntity(body?: ResponseBodyForStatus<TResponseMap, 422>): void;
|
|
938
957
|
/**
|
|
939
958
|
* 429 Too Many Requests
|
|
940
959
|
*/
|
|
941
|
-
tooManyRequests(body?:
|
|
960
|
+
tooManyRequests(body?: ResponseBodyForStatus<TResponseMap, 429>): void;
|
|
942
961
|
/**
|
|
943
962
|
* 5XX Server Errors
|
|
944
963
|
*/
|
|
945
|
-
internalServerError(body?:
|
|
964
|
+
internalServerError(body?: ResponseBodyForStatus<TResponseMap, 500>): void;
|
|
946
965
|
/**
|
|
947
966
|
* 501 Not Implemented
|
|
948
967
|
*/
|
|
949
|
-
notImplemented(body?:
|
|
968
|
+
notImplemented(body?: ResponseBodyForStatus<TResponseMap, 501>): void;
|
|
950
969
|
/**
|
|
951
970
|
* 502 Bad Gateway
|
|
952
971
|
*/
|
|
953
|
-
badGateway(body?:
|
|
972
|
+
badGateway(body?: ResponseBodyForStatus<TResponseMap, 502>): void;
|
|
954
973
|
/**
|
|
955
974
|
* 503 Service Unavailable
|
|
956
975
|
*/
|
|
957
|
-
serviceUnavailable(body?:
|
|
976
|
+
serviceUnavailable(body?: ResponseBodyForStatus<TResponseMap, 503>): void;
|
|
958
977
|
/**
|
|
959
978
|
* 504 Gateway Timeout
|
|
960
979
|
*/
|
|
961
|
-
gatewayTimeout(body?:
|
|
980
|
+
gatewayTimeout(body?: ResponseBodyForStatus<TResponseMap, 504>): void;
|
|
962
981
|
/**
|
|
963
982
|
* 505 HTTP Version Not Supported
|
|
964
983
|
*/
|
|
965
|
-
httpVersionNotSupported(body?:
|
|
984
|
+
httpVersionNotSupported(body?: ResponseBodyForStatus<TResponseMap, 505>): void;
|
|
966
985
|
/**
|
|
967
986
|
* Set a cookie for the response, cookie middleware must be registered in order to use this function
|
|
968
987
|
*/
|
|
@@ -983,22 +1002,14 @@ declare class Response$1<TBody = any> {
|
|
|
983
1002
|
* If a fast serializer is available and the body is an object, it will be serialized lazily.
|
|
984
1003
|
*/
|
|
985
1004
|
getBody(): any;
|
|
1005
|
+
/**
|
|
1006
|
+
* Converts any schema type to JSON Schema format with appropriate prefix.
|
|
1007
|
+
* @param schema - The schema to convert
|
|
1008
|
+
* @returns Object with JSON Schema and prefix
|
|
1009
|
+
*/
|
|
1010
|
+
private getJsonSchemaWithPrefix;
|
|
986
1011
|
}
|
|
987
1012
|
|
|
988
|
-
/**
|
|
989
|
-
* Extracts parameter names from a path string and creates a typed object
|
|
990
|
-
* @example ExtractParams<"/users/:id/posts/:postId"> → { id: string; postId: string }
|
|
991
|
-
*/
|
|
992
|
-
type ExtractParams<T extends string> = T extends `${infer _Start}:${infer Param}/${infer Rest}` ? {
|
|
993
|
-
[K in Param | keyof ExtractParams<Rest>]: string;
|
|
994
|
-
} : T extends `${infer _Start}:${infer Param}` ? {
|
|
995
|
-
[K in Param]: string;
|
|
996
|
-
} : Record<string, never>;
|
|
997
|
-
/**
|
|
998
|
-
* Helper type to infer the output type from a Zod schema, TypeBox schema, or any schema with _output
|
|
999
|
-
*/
|
|
1000
|
-
type InferSchemaType<T> = T extends ZodAny ? z.infer<T> : T extends TSchema ? Static<T> : T;
|
|
1001
|
-
|
|
1002
1013
|
/**
|
|
1003
1014
|
* Decorator to mark a handler for a DELETE request with type-safe path parameters and response body
|
|
1004
1015
|
* DELETE requests cannot have a request body (by HTTP spec)
|
|
@@ -1161,10 +1172,10 @@ declare const put: <TPath extends string = string>(path: TPath, options?: Swagge
|
|
|
1161
1172
|
* Type-safe handler for routes with typed path parameters and response
|
|
1162
1173
|
* Body and query are validated first and passed as separate typed arguments
|
|
1163
1174
|
* @example
|
|
1164
|
-
* TypedHandler<"/users/:id", CreateUserSchema, SearchQuerySchema, UserResponse>
|
|
1165
|
-
* → (req: Request<{ id: string }>, res: Response<UserResponse>, body: CreateUserInput, query: SearchQuery) => void | Promise<void>
|
|
1175
|
+
* TypedHandler<"/users/:id", CreateUserSchema, SearchQuerySchema, { 200: UserResponse }>
|
|
1176
|
+
* → (req: Request<{ id: string }>, res: Response<{ 200: UserResponse }>, body: CreateUserInput, query: SearchQuery) => void | Promise<void>
|
|
1166
1177
|
*/
|
|
1167
|
-
type TypedHandler<TPath extends string, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined,
|
|
1178
|
+
type TypedHandler<TPath extends string, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TResponseMap extends Record<number, any> = Record<number, any>> = (req: Request<ExtractParams<TPath>>, res: Response$1<TResponseMap>, ...args: [
|
|
1168
1179
|
...(TBody extends RequestSchema ? [body: InferSchemaType<TBody>] : []),
|
|
1169
1180
|
...(TQuery extends RequestSchema ? [query: InferSchemaType<TQuery>] : [])
|
|
1170
1181
|
]) => void | Promise<void>;
|
|
@@ -1302,37 +1313,37 @@ declare class Router {
|
|
|
1302
1313
|
* Register a GET route under this router's base path with type-safe path parameters.
|
|
1303
1314
|
*/
|
|
1304
1315
|
get<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath>): void;
|
|
1305
|
-
get<TPath extends string = string>(path: TPath, options: StandardMethodOptions
|
|
1316
|
+
get<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>>(path: TPath, options: StandardMethodOptions<TResponses>, handler: ControllerHandler<TPath, TResponses>): void;
|
|
1306
1317
|
/**
|
|
1307
1318
|
* Register a POST route under this router's base path with type-safe path parameters.
|
|
1308
1319
|
*/
|
|
1309
1320
|
post<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath>): void;
|
|
1310
|
-
post<TPath extends string = string>(path: TPath, options: StandardMethodOptions
|
|
1321
|
+
post<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>>(path: TPath, options: StandardMethodOptions<TResponses>, handler: ControllerHandler<TPath, TResponses>): void;
|
|
1311
1322
|
/**
|
|
1312
1323
|
* Register a PATCH route under this router's base path with type-safe path parameters.
|
|
1313
1324
|
*/
|
|
1314
1325
|
patch<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath>): void;
|
|
1315
|
-
patch<TPath extends string = string>(path: TPath, options: StandardMethodOptions
|
|
1326
|
+
patch<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>>(path: TPath, options: StandardMethodOptions<TResponses>, handler: ControllerHandler<TPath, TResponses>): void;
|
|
1316
1327
|
/**
|
|
1317
1328
|
* Register a PUT route under this router's base path with type-safe path parameters.
|
|
1318
1329
|
*/
|
|
1319
1330
|
put<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath>): void;
|
|
1320
|
-
put<TPath extends string = string>(path: TPath, options: StandardMethodOptions
|
|
1331
|
+
put<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>>(path: TPath, options: StandardMethodOptions<TResponses>, handler: ControllerHandler<TPath, TResponses>): void;
|
|
1321
1332
|
/**
|
|
1322
1333
|
* Register a DELETE route under this router's base path with type-safe path parameters.
|
|
1323
1334
|
*/
|
|
1324
1335
|
delete<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath>): void;
|
|
1325
|
-
delete<TPath extends string = string>(path: TPath, options: StandardMethodOptions
|
|
1336
|
+
delete<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>>(path: TPath, options: StandardMethodOptions<TResponses>, handler: ControllerHandler<TPath, TResponses>): void;
|
|
1326
1337
|
/**
|
|
1327
1338
|
* Register an OPTIONS route under this router's base path with type-safe path parameters.
|
|
1328
1339
|
*/
|
|
1329
1340
|
options<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath>): void;
|
|
1330
|
-
options<TPath extends string = string>(path: TPath, options: StandardMethodOptions
|
|
1341
|
+
options<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>>(path: TPath, options: StandardMethodOptions<TResponses>, handler: ControllerHandler<TPath, TResponses>): void;
|
|
1331
1342
|
/**
|
|
1332
1343
|
* Register an HEAD route under this router's base path with type-safe path parameters.
|
|
1333
1344
|
*/
|
|
1334
|
-
head<TPath extends string = string>(path: TPath, handler:
|
|
1335
|
-
head<TPath extends string = string>(path: TPath, options: StandardMethodOptions
|
|
1345
|
+
head<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath>): void;
|
|
1346
|
+
head<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>>(path: TPath, options: StandardMethodOptions<TResponses>, handler: ControllerHandler<TPath, TResponses>): void;
|
|
1336
1347
|
/**
|
|
1337
1348
|
* Create a grouped router that shares a base path and middlewares.
|
|
1338
1349
|
* The callback receives a child router where routes are defined; routes
|
|
@@ -1422,22 +1433,6 @@ declare class Server<H extends NodeHttpClient = NodeHttpClient> implements Serve
|
|
|
1422
1433
|
compareHash(hash: string, data: string): Promise<boolean>;
|
|
1423
1434
|
getEnvironment(): Record<string, string>;
|
|
1424
1435
|
tmpDir(...append: string[]): string;
|
|
1425
|
-
get<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath>): void;
|
|
1426
|
-
get<TPath extends string = string>(path: TPath, options: StandardMethodOptions, handler: ControllerHandler<TPath>): void;
|
|
1427
|
-
post<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath>): void;
|
|
1428
|
-
post<TPath extends string = string>(path: TPath, options: StandardMethodOptions, handler: ControllerHandler<TPath>): void;
|
|
1429
|
-
patch<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath>): void;
|
|
1430
|
-
patch<TPath extends string = string>(path: TPath, options: StandardMethodOptions, handler: ControllerHandler<TPath>): void;
|
|
1431
|
-
put<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath>): void;
|
|
1432
|
-
put<TPath extends string = string>(path: TPath, options: StandardMethodOptions, handler: ControllerHandler<TPath>): void;
|
|
1433
|
-
delete<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath>): void;
|
|
1434
|
-
delete<TPath extends string = string>(path: TPath, options: StandardMethodOptions, handler: ControllerHandler<TPath>): void;
|
|
1435
|
-
options<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath>): void;
|
|
1436
|
-
options<TPath extends string = string>(path: TPath, options: StandardMethodOptions, handler: ControllerHandler<TPath>): void;
|
|
1437
|
-
head<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath>): void;
|
|
1438
|
-
head<TPath extends string = string>(path: TPath, options: StandardMethodOptions, handler: ControllerHandler<TPath>): void;
|
|
1439
|
-
group(path: string, middleware: ServerRouteMiddleware[] | ServerRouteMiddleware, cb: (router: ClientRouter) => void): void;
|
|
1440
|
-
group(path: string, cb: (router: ClientRouter) => void): void;
|
|
1441
1436
|
getNodeServer(): RuntimeServerMap<"node", H>;
|
|
1442
1437
|
getBunServer(): RuntimeServerMap<"bun">;
|
|
1443
1438
|
getDenoServer(): RuntimeServerMap<"deno">;
|
|
@@ -1476,7 +1471,6 @@ declare class Server<H extends NodeHttpClient = NodeHttpClient> implements Serve
|
|
|
1476
1471
|
}): void;
|
|
1477
1472
|
getMockServer(options?: Pick<ServerOptions, "controllerPatterns">): Promise<MockServer>;
|
|
1478
1473
|
private importControllers;
|
|
1479
|
-
private extractOptionsAndHandlerFromRouteRegistration;
|
|
1480
1474
|
private applyPlugins;
|
|
1481
1475
|
/**
|
|
1482
1476
|
* Initializes the server by importing the controllers and applying the plugins, it's idempotent, it will not re-import the controllers or apply the plugins if the server was already initialized (e.g. mockServer init)
|
|
@@ -2171,38 +2165,6 @@ interface ServerInterface {
|
|
|
2171
2165
|
* @param expressRouter - The Express router to mount
|
|
2172
2166
|
*/
|
|
2173
2167
|
mountExpressRouter: (basePath: string, expressRouter: ExpressRouter) => void;
|
|
2174
|
-
/**
|
|
2175
|
-
* Shorthand for the router.get method
|
|
2176
|
-
*/
|
|
2177
|
-
get: (...args: any[]) => void;
|
|
2178
|
-
/**
|
|
2179
|
-
* Shorthand for the router.post method
|
|
2180
|
-
*/
|
|
2181
|
-
post: (...args: any[]) => void;
|
|
2182
|
-
/**
|
|
2183
|
-
* Shorthand for the router.put method
|
|
2184
|
-
*/
|
|
2185
|
-
put: (...args: any[]) => void;
|
|
2186
|
-
/**
|
|
2187
|
-
* Shorthand for the router.patch method
|
|
2188
|
-
*/
|
|
2189
|
-
patch: (...args: any[]) => void;
|
|
2190
|
-
/**
|
|
2191
|
-
* Shorthand for the router.delete method
|
|
2192
|
-
*/
|
|
2193
|
-
delete: (...args: any[]) => void;
|
|
2194
|
-
/**
|
|
2195
|
-
* Shorthand for the router.options method
|
|
2196
|
-
*/
|
|
2197
|
-
options: (...args: any[]) => void;
|
|
2198
|
-
/**
|
|
2199
|
-
* Shorthand for the router.head method
|
|
2200
|
-
*/
|
|
2201
|
-
head: (...args: any[]) => void;
|
|
2202
|
-
/**
|
|
2203
|
-
* Shorthand for the router.group method
|
|
2204
|
-
*/
|
|
2205
|
-
group: (...args: any[]) => void;
|
|
2206
2168
|
/**
|
|
2207
2169
|
* Get the node server instance, you must be using node runtime to use this method based on the nodeHttpClient option passed to the server constructor (defaults to http)
|
|
2208
2170
|
* @throws if the runtime is not node
|
|
@@ -2338,16 +2300,16 @@ interface ServerInterface {
|
|
|
2338
2300
|
*/
|
|
2339
2301
|
exit: (code?: number) => void;
|
|
2340
2302
|
}
|
|
2341
|
-
type StandardMethodOptions = {
|
|
2303
|
+
type StandardMethodOptions<TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>> = {
|
|
2342
2304
|
middlewares?: ServerRouteMiddleware[] | ServerRouteMiddleware;
|
|
2343
2305
|
body?: RequestSchema;
|
|
2344
2306
|
query?: RequestSchema;
|
|
2345
2307
|
all?: RequestSchema;
|
|
2346
|
-
swagger?: SwaggerRouteOptions
|
|
2308
|
+
swagger?: SwaggerRouteOptions<TResponses>;
|
|
2347
2309
|
};
|
|
2348
2310
|
type ServerHook = () => SyncOrAsync;
|
|
2349
2311
|
type SignalEvent = Deno.Signal | NodeJS.Signals;
|
|
2350
|
-
type ControllerHandler<TPath extends string = string> = (req: Request<ExtractParams<TPath>>, res: Response$1
|
|
2312
|
+
type ControllerHandler<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>> = (req: Request<ExtractParams<TPath>>, res: Response$1<InferResponseMap<TResponses>>, ...args: any[]) => ServerHandlerReturnType;
|
|
2351
2313
|
|
|
2352
2314
|
type RunTimeType = "bun" | "node" | "deno";
|
|
2353
2315
|
|
|
@@ -4074,4 +4036,4 @@ declare const createPolicyDecorator: <T extends Record<string, PolicyProvider>>(
|
|
|
4074
4036
|
*/
|
|
4075
4037
|
declare const router: ClientRouter;
|
|
4076
4038
|
|
|
4077
|
-
export { type AsyncLocalStorageContextSetters, AzureBlobStorageProvider, BaseCron, BasePlugin, type BaseStorageProviderOptions, type BlobStorageProviderOptions, BullMQConfiguration, type BullMQConfigurationOptions, BullMQPubSub, Command, type CommandOptions, CommandRegistry, type CompressionOptions, type CookieMiddlewareOptions, type CorsOptions, type CronSchedule, type CronScheduleParams, CronService, type CronUIOptions, CustomAdapter, type CustomQueueConfiguration, type CustomStorageProviderOptions, CustomTypedQueue, type CustomValidationError, EdgeAdapter, EjsAdapter, type ExtractParams, GraphQL, type GraphQLContext, type GraphQLOptions, type GraphQLResolverFunction, type GraphQLResolverMap, type GraphQLResolverType, type GraphQLResolvers, type GraphQLSchemaInput, type GraphQLTypeDef, HandlebarsAdapter, type HelmetOptions, type HttpMethod, type HttpsOptions, type InferSchemaType, LocalStorageProvider, type LocalStorageProviderOptions, type LogOptions, type LoggerOptions, type MailOptions, MailOptionsBuilder, MailProvider, type MailProviderInterface, Mailer, type MailerInterface, type MailerOptions, type MailerProviderOptions, MemoryPubSub, type MethodOverrideOptions, MockResponse, MockServer, type MockServerOptions, type MqttConnectionOptions, type MqttHandler, type MqttPublishOptions, MqttService, type MqttSubscribeOptions, type MqttSubscription, type MqttTopics, MustacheAdapter, type NextFunction, type NodeHttpClient, type NodeServer as NodeHttpServerClient, PGBossConfiguration, type PGBossConfigurationOptions, PGBossPubSub, type PolicyDecorator, PolicyManager, type PolicyProvider, type PublishTopic, QueueManager, QueueService, type RateLimiterKeyOptions, Request, type RequestSchema, Response$1 as Response, type RuntimeServer, S3StorageProvider, type S3StorageProviderOptions, SQSConfiguration, type SQSConfigurationOptions, SQSPubSub, type CacheMetrics as SchemaCacheMetrics, type SerializeOptions, Server, type ServerConnectInput, type ServerErrorHandler, type ServerHook, type ServerInterface, type ServerListenCallback, type ServerOptions, type ServerRouteHandler, type ServerRouteMiddleware, type ServerTapOptions, type SessionOptions, type SignalEvent, type StaticPluginOptions, Storage, type StorageInterface, type StorageOptions, type StorageProviderOptions, type TemplateMailOptions, type TimeoutOptions, type TrustProxyOptions, type TypedHandler, TypedQueue, type TypedRouteMetadata, type ValidatedData, type ValidationOptions, arg, asyncLocalStorage, asyncStorage, bullmqQueue, clearAllCaches as clearAllSchemaCaches, commandRegistry, compression, controller, cookie, cors, createExpressAdapter, createPolicyDecorator, createQueue, cron, Server as default, defineQueueConfiguration, del, expressHandler, expressMiddleware, flag, get, getCacheMetrics as getSchemaCacheMetrics, hash, helmet, log, logCacheMetrics as logSchemaCacheMetrics, logger, memoryQueue, methodOverride, middleware, mountExpressRouter, mqtt, patch, pgbossQueue, post, put, rateLimiter, router, serialize, serveStatic, session, setCronGlobalErrorHandler, setMqttGlobalErrorHandler, sqsQueue, timeout as timeoutMw, trustProxy, validate };
|
|
4039
|
+
export { type AsyncLocalStorageContextSetters, AzureBlobStorageProvider, BaseCron, BasePlugin, type BaseStorageProviderOptions, type BlobStorageProviderOptions, BullMQConfiguration, type BullMQConfigurationOptions, BullMQPubSub, Command, type CommandOptions, CommandRegistry, type CompressionOptions, type CookieMiddlewareOptions, type CorsOptions, type CronSchedule, type CronScheduleParams, CronService, type CronUIOptions, CustomAdapter, type CustomQueueConfiguration, type CustomStorageProviderOptions, CustomTypedQueue, type CustomValidationError, EdgeAdapter, EjsAdapter, type ExtractParams, GraphQL, type GraphQLContext, type GraphQLOptions, type GraphQLResolverFunction, type GraphQLResolverMap, type GraphQLResolverType, type GraphQLResolvers, type GraphQLSchemaInput, type GraphQLTypeDef, HandlebarsAdapter, type HelmetOptions, type HttpMethod, type HttpsOptions, type InferResponseMap, type InferSchemaType, LocalStorageProvider, type LocalStorageProviderOptions, type LogOptions, type LoggerOptions, type MailOptions, MailOptionsBuilder, MailProvider, type MailProviderInterface, Mailer, type MailerInterface, type MailerOptions, type MailerProviderOptions, MemoryPubSub, type MethodOverrideOptions, MockResponse, MockServer, type MockServerOptions, type MqttConnectionOptions, type MqttHandler, type MqttPublishOptions, MqttService, type MqttSubscribeOptions, type MqttSubscription, type MqttTopics, MustacheAdapter, type NextFunction, type NodeHttpClient, type NodeServer as NodeHttpServerClient, PGBossConfiguration, type PGBossConfigurationOptions, PGBossPubSub, type PolicyDecorator, PolicyManager, type PolicyProvider, type PublishTopic, QueueManager, QueueService, type RateLimiterKeyOptions, Request, type RequestSchema, Response$1 as Response, type ResponseBodyForStatus, type RuntimeServer, S3StorageProvider, type S3StorageProviderOptions, SQSConfiguration, type SQSConfigurationOptions, SQSPubSub, type CacheMetrics as SchemaCacheMetrics, type SerializeOptions, Server, type ServerConnectInput, type ServerErrorHandler, type ServerHook, type ServerInterface, type ServerListenCallback, type ServerOptions, type ServerRouteHandler, type ServerRouteMiddleware, type ServerTapOptions, type SessionOptions, type SignalEvent, type StaticPluginOptions, Storage, type StorageInterface, type StorageOptions, type StorageProviderOptions, type TemplateMailOptions, type TimeoutOptions, type TrustProxyOptions, type TypedHandler, TypedQueue, type TypedRouteMetadata, type ValidatedData, type ValidationOptions, arg, asyncLocalStorage, asyncStorage, bullmqQueue, clearAllCaches as clearAllSchemaCaches, commandRegistry, compression, controller, cookie, cors, createExpressAdapter, createPolicyDecorator, createQueue, cron, Server as default, defineQueueConfiguration, del, expressHandler, expressMiddleware, flag, get, getCacheMetrics as getSchemaCacheMetrics, hash, helmet, log, logCacheMetrics as logSchemaCacheMetrics, logger, memoryQueue, methodOverride, middleware, mountExpressRouter, mqtt, patch, pgbossQueue, post, put, rateLimiter, router, serialize, serveStatic, session, setCronGlobalErrorHandler, setMqttGlobalErrorHandler, sqsQueue, timeout as timeoutMw, trustProxy, validate };
|