fix: expand method ALL for bodyparser config and additional validator (#12612)
Fixes: FRMW-2969
This commit is contained in:
@@ -44,6 +44,14 @@ const middlewares = defineMiddlewares([
|
||||
matcher: "/customers",
|
||||
middlewares: [customersGlobalMiddleware],
|
||||
},
|
||||
{
|
||||
method: ["ALL"],
|
||||
matcher: "/v1*",
|
||||
bodyParser: {
|
||||
sizeLimit: "500kb",
|
||||
},
|
||||
middlewares: [],
|
||||
},
|
||||
{
|
||||
method: "POST",
|
||||
matcher: "/customers",
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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}`
|
||||
|
||||
Reference in New Issue
Block a user