fix: expand method ALL for bodyparser config and additional validator (#12612)

Fixes: FRMW-2969
This commit is contained in:
Harminder Virk
2025-05-26 15:52:26 +05:30
committed by GitHub
parent 7b3b4ff68a
commit 1f5f50010a
4 changed files with 36 additions and 2 deletions

View File

@@ -44,6 +44,14 @@ const middlewares = defineMiddlewares([
matcher: "/customers",
middlewares: [customersGlobalMiddleware],
},
{
method: ["ALL"],
matcher: "/v1*",
bodyParser: {
sizeLimit: "500kb",
},
middlewares: [],
},
{
method: "POST",
matcher: "/customers",

View File

@@ -9,6 +9,21 @@ describe("Middleware file loader", () => {
expect(loader.getBodyParserConfigRoutes()).toMatchInlineSnapshot(`
[
{
"config": {
"sizeLimit": "500kb",
},
"matcher": "/v1*",
"methods": [
"GET",
"POST",
"PUT",
"PATCH",
"DELETE",
"OPTIONS",
"HEAD",
],
},
{
"config": {
"preserveRawBody": true,

View File

@@ -86,7 +86,10 @@ export class MiddlewareFileLoader {
const matcher = String(route.matcher)
if (route.bodyParser !== undefined) {
const methods = route.methods || [...HTTP_METHODS]
let methods = route.methods || [...HTTP_METHODS]
if (methods.includes("ALL")) {
methods = [...HTTP_METHODS]
}
logger.debug(
`using custom bodyparser config on matcher ${methods}:${route.matcher}`
@@ -100,7 +103,10 @@ export class MiddlewareFileLoader {
}
if (route.additionalDataValidator !== undefined) {
const methods = route.methods || [...HTTP_METHODS]
let methods = route.methods || [...HTTP_METHODS]
if (methods.includes("ALL")) {
methods = [...HTTP_METHODS]
}
logger.debug(
`assigning additionalData validator on matcher ${methods}:${route.matcher}`