docs: fix import of defineMiddleware (#11293)

This commit is contained in:
Shahed Nasser authored and GitHub committed 2025-02-04 12:15:46 +02:00
1 parent ddaeafacdd
commit 70b3e16683
1 file changed
+5 -5
@@ -27,7 +27,7 @@ Middlewares are defined in the special file `src/api/middlewares.ts`. Use the `d
For example: For example:
```ts title="src/api/middlewares.ts" ```ts title="src/api/middlewares.ts"
import type { import {
defineMiddlewares, defineMiddlewares,
MedusaNextFunction, MedusaNextFunction,
MedusaRequest, MedusaRequest,
@@ -118,7 +118,7 @@ For example:
export const pathParamHighlights = [["11", ":id", "Indicates that the API route accepts an `id` path parameter."]] export const pathParamHighlights = [["11", ":id", "Indicates that the API route accepts an `id` path parameter."]]
```ts title="src/api/middlewares.ts" collapsibleLines="1-7" expandMoreLabel="Show Imports" highlights={pathParamHighlights} ```ts title="src/api/middlewares.ts" collapsibleLines="1-7" expandMoreLabel="Show Imports" highlights={pathParamHighlights}
import type { import {
MedusaNextFunction, MedusaNextFunction,
MedusaRequest, MedusaRequest,
MedusaResponse, MedusaResponse,
@@ -150,7 +150,7 @@ For example:
export const highlights = [["12", "method", "Apply the middleware only on `POST` requests"]] export const highlights = [["12", "method", "Apply the middleware only on `POST` requests"]]
```ts title="src/api/middlewares.ts" highlights={highlights} collapsibleLines="1-7" expandButtonLabel="Show Imports" ```ts title="src/api/middlewares.ts" highlights={highlights} collapsibleLines="1-7" expandButtonLabel="Show Imports"
import type { import {
MedusaNextFunction, MedusaNextFunction,
MedusaRequest, MedusaRequest,
MedusaResponse, MedusaResponse,
@@ -183,7 +183,7 @@ A middleware whose `matcher` pattern doesn't end with a backslash won't be appli
For example, consider you have the following middleware: For example, consider you have the following middleware:
```ts collapsibleLines="1-7" expandMoreLabel="Show Imports" ```ts collapsibleLines="1-7" expandMoreLabel="Show Imports"
import type { import {
MedusaNextFunction, MedusaNextFunction,
MedusaRequest, MedusaRequest,
MedusaResponse, MedusaResponse,
@@ -214,4 +214,4 @@ If you send a request to `http://localhost:9000/custom`, the middleware will run
However, if you send a request to `http://localhost:9000/custom/`, the middleware won't run. However, if you send a request to `http://localhost:9000/custom/`, the middleware won't run.
In general, avoid adding trailing backslashes when sending requests to API routes. In general, avoid adding trailing backslashes when sending requests to API routes.