balda 0.0.11 → 0.0.13
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/index.cjs +38 -38
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +61 -58
- package/lib/index.d.ts +61 -58
- package/lib/index.js +38 -38
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.d.cts
CHANGED
|
@@ -610,6 +610,7 @@ type CookieMiddlewareOptions = {
|
|
|
610
610
|
* It also contains the methods to send the response.
|
|
611
611
|
*/
|
|
612
612
|
declare class Response$1 {
|
|
613
|
+
static toWebResponse(response: Response$1): globalThis.Response;
|
|
613
614
|
/**
|
|
614
615
|
* The node http response object available only on the node runtime, useful for direct response manipulation
|
|
615
616
|
* @warning undefined on other runtimes since they already use Web API Response object
|
|
@@ -974,64 +975,6 @@ declare class GraphQL {
|
|
|
974
975
|
private ensureTypeDefsArray;
|
|
975
976
|
}
|
|
976
977
|
|
|
977
|
-
declare class MockResponse<T = any> {
|
|
978
|
-
private readonly response;
|
|
979
|
-
constructor(response: Response$1);
|
|
980
|
-
body(): T;
|
|
981
|
-
statusCode(): number;
|
|
982
|
-
headers(): Record<string, string>;
|
|
983
|
-
assertStatus(status: number): this;
|
|
984
|
-
assertHeader(header: string, value: string): this;
|
|
985
|
-
assertHeaderExists(header: string): this;
|
|
986
|
-
assertHeaderNotExists(header: string): this;
|
|
987
|
-
assertBodySubset(subset: Partial<T>): this;
|
|
988
|
-
assertBodyDeepEqual(expected: T): this;
|
|
989
|
-
assertBodyNotSubset(subset: Partial<T>): this;
|
|
990
|
-
assertBodyNotDeepEqual(expected: T): this;
|
|
991
|
-
assertCustom(assertion: (response: Response$1) => void): this;
|
|
992
|
-
private assertSubset;
|
|
993
|
-
private assertDeepEqual;
|
|
994
|
-
private assertNotSubset;
|
|
995
|
-
private assertNotDeepEqual;
|
|
996
|
-
private assertArraySubset;
|
|
997
|
-
private assertArrayDeepEqual;
|
|
998
|
-
private isObject;
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
/**
|
|
1002
|
-
* The options for the mock server, only one of body, formData, urlencoded can be provided
|
|
1003
|
-
*/
|
|
1004
|
-
interface MockServerOptions {
|
|
1005
|
-
/**
|
|
1006
|
-
* The body of the request, if formData is provided, it will be ignored
|
|
1007
|
-
*/
|
|
1008
|
-
body?: any;
|
|
1009
|
-
/**
|
|
1010
|
-
* The form data of the request
|
|
1011
|
-
*/
|
|
1012
|
-
formData?: FormData;
|
|
1013
|
-
/**
|
|
1014
|
-
* The urlencoded body of the request
|
|
1015
|
-
*/
|
|
1016
|
-
urlencoded?: Record<string, string>;
|
|
1017
|
-
/**
|
|
1018
|
-
* The headers of the request
|
|
1019
|
-
*/
|
|
1020
|
-
headers?: Record<string, string>;
|
|
1021
|
-
/**
|
|
1022
|
-
* The query parameters of the request, if provided, they will be merged with the query parameters from the path (precedence is given to the query parameters provided here)
|
|
1023
|
-
*/
|
|
1024
|
-
query?: Record<string, string>;
|
|
1025
|
-
/**
|
|
1026
|
-
* The cookies of the request
|
|
1027
|
-
*/
|
|
1028
|
-
cookies?: Record<string, string>;
|
|
1029
|
-
/**
|
|
1030
|
-
* The ip of the request
|
|
1031
|
-
*/
|
|
1032
|
-
ip?: string;
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
978
|
/**
|
|
1036
979
|
* Singleton that handles the routing of requests to the appropriate handler(s).
|
|
1037
980
|
*/
|
|
@@ -1040,6 +983,7 @@ declare class Router {
|
|
|
1040
983
|
private routes;
|
|
1041
984
|
private middlewares;
|
|
1042
985
|
private basePath;
|
|
986
|
+
private staticRouteCache;
|
|
1043
987
|
/**
|
|
1044
988
|
* Create a new router with an optional base path and default middlewares.
|
|
1045
989
|
* Base path is normalized so it never produces duplicate slashes and never ends with a trailing slash (except root).
|
|
@@ -1055,6 +999,7 @@ declare class Router {
|
|
|
1055
999
|
/**
|
|
1056
1000
|
* Find the matching route for the given HTTP method and path.
|
|
1057
1001
|
* Returns the resolved middleware chain, handler, and extracted params; or null if not found.
|
|
1002
|
+
* Uses O(1) cache lookup for static routes, falls back to O(k) tree traversal for dynamic routes.
|
|
1058
1003
|
*/
|
|
1059
1004
|
find(method: string, rawPath: string): {
|
|
1060
1005
|
middleware: ServerRouteMiddleware[];
|
|
@@ -1229,6 +1174,64 @@ declare class Server<H extends NodeHttpClient = NodeHttpClient> implements Serve
|
|
|
1229
1174
|
private registerNotFoundRoutes;
|
|
1230
1175
|
}
|
|
1231
1176
|
|
|
1177
|
+
declare class MockResponse<T = any> {
|
|
1178
|
+
private readonly response;
|
|
1179
|
+
constructor(response: Response$1);
|
|
1180
|
+
body(): T;
|
|
1181
|
+
statusCode(): number;
|
|
1182
|
+
headers(): Record<string, string>;
|
|
1183
|
+
assertStatus(status: number): this;
|
|
1184
|
+
assertHeader(header: string, value: string): this;
|
|
1185
|
+
assertHeaderExists(header: string): this;
|
|
1186
|
+
assertHeaderNotExists(header: string): this;
|
|
1187
|
+
assertBodySubset(subset: Partial<T>): this;
|
|
1188
|
+
assertBodyDeepEqual(expected: T): this;
|
|
1189
|
+
assertBodyNotSubset(subset: Partial<T>): this;
|
|
1190
|
+
assertBodyNotDeepEqual(expected: T): this;
|
|
1191
|
+
assertCustom(assertion: (response: Response$1) => void): this;
|
|
1192
|
+
private assertSubset;
|
|
1193
|
+
private assertDeepEqual;
|
|
1194
|
+
private assertNotSubset;
|
|
1195
|
+
private assertNotDeepEqual;
|
|
1196
|
+
private assertArraySubset;
|
|
1197
|
+
private assertArrayDeepEqual;
|
|
1198
|
+
private isObject;
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
/**
|
|
1202
|
+
* The options for the mock server, only one of body, formData, urlencoded can be provided
|
|
1203
|
+
*/
|
|
1204
|
+
interface MockServerOptions {
|
|
1205
|
+
/**
|
|
1206
|
+
* The body of the request, if formData is provided, it will be ignored
|
|
1207
|
+
*/
|
|
1208
|
+
body?: any;
|
|
1209
|
+
/**
|
|
1210
|
+
* The form data of the request
|
|
1211
|
+
*/
|
|
1212
|
+
formData?: FormData;
|
|
1213
|
+
/**
|
|
1214
|
+
* The urlencoded body of the request
|
|
1215
|
+
*/
|
|
1216
|
+
urlencoded?: Record<string, string>;
|
|
1217
|
+
/**
|
|
1218
|
+
* The headers of the request
|
|
1219
|
+
*/
|
|
1220
|
+
headers?: Record<string, string>;
|
|
1221
|
+
/**
|
|
1222
|
+
* The query parameters of the request, if provided, they will be merged with the query parameters from the path (precedence is given to the query parameters provided here)
|
|
1223
|
+
*/
|
|
1224
|
+
query?: Record<string, string>;
|
|
1225
|
+
/**
|
|
1226
|
+
* The cookies of the request
|
|
1227
|
+
*/
|
|
1228
|
+
cookies?: Record<string, string>;
|
|
1229
|
+
/**
|
|
1230
|
+
* The ip of the request
|
|
1231
|
+
*/
|
|
1232
|
+
ip?: string;
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1232
1235
|
/**
|
|
1233
1236
|
* Allows to mock server requests without needing to start the server, useful for testing purposes
|
|
1234
1237
|
*/
|
package/lib/index.d.ts
CHANGED
|
@@ -610,6 +610,7 @@ type CookieMiddlewareOptions = {
|
|
|
610
610
|
* It also contains the methods to send the response.
|
|
611
611
|
*/
|
|
612
612
|
declare class Response$1 {
|
|
613
|
+
static toWebResponse(response: Response$1): globalThis.Response;
|
|
613
614
|
/**
|
|
614
615
|
* The node http response object available only on the node runtime, useful for direct response manipulation
|
|
615
616
|
* @warning undefined on other runtimes since they already use Web API Response object
|
|
@@ -974,64 +975,6 @@ declare class GraphQL {
|
|
|
974
975
|
private ensureTypeDefsArray;
|
|
975
976
|
}
|
|
976
977
|
|
|
977
|
-
declare class MockResponse<T = any> {
|
|
978
|
-
private readonly response;
|
|
979
|
-
constructor(response: Response$1);
|
|
980
|
-
body(): T;
|
|
981
|
-
statusCode(): number;
|
|
982
|
-
headers(): Record<string, string>;
|
|
983
|
-
assertStatus(status: number): this;
|
|
984
|
-
assertHeader(header: string, value: string): this;
|
|
985
|
-
assertHeaderExists(header: string): this;
|
|
986
|
-
assertHeaderNotExists(header: string): this;
|
|
987
|
-
assertBodySubset(subset: Partial<T>): this;
|
|
988
|
-
assertBodyDeepEqual(expected: T): this;
|
|
989
|
-
assertBodyNotSubset(subset: Partial<T>): this;
|
|
990
|
-
assertBodyNotDeepEqual(expected: T): this;
|
|
991
|
-
assertCustom(assertion: (response: Response$1) => void): this;
|
|
992
|
-
private assertSubset;
|
|
993
|
-
private assertDeepEqual;
|
|
994
|
-
private assertNotSubset;
|
|
995
|
-
private assertNotDeepEqual;
|
|
996
|
-
private assertArraySubset;
|
|
997
|
-
private assertArrayDeepEqual;
|
|
998
|
-
private isObject;
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
/**
|
|
1002
|
-
* The options for the mock server, only one of body, formData, urlencoded can be provided
|
|
1003
|
-
*/
|
|
1004
|
-
interface MockServerOptions {
|
|
1005
|
-
/**
|
|
1006
|
-
* The body of the request, if formData is provided, it will be ignored
|
|
1007
|
-
*/
|
|
1008
|
-
body?: any;
|
|
1009
|
-
/**
|
|
1010
|
-
* The form data of the request
|
|
1011
|
-
*/
|
|
1012
|
-
formData?: FormData;
|
|
1013
|
-
/**
|
|
1014
|
-
* The urlencoded body of the request
|
|
1015
|
-
*/
|
|
1016
|
-
urlencoded?: Record<string, string>;
|
|
1017
|
-
/**
|
|
1018
|
-
* The headers of the request
|
|
1019
|
-
*/
|
|
1020
|
-
headers?: Record<string, string>;
|
|
1021
|
-
/**
|
|
1022
|
-
* The query parameters of the request, if provided, they will be merged with the query parameters from the path (precedence is given to the query parameters provided here)
|
|
1023
|
-
*/
|
|
1024
|
-
query?: Record<string, string>;
|
|
1025
|
-
/**
|
|
1026
|
-
* The cookies of the request
|
|
1027
|
-
*/
|
|
1028
|
-
cookies?: Record<string, string>;
|
|
1029
|
-
/**
|
|
1030
|
-
* The ip of the request
|
|
1031
|
-
*/
|
|
1032
|
-
ip?: string;
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
978
|
/**
|
|
1036
979
|
* Singleton that handles the routing of requests to the appropriate handler(s).
|
|
1037
980
|
*/
|
|
@@ -1040,6 +983,7 @@ declare class Router {
|
|
|
1040
983
|
private routes;
|
|
1041
984
|
private middlewares;
|
|
1042
985
|
private basePath;
|
|
986
|
+
private staticRouteCache;
|
|
1043
987
|
/**
|
|
1044
988
|
* Create a new router with an optional base path and default middlewares.
|
|
1045
989
|
* Base path is normalized so it never produces duplicate slashes and never ends with a trailing slash (except root).
|
|
@@ -1055,6 +999,7 @@ declare class Router {
|
|
|
1055
999
|
/**
|
|
1056
1000
|
* Find the matching route for the given HTTP method and path.
|
|
1057
1001
|
* Returns the resolved middleware chain, handler, and extracted params; or null if not found.
|
|
1002
|
+
* Uses O(1) cache lookup for static routes, falls back to O(k) tree traversal for dynamic routes.
|
|
1058
1003
|
*/
|
|
1059
1004
|
find(method: string, rawPath: string): {
|
|
1060
1005
|
middleware: ServerRouteMiddleware[];
|
|
@@ -1229,6 +1174,64 @@ declare class Server<H extends NodeHttpClient = NodeHttpClient> implements Serve
|
|
|
1229
1174
|
private registerNotFoundRoutes;
|
|
1230
1175
|
}
|
|
1231
1176
|
|
|
1177
|
+
declare class MockResponse<T = any> {
|
|
1178
|
+
private readonly response;
|
|
1179
|
+
constructor(response: Response$1);
|
|
1180
|
+
body(): T;
|
|
1181
|
+
statusCode(): number;
|
|
1182
|
+
headers(): Record<string, string>;
|
|
1183
|
+
assertStatus(status: number): this;
|
|
1184
|
+
assertHeader(header: string, value: string): this;
|
|
1185
|
+
assertHeaderExists(header: string): this;
|
|
1186
|
+
assertHeaderNotExists(header: string): this;
|
|
1187
|
+
assertBodySubset(subset: Partial<T>): this;
|
|
1188
|
+
assertBodyDeepEqual(expected: T): this;
|
|
1189
|
+
assertBodyNotSubset(subset: Partial<T>): this;
|
|
1190
|
+
assertBodyNotDeepEqual(expected: T): this;
|
|
1191
|
+
assertCustom(assertion: (response: Response$1) => void): this;
|
|
1192
|
+
private assertSubset;
|
|
1193
|
+
private assertDeepEqual;
|
|
1194
|
+
private assertNotSubset;
|
|
1195
|
+
private assertNotDeepEqual;
|
|
1196
|
+
private assertArraySubset;
|
|
1197
|
+
private assertArrayDeepEqual;
|
|
1198
|
+
private isObject;
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
/**
|
|
1202
|
+
* The options for the mock server, only one of body, formData, urlencoded can be provided
|
|
1203
|
+
*/
|
|
1204
|
+
interface MockServerOptions {
|
|
1205
|
+
/**
|
|
1206
|
+
* The body of the request, if formData is provided, it will be ignored
|
|
1207
|
+
*/
|
|
1208
|
+
body?: any;
|
|
1209
|
+
/**
|
|
1210
|
+
* The form data of the request
|
|
1211
|
+
*/
|
|
1212
|
+
formData?: FormData;
|
|
1213
|
+
/**
|
|
1214
|
+
* The urlencoded body of the request
|
|
1215
|
+
*/
|
|
1216
|
+
urlencoded?: Record<string, string>;
|
|
1217
|
+
/**
|
|
1218
|
+
* The headers of the request
|
|
1219
|
+
*/
|
|
1220
|
+
headers?: Record<string, string>;
|
|
1221
|
+
/**
|
|
1222
|
+
* The query parameters of the request, if provided, they will be merged with the query parameters from the path (precedence is given to the query parameters provided here)
|
|
1223
|
+
*/
|
|
1224
|
+
query?: Record<string, string>;
|
|
1225
|
+
/**
|
|
1226
|
+
* The cookies of the request
|
|
1227
|
+
*/
|
|
1228
|
+
cookies?: Record<string, string>;
|
|
1229
|
+
/**
|
|
1230
|
+
* The ip of the request
|
|
1231
|
+
*/
|
|
1232
|
+
ip?: string;
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1232
1235
|
/**
|
|
1233
1236
|
* Allows to mock server requests without needing to start the server, useful for testing purposes
|
|
1234
1237
|
*/
|