docs: update middlewares to use defineMiddlewares (#8283)

This commit is contained in:
Shahed Nasser
2024-07-25 17:14:06 +02:00
committed by GitHub
parent 47c132c70b
commit eb64ae75a6
7 changed files with 51 additions and 39 deletions
@@ -347,10 +347,10 @@ For example, suppose an administrator changes the product data in the ERP system
Then, create the file `src/api/middlewares.ts` with the following content:
```ts title="src/api/middlewares.ts"
import { MiddlewaresConfig } from "@medusajs/medusa"
import { defineMiddlewares } from "@medusajs/medusa"
import { raw } from "body-parser"
export const config: MiddlewaresConfig = {
export default defineMiddlewares({
routes: [
{
method: ["POST", "PUT"],
@@ -359,7 +359,7 @@ For example, suppose an administrator changes the product data in the ERP system
middlewares: [raw({ type: "application/json" })],
},
],
}
})
```
This replaces the default JSON middleware with the raw middleware, which is useful for webhook routes.