docs: fix imports across docs
This commit is contained in:
@@ -54,7 +54,7 @@ export const highlights = [
|
||||
import {
|
||||
defineMiddlewares,
|
||||
authenticate,
|
||||
} from "@medusajs/medusa"
|
||||
} from "@medusajs/framework/http"
|
||||
|
||||
export default defineMiddlewares({
|
||||
routes: [
|
||||
|
||||
@@ -192,7 +192,7 @@ export const middlewareHighlights = [
|
||||
import {
|
||||
defineMiddlewares,
|
||||
authenticate,
|
||||
} from "@medusajs/medusa"
|
||||
} from "@medusajs/framework/http"
|
||||
|
||||
export default defineMiddlewares({
|
||||
routes: [
|
||||
|
||||
@@ -128,7 +128,7 @@ To pass the `custom_name` in the `additional_data` parameter, you must add a val
|
||||
Create the file `src/api/middlewares.ts` with the following content:
|
||||
|
||||
```ts title="src/api/middlewares.ts"
|
||||
import { defineMiddlewares } from "@medusajs/medusa"
|
||||
import { defineMiddlewares } from "@medusajs/framework/http"
|
||||
import { z } from "zod"
|
||||
|
||||
export default defineMiddlewares({
|
||||
@@ -384,7 +384,7 @@ The `updateCartWorkflow` is executed by the [Update Cart API route](!api!/store#
|
||||
To allow passing `custom_name` in the `additional_data` parameter of the update cart route, add in `src/api/middlewares.ts` a new route middleware configuration object:
|
||||
|
||||
```ts title="src/api/middlewares.ts"
|
||||
import { defineMiddlewares } from "@medusajs/medusa"
|
||||
import { defineMiddlewares } from "@medusajs/framework/http"
|
||||
import { z } from "zod"
|
||||
|
||||
export default defineMiddlewares({
|
||||
|
||||
@@ -134,7 +134,7 @@ To pass the `custom_name` in the `additional_data` parameter, you must add a val
|
||||
Create the file `src/api/middlewares.ts` with the following content:
|
||||
|
||||
```ts title="src/api/middlewares.ts"
|
||||
import { defineMiddlewares } from "@medusajs/medusa"
|
||||
import { defineMiddlewares } from "@medusajs/framework/http"
|
||||
import { z } from "zod"
|
||||
|
||||
export default defineMiddlewares({
|
||||
@@ -396,7 +396,7 @@ The `updateCustomersWorkflow` is executed by the [Update Customer API route](!ap
|
||||
To allow passing `custom_name` in the `additional_data` parameter of the update customer route, add in `src/api/middlewares.ts` a new route middleware configuration object:
|
||||
|
||||
```ts title="src/api/middlewares.ts"
|
||||
import { defineMiddlewares } from "@medusajs/medusa"
|
||||
import { defineMiddlewares } from "@medusajs/framework/http"
|
||||
import { z } from "zod"
|
||||
|
||||
export default defineMiddlewares({
|
||||
|
||||
@@ -290,7 +290,7 @@ export async function POST(
|
||||
|
||||
```ts
|
||||
import { NextResponse } from "next/server"
|
||||
import { PriceListType } from "@medusajs/medusa"
|
||||
import { PriceListType } from "@medusajs/framework/utils"
|
||||
|
||||
import { initialize as initializePricingModule } from "@medusajs/medusa/pricing"
|
||||
import { PriceListType } from "@medusajs/framework/utils"
|
||||
|
||||
@@ -134,7 +134,7 @@ To pass the `custom_name` in the `additional_data` parameter, you must add a val
|
||||
Create the file `src/api/middlewares.ts` with the following content:
|
||||
|
||||
```ts title="src/api/middlewares.ts"
|
||||
import { defineMiddlewares } from "@medusajs/medusa"
|
||||
import { defineMiddlewares } from "@medusajs/framework/http"
|
||||
import { z } from "zod"
|
||||
|
||||
export default defineMiddlewares({
|
||||
@@ -402,7 +402,7 @@ The `updateProductsWorkflow` is executed by the [Update Product API route](!api!
|
||||
To allow passing `custom_name` in the `additional_data` parameter of the update product route, add in `src/api/middlewares.ts` a new route middleware configuration object:
|
||||
|
||||
```ts title="src/api/middlewares.ts"
|
||||
import { defineMiddlewares } from "@medusajs/medusa"
|
||||
import { defineMiddlewares } from "@medusajs/framework/http"
|
||||
import { z } from "zod"
|
||||
|
||||
export default defineMiddlewares({
|
||||
|
||||
@@ -134,7 +134,7 @@ To pass the `custom_name` in the `additional_data` parameter, you must add a val
|
||||
Create the file `src/api/middlewares.ts` with the following content:
|
||||
|
||||
```ts title="src/api/middlewares.ts"
|
||||
import { defineMiddlewares } from "@medusajs/medusa"
|
||||
import { defineMiddlewares } from "@medusajs/framework/http"
|
||||
import { z } from "zod"
|
||||
|
||||
export default defineMiddlewares({
|
||||
@@ -408,7 +408,7 @@ The `updatePromotionsWorkflow` is executed by the [Update Promotion API route](!
|
||||
To allow passing `custom_name` in the `additional_data` parameter of the update promotion route, add in `src/api/middlewares.ts` a new route middleware configuration object:
|
||||
|
||||
```ts title="src/api/middlewares.ts"
|
||||
import { defineMiddlewares } from "@medusajs/medusa"
|
||||
import { defineMiddlewares } from "@medusajs/framework/http"
|
||||
import { z } from "zod"
|
||||
|
||||
export default defineMiddlewares({
|
||||
|
||||
@@ -244,11 +244,11 @@ A middleware is a function executed when a request is sent to an API Route.
|
||||
Create the file `src/api/middlewares.ts` with the following content:
|
||||
|
||||
```ts title="src/api/middlewares.ts"
|
||||
import { defineMiddlewares } from "@medusajs/medusa"
|
||||
import type {
|
||||
MedusaNextFunction,
|
||||
MedusaRequest,
|
||||
MedusaResponse,
|
||||
defineMiddlewares,
|
||||
} from "@medusajs/framework/http"
|
||||
|
||||
export default defineMiddlewares({
|
||||
@@ -296,11 +296,11 @@ export const middlewareMethodHighlights = [
|
||||
]
|
||||
|
||||
```ts title="src/api/middlewares.ts" highlights={middlewareMethodHighlights}
|
||||
import { defineMiddlewares } from "@medusajs/medusa"
|
||||
import type {
|
||||
MedusaNextFunction,
|
||||
MedusaRequest,
|
||||
MedusaResponse,
|
||||
defineMiddlewares,
|
||||
} from "@medusajs/framework/http"
|
||||
|
||||
export default defineMiddlewares({
|
||||
@@ -331,9 +331,11 @@ export const PostStoreCustomSchema = z.object({
|
||||
|
||||
2. Add a validation middleware to the custom route in `src/api/middlewares.ts`:
|
||||
|
||||
```ts title="src/api/middlewares.ts" highlights={[["11", "validateAndTransformBody"]]}
|
||||
import { defineMiddlewares } from "@medusajs/medusa"
|
||||
import { validateAndTransformBody } from "@medusajs/framework/utils"
|
||||
```ts title="src/api/middlewares.ts" highlights={[["13", "validateAndTransformBody"]]}
|
||||
import {
|
||||
validateAndTransformBody,
|
||||
defineMiddlewares
|
||||
} from "@medusajs/framework/http"
|
||||
import { PostStoreCustomSchema } from "./custom/validators"
|
||||
|
||||
export default defineMiddlewares({
|
||||
@@ -385,7 +387,7 @@ Find this example in details in [this documentation](!docs!/learn/customization/
|
||||
1. Create the file `src/api/middlewares.ts` with the following content:
|
||||
|
||||
```ts title="src/api/middlewares.ts" highlights={[["10", "brand_id", "Replace with your custom field."]]}
|
||||
import { defineMiddlewares } from "@medusajs/medusa"
|
||||
import { defineMiddlewares } from "@medusajs/framework/http"
|
||||
import { z } from "zod"
|
||||
|
||||
export default defineMiddlewares({
|
||||
@@ -444,7 +446,7 @@ Add the following middleware in `src/api/middlewares.ts`:
|
||||
import {
|
||||
defineMiddlewares,
|
||||
authenticate,
|
||||
} from "@medusajs/medusa"
|
||||
} from "@medusajs/framework/http"
|
||||
|
||||
export default defineMiddlewares({
|
||||
routes: [
|
||||
@@ -473,7 +475,7 @@ Add the following middleware in `src/api/middlewares.ts`:
|
||||
import {
|
||||
defineMiddlewares,
|
||||
authenticate,
|
||||
} from "@medusajs/medusa"
|
||||
} from "@medusajs/framework/http"
|
||||
|
||||
export default defineMiddlewares({
|
||||
routes: [
|
||||
@@ -623,11 +625,11 @@ By default, Medusa configures CORS for all routes starting with `/admin`, `/stor
|
||||
To configure CORS for routes under other prefixes, create the file `src/api/middlewares.ts` with the following content:
|
||||
|
||||
```ts title="src/api/middlewares.ts"
|
||||
import { defineMiddlewares } from "@medusajs/medusa"
|
||||
import type {
|
||||
MedusaNextFunction,
|
||||
MedusaRequest,
|
||||
MedusaResponse,
|
||||
defineMiddlewares
|
||||
} from "@medusajs/framework/http"
|
||||
import { ConfigModule } from "@medusajs/framework/types"
|
||||
import { parseCorsOrigins } from "@medusajs/framework/utils"
|
||||
@@ -3444,7 +3446,7 @@ export async function POST(
|
||||
import {
|
||||
defineMiddlewares,
|
||||
authenticate,
|
||||
} from "@medusajs/medusa"
|
||||
} from "@medusajs/framework/http"
|
||||
|
||||
export default defineMiddlewares({
|
||||
routes: [
|
||||
|
||||
@@ -704,10 +704,10 @@ This defines the expected request body schema.
|
||||
Finally, create the file `src/api/middlewares.ts` with the following content:
|
||||
|
||||
```ts title="src/api/middlewares.ts"
|
||||
import { defineMiddlewares } from "@medusajs/medusa"
|
||||
import {
|
||||
defineMiddlewares,
|
||||
validateAndTransformBody,
|
||||
} from "@medusajs/framework"
|
||||
} from "@medusajs/framework/http"
|
||||
import { createDigitalProductsSchema } from "./validation-schemas"
|
||||
|
||||
export default defineMiddlewares({
|
||||
|
||||
@@ -345,7 +345,7 @@ 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 { defineMiddlewares } from "@medusajs/medusa"
|
||||
import { defineMiddlewares } from "@medusajs/framework/http"
|
||||
import { raw } from "body-parser"
|
||||
|
||||
export default defineMiddlewares({
|
||||
|
||||
@@ -967,7 +967,7 @@ Create the file `src/api/middlewares.ts` with the following content:
|
||||
import {
|
||||
authenticate,
|
||||
defineMiddlewares,
|
||||
} from "@medusajs/medusa"
|
||||
} from "@medusajs/framework/http"
|
||||
|
||||
export default defineMiddlewares({
|
||||
routes: [
|
||||
@@ -2646,7 +2646,7 @@ Then, create the file `src/api/deliveries/[id]/middlewares.ts` with the followin
|
||||
import {
|
||||
authenticate,
|
||||
defineMiddlewares,
|
||||
} from "@medusajs/medusa"
|
||||
} from "@medusajs/framework/http"
|
||||
import { isDeliveryRestaurant } from "../../utils/is-delivery-restaurant"
|
||||
|
||||
export default defineMiddlewares({
|
||||
|
||||
@@ -468,7 +468,7 @@ Next, create the file `src/api/middlewares.ts` with the following content:
|
||||
import {
|
||||
defineMiddlewares,
|
||||
authenticate,
|
||||
} from "@medusajs/medusa"
|
||||
} from "@medusajs/framework/http"
|
||||
|
||||
export default defineMiddlewares({
|
||||
routes: [
|
||||
@@ -723,10 +723,8 @@ Finally, in `src/api/middlewares.ts`, apply a middleware on the create products
|
||||
import {
|
||||
defineMiddlewares,
|
||||
authenticate,
|
||||
} from "@medusajs/medusa"
|
||||
import {
|
||||
validateAndTransformBody,
|
||||
} from "@medusajs/framework/utils"
|
||||
} from "@medusajs/framework/http"
|
||||
import {
|
||||
AdminCreateProduct,
|
||||
} from "@medusajs/medusa/api/admin/products/validators"
|
||||
|
||||
Reference in New Issue
Block a user