@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/cli/index.js
CHANGED
|
@@ -2617,6 +2617,28 @@ function collectRouteSchemaSources(routes, rootDir) {
|
|
|
2617
2617
|
typeInfo: resolver.resolve(paramsArg.typeName) ?? null
|
|
2618
2618
|
});
|
|
2619
2619
|
}
|
|
2620
|
+
if (inputType === "body") {
|
|
2621
|
+
const queryArg = meta.params.find((p) => p.type === "query");
|
|
2622
|
+
if (queryArg?.typeName) {
|
|
2623
|
+
sources.push({
|
|
2624
|
+
urlPath: entry.urlPath,
|
|
2625
|
+
filePath,
|
|
2626
|
+
schemaName: getSchemaName(method, "query"),
|
|
2627
|
+
typeInfo: resolver.resolve(queryArg.typeName) ?? null
|
|
2628
|
+
});
|
|
2629
|
+
}
|
|
2630
|
+
} else if (hasBody(method)) {
|
|
2631
|
+
const bodyArg = meta.params.find((p) => p.type === "body") ?? meta.params.find((p) => p.type === "form");
|
|
2632
|
+
if (bodyArg?.typeName) {
|
|
2633
|
+
sources.push({
|
|
2634
|
+
urlPath: entry.urlPath,
|
|
2635
|
+
filePath,
|
|
2636
|
+
schemaName: getSchemaName(method, "body"),
|
|
2637
|
+
typeInfo: resolver.resolve(bodyArg.typeName) ?? null,
|
|
2638
|
+
coerce: bodyArg.type === "form" || void 0
|
|
2639
|
+
});
|
|
2640
|
+
}
|
|
2641
|
+
}
|
|
2620
2642
|
}
|
|
2621
2643
|
}
|
|
2622
2644
|
return { sources, resolversByFile };
|
|
@@ -8765,7 +8787,32 @@ function createRoutePipeline(opts) {
|
|
|
8765
8787
|
...paramsResult.data
|
|
8766
8788
|
} : match.params;
|
|
8767
8789
|
}
|
|
8768
|
-
|
|
8790
|
+
if (inputType === "body") {
|
|
8791
|
+
const rawQuery = queryToObject(url.searchParams);
|
|
8792
|
+
const queryResult = await validateInput(schemaPath, route.method, "query", rawQuery);
|
|
8793
|
+
if (!queryResult.valid) {
|
|
8794
|
+
throw new ValidationError("\u53C2\u6570\u6821\u9A8C\u5931\u8D25", queryResult.issues);
|
|
8795
|
+
}
|
|
8796
|
+
if (queryResult.data !== rawQuery && typeof queryResult.data === "object" && queryResult.data !== null) {
|
|
8797
|
+
ctx.__validatedQuery = {
|
|
8798
|
+
...rawQuery,
|
|
8799
|
+
...queryResult.data
|
|
8800
|
+
};
|
|
8801
|
+
}
|
|
8802
|
+
}
|
|
8803
|
+
let body;
|
|
8804
|
+
if (inputType === "query" && hasBody(route.method)) {
|
|
8805
|
+
const parsed = await resolveBodyForQueryMethod(request);
|
|
8806
|
+
if (parsed !== void 0) {
|
|
8807
|
+
const bodyResult = await validateInput(schemaPath, route.method, "body", parsed);
|
|
8808
|
+
if (!bodyResult.valid) {
|
|
8809
|
+
throw new ValidationError("\u53C2\u6570\u6821\u9A8C\u5931\u8D25", bodyResult.issues);
|
|
8810
|
+
}
|
|
8811
|
+
body = bodyResult.data;
|
|
8812
|
+
}
|
|
8813
|
+
} else if (hasBody(route.method)) {
|
|
8814
|
+
body = result.data;
|
|
8815
|
+
}
|
|
8769
8816
|
if (route.middlewares === void 0 && route.injectors === void 0 && route.middlewarePaths) {
|
|
8770
8817
|
await ensureMiddlewaresCompiled(route.middlewarePaths, rootDir);
|
|
8771
8818
|
const bundle = await loadMergedMiddlewares(route.middlewarePaths);
|
|
@@ -8855,6 +8902,7 @@ var init_createServer = __esm({
|
|
|
8855
8902
|
init_httpErrors();
|
|
8856
8903
|
init_validateInput();
|
|
8857
8904
|
init_inputType();
|
|
8905
|
+
init_queryToObject();
|
|
8858
8906
|
init_getClientIp();
|
|
8859
8907
|
init_cors();
|
|
8860
8908
|
init_helmet();
|