@faapi/faapi 6.19.0 → 6.20.0
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/cli/index.js +49 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +48 -1
- package/dist/index.js.map +1 -1
- package/dist/testing.js +48 -1
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1228,6 +1228,28 @@ function collectRouteSchemaSources(routes, rootDir) {
|
|
|
1228
1228
|
typeInfo: resolver.resolve(paramsArg.typeName) ?? null
|
|
1229
1229
|
});
|
|
1230
1230
|
}
|
|
1231
|
+
if (inputType === "body") {
|
|
1232
|
+
const queryArg = meta.params.find((p) => p.type === "query");
|
|
1233
|
+
if (queryArg?.typeName) {
|
|
1234
|
+
sources.push({
|
|
1235
|
+
urlPath: entry.urlPath,
|
|
1236
|
+
filePath,
|
|
1237
|
+
schemaName: getSchemaName(method, "query"),
|
|
1238
|
+
typeInfo: resolver.resolve(queryArg.typeName) ?? null
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1241
|
+
} else if (hasBody(method)) {
|
|
1242
|
+
const bodyArg = meta.params.find((p) => p.type === "body") ?? meta.params.find((p) => p.type === "form");
|
|
1243
|
+
if (bodyArg?.typeName) {
|
|
1244
|
+
sources.push({
|
|
1245
|
+
urlPath: entry.urlPath,
|
|
1246
|
+
filePath,
|
|
1247
|
+
schemaName: getSchemaName(method, "body"),
|
|
1248
|
+
typeInfo: resolver.resolve(bodyArg.typeName) ?? null,
|
|
1249
|
+
coerce: bodyArg.type === "form" || void 0
|
|
1250
|
+
});
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1231
1253
|
}
|
|
1232
1254
|
}
|
|
1233
1255
|
return { sources, resolversByFile };
|
|
@@ -6343,7 +6365,32 @@ function createRoutePipeline(opts) {
|
|
|
6343
6365
|
...paramsResult.data
|
|
6344
6366
|
} : match.params;
|
|
6345
6367
|
}
|
|
6346
|
-
|
|
6368
|
+
if (inputType === "body") {
|
|
6369
|
+
const rawQuery = queryToObject(url.searchParams);
|
|
6370
|
+
const queryResult = await validateInput(schemaPath, route.method, "query", rawQuery);
|
|
6371
|
+
if (!queryResult.valid) {
|
|
6372
|
+
throw new ValidationError("\u53C2\u6570\u6821\u9A8C\u5931\u8D25", queryResult.issues);
|
|
6373
|
+
}
|
|
6374
|
+
if (queryResult.data !== rawQuery && typeof queryResult.data === "object" && queryResult.data !== null) {
|
|
6375
|
+
ctx.__validatedQuery = {
|
|
6376
|
+
...rawQuery,
|
|
6377
|
+
...queryResult.data
|
|
6378
|
+
};
|
|
6379
|
+
}
|
|
6380
|
+
}
|
|
6381
|
+
let body;
|
|
6382
|
+
if (inputType === "query" && hasBody(route.method)) {
|
|
6383
|
+
const parsed = await resolveBodyForQueryMethod(request);
|
|
6384
|
+
if (parsed !== void 0) {
|
|
6385
|
+
const bodyResult = await validateInput(schemaPath, route.method, "body", parsed);
|
|
6386
|
+
if (!bodyResult.valid) {
|
|
6387
|
+
throw new ValidationError("\u53C2\u6570\u6821\u9A8C\u5931\u8D25", bodyResult.issues);
|
|
6388
|
+
}
|
|
6389
|
+
body = bodyResult.data;
|
|
6390
|
+
}
|
|
6391
|
+
} else if (hasBody(route.method)) {
|
|
6392
|
+
body = result.data;
|
|
6393
|
+
}
|
|
6347
6394
|
if (route.middlewares === void 0 && route.injectors === void 0 && route.middlewarePaths) {
|
|
6348
6395
|
await ensureMiddlewaresCompiled(route.middlewarePaths, rootDir);
|
|
6349
6396
|
const bundle = await loadMergedMiddlewares(route.middlewarePaths);
|