fix: expand method ALL for bodyparser config and additional validator (#12612)
Fixes: FRMW-2969
This commit is contained in:
1 parent
7b3b4ff68a
commit
1f5f50010a
4 files changed
+36
-2
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/framework": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: expand method ALL for bodyparser config and additional validator
|
||||||
@@ -44,6 +44,14 @@ const middlewares = defineMiddlewares([
|
|||||||
matcher: "/customers",
|
matcher: "/customers",
|
||||||
middlewares: [customersGlobalMiddleware],
|
middlewares: [customersGlobalMiddleware],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
method: ["ALL"],
|
||||||
|
matcher: "/v1*",
|
||||||
|
bodyParser: {
|
||||||
|
sizeLimit: "500kb",
|
||||||
|
},
|
||||||
|
middlewares: [],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
method: "POST",
|
method: "POST",
|
||||||
matcher: "/customers",
|
matcher: "/customers",
|
||||||
|
|||||||
@@ -9,6 +9,21 @@ describe("Middleware file loader", () => {
|
|||||||
|
|
||||||
expect(loader.getBodyParserConfigRoutes()).toMatchInlineSnapshot(`
|
expect(loader.getBodyParserConfigRoutes()).toMatchInlineSnapshot(`
|
||||||
[
|
[
|
||||||
|
{
|
||||||
|
"config": {
|
||||||
|
"sizeLimit": "500kb",
|
||||||
|
},
|
||||||
|
"matcher": "/v1*",
|
||||||
|
"methods": [
|
||||||
|
"GET",
|
||||||
|
"POST",
|
||||||
|
"PUT",
|
||||||
|
"PATCH",
|
||||||
|
"DELETE",
|
||||||
|
"OPTIONS",
|
||||||
|
"HEAD",
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"config": {
|
"config": {
|
||||||
"preserveRawBody": true,
|
"preserveRawBody": true,
|
||||||
|
|||||||
@@ -86,7 +86,10 @@ export class MiddlewareFileLoader {
|
|||||||
const matcher = String(route.matcher)
|
const matcher = String(route.matcher)
|
||||||
|
|
||||||
if (route.bodyParser !== undefined) {
|
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(
|
logger.debug(
|
||||||
`using custom bodyparser config on matcher ${methods}:${route.matcher}`
|
`using custom bodyparser config on matcher ${methods}:${route.matcher}`
|
||||||
@@ -100,7 +103,10 @@ export class MiddlewareFileLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (route.additionalDataValidator !== undefined) {
|
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(
|
logger.debug(
|
||||||
`assigning additionalData validator on matcher ${methods}:${route.matcher}`
|
`assigning additionalData validator on matcher ${methods}:${route.matcher}`
|
||||||
|
|||||||
Reference in new issue
Block a user