docs: updates for breaking changes (#9558)

- Update modules registration
- Update `medusa-config.js` to `medusa-config.ts`
- Update the out directory in the admin deployment guide
- Update logger imports
- Other fixes

Note: will need to re-generate references afterwards

Closes #9548
This commit is contained in:
Shahed Nasser authored and GitHub committed 2024-10-14 10:40:30 +00:00
1 parent 2a9fc0e514
commit b6df24463d
53 files changed
+319 -324

No files matched your search

@@ -20,7 +20,7 @@ These configurations accept a URL pattern to identify allowed origins.
For example: For example:
```js title="medusa-config.js" ```js title="medusa-config.ts"
module.exports = defineConfig({ module.exports = defineConfig({
projectConfig: { projectConfig: {
http: { http: {
@@ -78,7 +78,7 @@ You can do that in the exported middlewares configurations in `src/api/middlewar
For example: For example:
export const highlights = [["25", "parseCorsOrigins", "A utility function that parses the CORS configurations in `medusa-config.js`"]] export const highlights = [["25", "parseCorsOrigins", "A utility function that parses the CORS configurations in `medusa-config.ts`"]]
```ts title="src/api/middlewares.ts" highlights={highlights} collapsibleLines="1-10" expandButtonLabel="Show Imports" ```ts title="src/api/middlewares.ts" highlights={highlights} collapsibleLines="1-10" expandButtonLabel="Show Imports"
import { defineMiddlewares } from "@medusajs/medusa" import { defineMiddlewares } from "@medusajs/medusa"
@@ -117,4 +117,4 @@ export default defineMiddlewares({
}) })
``` ```
This retrieves the configurations exported from `medusa-config.js` and applies the `storeCors` to routes starting with `/custom`. This retrieves the configurations exported from `medusa-config.ts` and applies the `storeCors` to routes starting with `/custom`.
@@ -27,7 +27,7 @@ A service's constructor accepts as a first parameter an object used to resolve r
For example: For example:
```ts highlights={[["4"], ["10"]]} ```ts highlights={[["4"], ["10"]]}
import { Logger } from "@medusajs/medusa" import { Logger } from "@medusajs/framework/types"
type InjectedDependencies = { type InjectedDependencies = {
logger: Logger logger: Logger
@@ -56,12 +56,14 @@ For example:
import { import {
LoaderOptions, LoaderOptions,
} from "@medusajs/framework/modules-sdk" } from "@medusajs/framework/modules-sdk"
import { Logger } from "@medusajs/medusa" import {
ContainerRegistrationKeys
} from "@medusajs/framework/utils"
export default async function helloWorldLoader({ export default async function helloWorldLoader({
container, container,
}: LoaderOptions) { }: LoaderOptions) {
const logger: Logger = container.resolve("logger") const logger = container.resolve(ContainerRegistrationKeys.LOGGER)
logger.info("[helloWorldLoader]: Hello, World!") logger.info("[helloWorldLoader]: Hello, World!")
} }
@@ -100,7 +100,7 @@ export class ClientService {
Your internal service can't access the module's options. Your internal service can't access the module's options.
To retrieve the module's options, use the `configModule` registered in the module's container, which is the configurations in `medusa-config.js`. To retrieve the module's options, use the `configModule` registered in the module's container, which is the configurations in `medusa-config.ts`.
For example: For example:
@@ -16,21 +16,21 @@ For example, if you’re creating a module that integrates a third-party service
## How to Pass Options to a Module? ## How to Pass Options to a Module?
To pass options to a module, add an `options` property to the module’s configuration in `medusa-config.js`. To pass options to a module, add an `options` property to the module’s configuration in `medusa-config.ts`.
For example: For example:
```js title="medusa-config.js" ```js title="medusa-config.ts"
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
helloModuleService: { {
resolve: "./modules/hello", resolve: "./modules/hello",
options: { options: {
capitalize: true, capitalize: true,
}, },
}, },
}, ]
}) })
``` ```
+8 -16
View File
@@ -118,37 +118,29 @@ export default Module(HELLO_MODULE, {
You use the `Module` function imported from `@medusajs/framework/utils` to create the module's definition. It accepts two parameters: You use the `Module` function imported from `@medusajs/framework/utils` to create the module's definition. It accepts two parameters:
1. The module's name. 1. The name that the module's main service is registered under (`helloModuleService`).
2. An object with a required property `service` indicating the module's main service. 2. An object with a required property `service` indicating the module's main service.
### 4. Add Module to Configurations ### 4. Add Module to Configurations
The last step is to add the module in Medusa’s configurations. The last step is to add the module in Medusa’s configurations.
In `medusa-config.js`, add a `modules` property and pass to it your custom module: In `medusa-config.ts`, add a `modules` property and pass in it your custom module:
```js title="medusa-config.js" highlights={[["6", "helloModuleService", "The key of the main service to be registered in the Medusa container."]]} ```ts title="medusa-config.ts" highlights={[["6", "helloModuleService", "The key of the main service to be registered in the Medusa container."]]}
module.exports = defineConfig({ module.exports = defineConfig({
projectConfig: { projectConfig: {
// ... // ...
}, },
modules: { modules: [
helloModuleService: { {
resolve: "./modules/hello", resolve: "./modules/hello",
}, }
}, ]
}) })
``` ```
The key `helloModuleService` is the name of the module’s main service. It will be registered in the Medusa container with that name. Its value is an array of objects, each having a `resolve` property, whose value is either a path to module's directory relative to `src` (it shouldn't include `src` in the path), or an `npm` package’s name.
<Note>
The key must be the same value passed as the first parameter to the `Module` function in the module's definition.
</Note>
Its value is an object having the `resolve` property, whose value is either a path to module's directory relative to `src` (it shouldn't include `src` in the path), or an `npm` package’s name.
### 5. Generate Migrations ### 5. Generate Migrations
@@ -18,6 +18,6 @@ This directory is the central place for your custom development. It includes the
- `subscribers`: Holds your event listeners that are executed asynchronously whenever an event is emitted. - `subscribers`: Holds your event listeners that are executed asynchronously whenever an event is emitted.
- `workflows`: Holds your custom flows that can be executed from anywhere in your application. - `workflows`: Holds your custom flows that can be executed from anywhere in your application.
## medusa-config.js ## medusa-config.ts
This file holds your Medusa configurations, such as your PostgreSQL database configurations. This file holds your Medusa configurations, such as your PostgreSQL database configurations.
@@ -97,16 +97,16 @@ Learn more about modules and services [in this guide](../../../basics/modules/pa
## 5. Register Module in Config ## 5. Register Module in Config
Finally, add the module to Medusa's configurations in `medusa-config.js`: Finally, add the module to Medusa's configurations in `medusa-config.ts`:
```js title="medusa-config.js" ```ts title="medusa-config.ts"
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
brandModuleService: { {
resolve: "./modules/brand", resolve: "./modules/brand",
}, }
}, ]
}) })
``` ```
@@ -61,7 +61,7 @@ export class BrandClient {
This creates a `BrandClient` service. Using dependency injection, you resolve the `logger` and `configModule` from the Module's container. This creates a `BrandClient` service. Using dependency injection, you resolve the `logger` and `configModule` from the Module's container.
`logger` is useful to log messages, and `configModule` has configurations exported in `medusa-config.js`. `logger` is useful to log messages, and `configModule` has configurations exported in `medusa-config.ts`.
You also define an `options_` property in your service to store the module's options. You also define an `options_` property in your service to store the module's options.
@@ -180,19 +180,19 @@ In the main module service, you first resolve through dependency injection the `
## 4. Pass Options to the Module ## 4. Pass Options to the Module
To pass options in the module, change its configurations in `medusa-config.js`: To pass options in the module, change its configurations in `medusa-config.ts`:
```js title="medusa-config.js" ```ts title="medusa-config.ts"
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
brandModuleService: { {
resolve: "./modules/brand", resolve: "./modules/brand",
options: { options: {
apiKey: process.env.BRAND_API_KEY || "temp", apiKey: process.env.BRAND_API_KEY || "temp",
}, },
}, },
}, ]
}) })
``` ```
@@ -44,14 +44,13 @@ Also, install the dependencies relevant for the exporter you use. If you're usin
npm install @opentelemetry/exporter-zipkin npm install @opentelemetry/exporter-zipkin
``` ```
### Add instrumentation.js ### Add instrumentation.ts
Next, create the file `instrumentation.js` with the following content: Next, create the file `instrumentation.ts` with the following content:
```js title="instrumentation.js" ```ts title="instrumentation.ts"
const { registerOtel } = require("@medusajs/medusa") import { registerOtel } from "@medusajs/medusa"
// If using an exporter other than Zipkin, require it here. import { ZipkinExporter } from "@opentelemetry/exporter-zipkin"
const { ZipkinExporter } = require("@opentelemetry/exporter-zipkin")
// If using an exporter other than Zipkin, initialize it here. // If using an exporter other than Zipkin, initialize it here.
const exporter = new ZipkinExporter({ const exporter = new ZipkinExporter({
@@ -72,7 +71,7 @@ export function register() {
} }
``` ```
In the `instrumentation.js` file, you export a `register` function that uses Medusa's `registerOtel` utility function. In the `instrumentation.ts` file, you export a `register` function that uses Medusa's `registerOtel` utility function.
You also initialize an instance of the exporter, such as Zipkin, and pass it to the `registerOtel` function. You also initialize an instance of the exporter, such as Zipkin, and pass it to the `registerOtel` function.
@@ -26,13 +26,13 @@ export const highlights = [
] ]
```ts title="src/jobs/log-message.ts" highlights={highlights} ```ts title="src/jobs/log-message.ts" highlights={highlights}
import { Logger } from "@medusajs/medusa"
import { MedusaContainer } from "@medusajs/framework/types" import { MedusaContainer } from "@medusajs/framework/types"
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
export default async function myCustomJob( export default async function myCustomJob(
container: MedusaContainer container: MedusaContainer
) { ) {
const logger: Logger = container.resolve("logger") const logger = container.resolve(ContainerRegistrationKeys.LOGGER)
logger.info("I'm using the logger!") logger.info("I'm using the logger!")
} }
@@ -129,11 +129,14 @@ The `Logger` class has an `activity` method used to log a message of level `info
For example: For example:
```ts title="src/loaders/log-message.ts" ```ts title="src/jobs/log-message.ts"
import { Logger, MedusaContainer } from "@medusajs/medusa" import { MedusaContainer } from "@medusajs/framework/types"
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
export default async (container: MedusaContainer) => { export default async function myCustomJob(
const logger = container.resolve<Logger>("logger") container: MedusaContainer
) {
const logger = container.resolve(ContainerRegistrationKeys.LOGGER)
const activityId = logger.activity("First log message") const activityId = logger.activity("First log message")
@@ -141,7 +144,6 @@ export default async (container: MedusaContainer) => {
logger.success(activityId, "Last log message") logger.success(activityId, "Last log message")
} }
``` ```
The `activity` method returns the ID of the started activity. This ID can then be passed to one of the following methods of the `Logger` class: The `activity` method returns the ID of the started activity. This ID can then be passed to one of the following methods of the `Logger` class:
@@ -148,25 +148,25 @@ This exports the module's definition, indicating that the `MyCacheService` is th
## 4. Use Module ## 4. Use Module
To use your Cache Module, add it to the `modules` object exported as part of the configurations in `medusa-config.js`. A Cache Module is added under the `cacheService` key. To use your Cache Module, add it to the `modules` object exported as part of the configurations in `medusa-config.ts`. A Cache Module is added under the `cacheService` key.
For example: For example:
```js title="medusa-config.js" ```ts title="medusa-config.ts"
const { Modules } = require("@medusajs/framework/utils") import { Modules } from "@medusajs/framework/utils"
// ... // ...
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
[Modules.CACHE]: { {
resolve: "./modules/my-cache", resolve: "./modules/my-cache",
options: { options: {
// any options // any options
ttl: 30, ttl: 30,
}, },
}, },
}, ]
}) })
``` ```
@@ -22,23 +22,22 @@ The In-Memory Cache Module is registered by default in your application.
</Note> </Note>
Add the module into the `modules` property of the exported object in `medusa-config.js`: Add the module into the `modules` property of the exported object in `medusa-config.ts`:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/framework/utils")
```ts title="medusa-config.ts"
import { Modules } from "@medusajs/framework/utils"
// ... // ...
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
[Modules.CACHE]: { {
resolve: "@medusajs/medusa/cache-inmemory", resolve: "@medusajs/cache-inmemory",
options: { options: {
// optional options // optional options
}, },
}, },
}, ]
}) })
``` ```
@@ -19,27 +19,27 @@ The Redis Cache Module uses Redis to cache data in your store. In production, it
} }
]} /> ]} />
Add the module into the `modules` property of the exported object in `medusa-config.js`: Add the module into the `modules` property of the exported object in `medusa-config.ts`:
export const highlights = [ export const highlights = [
["11", "redisUrl", "The Redis connection URL."] ["11", "redisUrl", "The Redis connection URL."]
] ]
```js title="medusa-config.js" highlights={highlights} ```ts title="medusa-config.ts" highlights={highlights}
const { Modules } = require("@medusajs/framework/utils") import { Modules } from "@medusajs/framework/utils"
// ... // ...
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
[Modules.CACHE]: { {
resolve: "@medusajs/medusa/cache-redis", resolve: "@medusajs/cache-redis",
options: { options: {
redisUrl: process.env.CACHE_REDIS_URL, redisUrl: process.env.CACHE_REDIS_URL,
}, },
}, },
}, ]
}) })
``` ```
@@ -103,24 +103,24 @@ This exports the module's definition, indicating that the `MyEventService` is th
## 4. Use Module ## 4. Use Module
To use your Event Module, add it to the `modules` object exported as part of the configurations in `medusa-config.js`. An Event Module is added under the `eventBus` key. To use your Event Module, add it to the `modules` object exported as part of the configurations in `medusa-config.ts`. An Event Module is added under the `eventBus` key.
For example: For example:
```js title="medusa-config.js" ```ts title="medusa-config.ts"
const { Modules } = require("@medusajs/framework/utils") import { Modules } from "@medusajs/framework/utils"
// ... // ...
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
[Modules.EVENT_BUS]: { {
resolve: "./modules/my-event", resolve: "./modules/my-event",
options: { options: {
// any options // any options
}, },
}, },
}, ]
}) })
``` ```
@@ -20,18 +20,20 @@ The Local Event Bus Module is registered by default in your application.
</Note> </Note>
Add the module into the `modules` property of the exported object in `medusa-config.js`: Add the module into the `modules` property of the exported object in `medusa-config.ts`:
```js title="medusa-config.js" ```ts title="medusa-config.ts"
const { Modules } = require("@medusajs/framework/utils") import { Modules } from "@medusajs/framework/utils"
// ... // ...
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
[Modules.EVENT_BUS]: true, {
}, resolve: "@medusajs/event-bus-local"
}
]
}) })
``` ```
@@ -23,27 +23,27 @@ In production, it's recommended to use this module.
} }
]} /> ]} />
Add the module into the `modules` property of the exported object in `medusa-config.js`: Add the module into the `modules` property of the exported object in `medusa-config.ts`:
export const highlights = [ export const highlights = [
["11", "redisUrl", "The Redis connection URL."] ["11", "redisUrl", "The Redis connection URL."]
] ]
```js title="medusa-config.js" ```ts title="medusa-config.ts"
const { Modules } = require("@medusajs/framework/utils") import { Modules } from "@medusajs/framework/utils"
// ... // ...
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
[Modules.EVENT_BUS]: { {
resolve: "@medusajs/medusa/event-bus-redis", resolve: "@medusajs/event-bus-redis",
options: { options: {
redisUrl: process.env.EVENTS_REDIS_URL, redisUrl: process.env.EVENTS_REDIS_URL,
}, },
}, }
}, ]
}) })
``` ```
@@ -32,20 +32,20 @@ The File Module accepts one provider only.
</Note> </Note>
```js title="medusa-config.js" ```ts title="medusa-config.ts"
const { Modules } = require("@medusajs/framework/utils") import { Modules } from "@medusajs/framework/utils"
// ... // ...
module.exports = { module.exports = {
// ... // ...
modules: { modules: [
[Modules.FILE]: { {
resolve: "@medusajs/medusa/file", resolve: "@medusajs/file",
options: { options: {
providers: [ providers: [
{ {
resolve: "@medusajs/medusa/file-local-next", resolve: "@medusajs/file-local-next",
id: "local", id: "local",
options: { options: {
// provider options... // provider options...
@@ -54,7 +54,7 @@ module.exports = {
], ],
}, },
}, },
}, ]
} }
``` ```
@@ -112,21 +112,21 @@ The File Module accepts one provider only.
</Note> </Note>
```js title="medusa-config.js" ```ts title="medusa-config.ts"
const { Modules } = require("@medusajs/framework/utils") import { Modules } from "@medusajs/framework/utils"
// ... // ...
module.exports = { module.exports = {
// ... // ...
modules: { modules: [
// ... // ...
[Modules.FILE]: { {
resolve: "@medusajs/medusa/file", resolve: "@medusajs/file",
options: { options: {
providers: [ providers: [
{ {
resolve: "@medusajs/medusa/file-s3", resolve: "@medusajs/file-s3",
id: "s3", id: "s3",
options: { options: {
file_url: process.env.S3_FILE_URL, file_url: process.env.S3_FILE_URL,
@@ -141,7 +141,7 @@ module.exports = {
], ],
}, },
}, },
}, ]
} }
``` ```
@@ -349,16 +349,16 @@ If you're using MinIO or Supabase, set `forcePathStyle` to `true` in the `additi
For example: For example:
```js title="medusa-config.js" ```ts title="medusa-config.ts"
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
[Modules.FILE]: { {
resolve: "@medusajs/medusa/file", resolve: "@medusajs/file",
options: { options: {
providers: [ providers: [
{ {
resolve: "@medusajs/medusa/file-s3", resolve: "@medusajs/file-s3",
id: "s3", id: "s3",
options: { options: {
// ... // ...
@@ -370,7 +370,7 @@ module.exports = defineConfig({
], ],
}, },
}, },
}, ]
}) })
``` ```
--- ---
@@ -26,21 +26,21 @@ Only one provider can be defined for a channel.
</Note> </Note>
```js title="medusa-config.js" ```ts title="medusa-config.ts"
const { Modules } = require("@medusajs/framework/utils") import { Modules } from "@medusajs/framework/utils"
// ... // ...
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
[Modules.NOTIFICATION]: { {
resolve: "@medusajs/medusa/notification", resolve: "@medusajs/notification",
options: { options: {
providers: [ providers: [
// ... // ...
{ {
resolve: "@medusajs/medusa/notification-local", resolve: "@medusajs/notification-local",
id: "local", id: "local",
options: { options: {
channels: ["email"], channels: ["email"],
@@ -49,7 +49,7 @@ module.exports = defineConfig({
], ],
}, },
}, },
}, ]
}) })
``` ```
@@ -30,22 +30,22 @@ When you send a notification, you specify the channel to send it through, such a
For example: For example:
```js title="medusa-config.js" highlights={[["19"]]} ```ts title="medusa-config.ts" highlights={[["19"]]}
const { Modules } = require("@medusajs/framework/utils") import { Modules } from "@medusajs/framework/utils"
// ... // ...
module.exports = { module.exports = {
// ... // ...
modules: { modules: [
// ... // ...
[Modules.NOTIFICATION]: { {
resolve: "@medusajs/medusa/notification", resolve: "@medusajs/notification",
options: { options: {
providers: [ providers: [
// ... // ...
{ {
resolve: "@medusajs/medusa/notification-local", resolve: "@medusajs/notification-local",
id: "notification", id: "notification",
options: { options: {
channels: ["email"], channels: ["email"],
@@ -54,7 +54,7 @@ module.exports = {
], ],
}, },
}, },
}, ]
} }
``` ```
@@ -37,21 +37,21 @@ Only one provider can be defined for a channel.
</Note> </Note>
```js title="medusa-config.js" ```ts title="medusa-config.ts"
const { Modules } = require("@medusajs/framework/utils") import { Modules } from "@medusajs/framework/utils"
// ... // ...
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
[Modules.NOTIFICATION]: { {
resolve: "@medusajs/medusa/notification", resolve: "@medusajs/notification",
options: { options: {
providers: [ providers: [
// ... // ...
{ {
resolve: "@medusajs/medusa/notification-sendgrid", resolve: "@medusajs/notification-sendgrid",
id: "sendgrid", id: "sendgrid",
options: { options: {
channels: ["email"], channels: ["email"],
@@ -62,7 +62,7 @@ module.exports = defineConfig({
], ],
}, },
}, },
}, ]
}) })
``` ```
@@ -22,17 +22,19 @@ The In-Memory Workflow Engine Module is registered by default in your applicatio
</Note> </Note>
Add the module into the `modules` property of the exported object in `medusa-config.js`: Add the module into the `modules` property of the exported object in `medusa-config.ts`:
```js title="medusa-config.js" ```ts title="medusa-config.ts"
const { Modules } = require("@medusajs/framework/utils") import { Modules } from "@medusajs/framework/utils"
// ... // ...
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
[Modules.WORKFLOW_ENGINE]: true, {
}, resolve: "@medusajs/workflow-engine-inmemory"
}
],
}) })
``` ```
@@ -19,21 +19,21 @@ The Redis Workflow Engine Module uses Redis to track workflow executions and han
} }
]} /> ]} />
Add the module into the `modules` property of the exported object in `medusa-config.js`: Add the module into the `modules` property of the exported object in `medusa-config.ts`:
export const highlights = [ export const highlights = [
["12", "url", "The Redis connection URL."] ["12", "url", "The Redis connection URL."]
] ]
```js title="medusa-config.js" highlights={highlights} ```ts title="medusa-config.ts" highlights={highlights}
const { Modules } = require("@medusajs/framework/utils") import { Modules } from "@medusajs/framework/utils"
// ... // ...
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
[Modules.WORKFLOW_ENGINE]: { {
resolve: "@medusajs/workflow-engine-redis", resolve: "@medusajs/workflow-engine-redis",
options: { options: {
redis: { redis: {
@@ -41,7 +41,7 @@ module.exports = defineConfig({
}, },
}, },
}, },
}, ]
}) })
``` ```
@@ -18,8 +18,8 @@ The Emailpass auth provider is registered by default with the Auth Module.
If you want to pass options to the provider, add the provider to the `providers` option of the Auth Module: If you want to pass options to the provider, add the provider to the `providers` option of the Auth Module:
```js title="medusa-config.js" ```ts title="medusa-config.ts"
const { Modules } = require("@medusajs/framework/utils") import { Modules } from "@medusajs/framework/utils"
// ... // ...
@@ -35,8 +35,8 @@ Learn about the authentication flow in [this guide](../../authentication-route/p
Add the module to the array of providers passed to the Auth Module: Add the module to the array of providers passed to the Auth Module:
```js title="medusa-config.js" ```ts title="medusa-config.ts"
const { Modules } = require("@medusajs/framework/utils") import { Modules } from "@medusajs/framework/utils"
// ... // ...
@@ -35,8 +35,8 @@ Learn about the authentication flow for third-party providers in [this guide](..
Add the module to the array of providers passed to the Auth Module: Add the module to the array of providers passed to the Auth Module:
```js title="medusa-config.js" ```ts title="medusa-config.ts"
const { Modules } = require("@medusajs/framework/utils") import { Modules } from "@medusajs/framework/utils"
// ... // ...
@@ -41,7 +41,7 @@ By default, users of all actor types can authenticate with all installed auth mo
To restrict the auth providers used for actor types, use the [authMethodsPerActor option](/references/medusa-config#http-authMethodsPerActor-1-3) in Medusa's configurations: To restrict the auth providers used for actor types, use the [authMethodsPerActor option](/references/medusa-config#http-authMethodsPerActor-1-3) in Medusa's configurations:
```js title="medusa-config.js" ```ts title="medusa-config.ts"
module.exports = defineConfig({ module.exports = defineConfig({
projectConfig: { projectConfig: {
http: { http: {
@@ -26,27 +26,29 @@ By default, the `emailpass` provider is registered to authenticate customers and
For example: For example:
```js title="medusa-config.js" ```ts title="medusa-config.ts"
const { Modules } = require("@medusajs/framework/utils") import { Modules } from "@medusajs/framework/utils"
// ... // ...
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
resolve: "@medusajs/medusa/auth", {
options: { resolve: "@medusajs/auth",
providers: [ options: {
{ providers: [
resolve: "@medusajs/medusa/auth-emailpass", {
id: "emailpass", resolve: "@medusajs/auth-emailpass",
options: { id: "emailpass",
// provider options... options: {
// provider options...
},
}, },
}, ],
], },
}, },
}, ]
}) })
``` ```
@@ -81,7 +81,7 @@ This defines a link between the `Cart` and `Custom` data models. Using this link
<Prerequisites <Prerequisites
items={[ items={[
{ {
text: "Module must be registered in medusa-config.js", text: "Module must be registered in medusa-config.ts",
link: "!docs!/basics/modules#4-add-module-to-configurations" link: "!docs!/basics/modules#4-add-module-to-configurations"
} }
]} ]}
@@ -87,7 +87,7 @@ This defines a link between the `Customer` and `Custom` data models. Using this
<Prerequisites <Prerequisites
items={[ items={[
{ {
text: "Module must be registered in medusa-config.js", text: "Module must be registered in medusa-config.ts",
link: "!docs!/basics/modules#4-add-module-to-configurations" link: "!docs!/basics/modules#4-add-module-to-configurations"
} }
]} ]}
@@ -20,20 +20,20 @@ When the Medusa application starts, these providers are registered and can be us
For example: For example:
```js title="medusa-config.js" ```ts title="medusa-config.ts"
const { Modules } = require("@medusajs/framework/utils") import { Modules } from "@medusajs/framework/utils"
// ... // ...
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
[Modules.FULFILLMENT]: { {
resolve: "@medusajs/medusa/fulfillment", resolve: "@medusajs/fulfillment",
options: { options: {
providers: [ providers: [
{ {
resolve: `@medusajs/medusa/fulfillment-manual`, resolve: `@medusajs/fulfillment-manual`,
id: "manual", id: "manual",
options: { options: {
// provider options... // provider options...
@@ -42,7 +42,7 @@ module.exports = defineConfig({
], ],
}, },
}, },
}, ]
}) })
``` ```
@@ -103,20 +103,20 @@ When the Medusa application starts, these providers are registered and can be us
For example: For example:
```js title="medusa-config.js" ```ts title="medusa-config.ts"
const { Modules } = require("@medusajs/framework/utils") import { Modules } from "@medusajs/framework/utils"
// ... // ...
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
[Modules.PAYMENT]: { {
resolve: "@medusajs/medusa/payment", resolve: "@medusajs/payment",
options: { options: {
providers: [ providers: [
{ {
resolve: "@medusajs/medusa/payment-stripe", resolve: "@medusajs/payment-stripe",
id: "stripe", id: "stripe",
options: { options: {
// ... // ...
@@ -125,7 +125,7 @@ module.exports = defineConfig({
], ],
}, },
}, },
}, ]
}) })
``` ```
@@ -31,20 +31,20 @@ In this document, you’ll learn about the Stripe Module Provider and how to ins
Add the module to the array of providers passed to the Payment Module: Add the module to the array of providers passed to the Payment Module:
```js title="medusa-config.js" ```ts title="medusa-config.ts"
const { Modules } = require("@medusajs/framework/utils") import { Modules } from "@medusajs/framework/utils"
// ... // ...
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
[Modules.PAYMENT]: { {
resolve: "@medusajs/medusa/payment", resolve: "@medusajs/payment",
options: { options: {
providers: [ providers: [
{ {
resolve: "@medusajs/medusa/payment-stripe", resolve: "@medusajs/payment-stripe",
id: "stripe", id: "stripe",
options: { options: {
apiKey: process.env.STRIPE_API_KEY, apiKey: process.env.STRIPE_API_KEY,
@@ -53,7 +53,7 @@ module.exports = defineConfig({
], ],
}, },
}, },
}, ]
}) })
``` ```
@@ -18,16 +18,16 @@ The `providers` option is an array of either tax module providers, tax plugins,
When the Medusa application starts, these providers are registered and can be used to retrieve tax lines. When the Medusa application starts, these providers are registered and can be used to retrieve tax lines.
```js title="medusa-config.js" ```ts title="medusa-config.ts"
const { Modules } = require("@medusajs/framework/utils") import { Modules } from "@medusajs/framework/utils"
// ... // ...
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
[Modules.TAX]: { {
resolve: "@medusajs/medusa/tax", resolve: "@medusajs/tax",
options: { options: {
providers: [ providers: [
{ {
@@ -40,7 +40,7 @@ module.exports = defineConfig({
], ],
}, },
}, },
}, ]
}) })
``` ```
@@ -14,21 +14,21 @@ In this document, you'll learn about the options of the User Module.
## Module Options ## Module Options
```js title="medusa-config.js" ```ts title="medusa-config.ts"
const { Modules } = require("@medusajs/framework/utils") import { Modules } from "@medusajs/framework/utils"
// ... // ...
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
[Modules.USER]: { {
resolve: "@medusajs/medusa/user", resolve: "@medusajs/user",
options: { options: {
jwt_secret: process.env.JWT_SECRET, jwt_secret: process.env.JWT_SECRET,
}, },
}, },
}, ]
}) })
``` ```
@@ -33,9 +33,9 @@ As Medusa v2 is still in active development, it's highly recommended not to depl
## 1. Configure Admin in Medusa ## 1. Configure Admin in Medusa
In `medusa-config.js`, set the following admin configuration: In `medusa-config.ts`, set the following admin configuration:
```js title="medusa-config.js" ```ts title="medusa-config.ts"
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
admin: { admin: {
@@ -89,7 +89,7 @@ To create a Vercel project, on your Vercel dashboard:
npm run build npm run build
``` ```
- Set the Output Directory field to `build`. - Set the Output Directory field to `.medusa/admin`.
- Set the Install Command field to the following: - Set the Install Command field to the following:
```bash npm2yarn ```bash npm2yarn
@@ -48,9 +48,9 @@ The same Medusa project is used to deploy the server and worker modes. Learn mor
The `workerMode` configuration determines which mode the Medusa application runs in. As mentioned at the beginning of this guide, you’ll deploy two Medusa applications: one in server mode, and one in worker mode. The `workerMode` configuration determines which mode the Medusa application runs in. As mentioned at the beginning of this guide, you’ll deploy two Medusa applications: one in server mode, and one in worker mode.
So, add the following configuration in `medusa-config.js`: So, add the following configuration in `medusa-config.ts`:
```js title="medusa-config.js" ```ts title="medusa-config.ts"
module.exports = defineConfig({ module.exports = defineConfig({
projectConfig: { projectConfig: {
// ... // ...
@@ -74,9 +74,9 @@ To host the admin with the Medusa application, the hosting provider and plan sho
</Note> </Note>
Add the following configuration in `medusa-config.js`: Add the following configuration in `medusa-config.ts`:
```js title="medusa-config.js" ```ts title="medusa-config.ts"
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
admin: { admin: {
@@ -89,9 +89,9 @@ Later, you’ll set different values of the `DISABLE_MEDUSA_ADMIN` environment v
### Configure Redis URL ### Configure Redis URL
Add the following configuration in `medusa-config.js` : Add the following configuration in `medusa-config.ts` :
```js title="medusa-config.js" ```ts title="medusa-config.ts"
module.exports = defineConfig({ module.exports = defineConfig({
projectConfig: { projectConfig: {
// ... // ...
@@ -134,34 +134,33 @@ For example, add the following dependencies in `package.json` for the Cache, Eve
```json ```json
"dependencies": { "dependencies": {
// ... // ...
"@medusajs/medusa/cache-redis": "rc", "@medusajs/cache-redis": "rc",
"@medusajs/medusa/event-bus-redis": "rc", "@medusajs/event-bus-redis": "rc",
"@medusajs/workflow-engine-redis": "rc" "@medusajs/workflow-engine-redis": "rc"
} }
``` ```
Then, add these modules in `medusa-config.js`: Then, add these modules in `medusa-config.ts`:
```js title="medusa-config.js" ```ts title="medusa-config.ts"
const { Modules } = require("@medusajs/framework/utils") import { Modules } from "@medusajs/framework/utils"
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
// ... {
[Modules.CACHE]: { resolve: "@medusajs/cache-redis",
resolve: "@medusajs/medusa/cache-redis",
options: { options: {
redisUrl: process.env.REDIS_URL, redisUrl: process.env.REDIS_URL,
}, },
}, },
[Modules.EVENT_BUS]: { {
resolve: "@medusajs/medusa/event-bus-redis", resolve: "@medusajs/event-bus-redis",
options: { options: {
redisUrl: process.env.REDIS_URL, redisUrl: process.env.REDIS_URL,
}, },
}, },
[Modules.WORKFLOW_ENGINE]: { {
resolve: "@medusajs/workflow-engine-redis", resolve: "@medusajs/workflow-engine-redis",
options: { options: {
redis: { redis: {
@@ -169,7 +168,7 @@ module.exports = defineConfig({
}, },
}, },
}, },
}, ]
}) })
``` ```
@@ -286,9 +285,9 @@ You can either generate a random domain name or set a custom one. To do that:
If you’re deploying the Medusa application in server mode with the admin, you have to make some changes now that you’ve obtained the application’s URL. If you’re deploying the Medusa application in server mode with the admin, you have to make some changes now that you’ve obtained the application’s URL.
First, add the following configuration to `medusa-config.js`: First, add the following configuration to `medusa-config.ts`:
```js title="medusa-config.js" ```ts title="medusa-config.ts"
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
admin: { admin: {
@@ -48,7 +48,7 @@ Use the `ContainerRegistrationKeys` enum imported from `@medusajs/framework/util
</Table.Cell> </Table.Cell>
<Table.Cell> <Table.Cell>
The configurations that are exported from `medusa-config.js`. The configurations that are exported from `medusa-config.ts`.
</Table.Cell> </Table.Cell>
<Table.Cell> <Table.Cell>
@@ -120,12 +120,12 @@ Use the `ContainerRegistrationKeys` enum imported from `@medusajs/framework/util
</Table.Cell> </Table.Cell>
<Table.Cell> <Table.Cell>
The main service of every module added in `medusa-config.js`. The main service of every module added in `medusa-config.ts`.
</Table.Cell> </Table.Cell>
<Table.Cell> <Table.Cell>
- For custom modules, the registration name is the key of the module in the `modules` configuration in `medusa-config.js`. - For custom modules, the registration name is the key of the module in the `modules` configuration in `medusa-config.ts`.
- For Medusa's commerce modules, use the `Modules` enum imported from `@medusajs/framework/utils`. - For Medusa's commerce modules, use the `Modules` enum imported from `@medusajs/framework/utils`.
</Table.Cell> </Table.Cell>
@@ -229,7 +229,7 @@ Use the `ContainerRegistrationKeys` enum imported from `@medusajs/framework/util
</Table.Cell> </Table.Cell>
<Table.Cell> <Table.Cell>
The configurations exported from `medusa-config.js`. The configurations exported from `medusa-config.ts`.
</Table.Cell> </Table.Cell>
<Table.Cell> <Table.Cell>
@@ -150,19 +150,16 @@ export const restockModelHighlights = [
}) })
``` ```
Finally, add the module to the `modules` object in `medusa-config.js`: Finally, add the module to the `modules` object in `medusa-config.ts`:
```js title="medusa-config.js" ```ts title="medusa-config.ts"
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
"restockNotificationModuleService": { {
resolve: "./modules/restock-notification", resolve: "./modules/restock-notification",
definition: {
isQueryable: true,
},
}, },
}, ]
}) })
``` ```
@@ -189,16 +189,16 @@ export default Module(DIGITAL_PRODUCT_MODULE, {
### Add Module to Medusa Configuration ### Add Module to Medusa Configuration
Finally, add the module to the list of modules in `medusa-config.js`: Finally, add the module to the list of modules in `medusa-config.ts`:
```tsx title="medusa-config.js" ```ts title="medusa-config.ts"
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
digitalProductModuleService: { {
resolve: "./modules/digital-product", resolve: "./modules/digital-product",
}, },
}, ]
}) })
``` ```
@@ -1502,21 +1502,21 @@ export default providerExport
### Register Module Provider in Medusa's Configurations ### Register Module Provider in Medusa's Configurations
Finally, register the module provider in `medusa-config.js`: Finally, register the module provider in `medusa-config.ts`:
```js title="medusa-config.js" ```ts title="medusa-config.ts"
// other imports... // other imports...
const { Modules } = require("@medusajs/framework/utils") import { Modules } from "@medusajs/framework/utils"
module.exports = defineConfig({ module.exports = defineConfig({
modules: { modules: [
// ... // ...
[Modules.FULFILLMENT]: { {
resolve: "@medusajs/medusa/fulfillment", resolve: "@medusajs/fulfillment",
options: { options: {
providers: [ providers: [
{ {
resolve: "@medusajs/medusa/fulfillment-manual", resolve: "@medusajs/fulfillment-manual",
id: "manual", id: "manual",
}, },
{ {
@@ -1526,7 +1526,7 @@ module.exports = defineConfig({
], ],
}, },
}, },
}, ]
}) })
``` ```
@@ -2000,19 +2000,19 @@ In the `sendDigitalOrderNotificationStep`, you use a notification provider confi
Check out the [Integrations page](../../../../integrations/page.mdx) to find Notification Module Providers. Check out the [Integrations page](../../../../integrations/page.mdx) to find Notification Module Providers.
For testing purposes, add to `medusa-config.js` the following to use the Local Notification Module Provider: For testing purposes, add to `medusa-config.ts` the following to use the Local Notification Module Provider:
```js title="medusa-config.js" ```ts title="medusa-config.ts"
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
// ... // ...
[Modules.NOTIFICATION]: { {
resolve: "@medusajs/medusa/notification", resolve: "@medusajs/notification",
options: { options: {
providers: [ providers: [
{ {
resolve: "@medusajs/medusa/notification-local", resolve: "@medusajs/notification-local",
id: "local", id: "local",
options: { options: {
name: "Local Notification Provider", name: "Local Notification Provider",
@@ -2022,7 +2022,7 @@ module.exports = defineConfig({
], ],
}, },
}, },
}, ]
}) })
``` ```
@@ -116,19 +116,19 @@ export const serviceHighlights = [
}) })
``` ```
Finally, add the module to the `modules` object in `medusa-config.js`: Finally, add the module to the `modules` object in `medusa-config.ts`:
```js title="medusa-config.js" highlights={[["7", "ERP_API_KEY", "The environment variable holding the API key of the ERP system."]]} ```ts title="medusa-config.ts" highlights={[["7", "ERP_API_KEY", "The environment variable holding the API key of the ERP system."]]}
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
erpModuleService: { {
resolve: "./modules/erp", resolve: "./modules/erp",
options: { options: {
apiKey: process.env.ERP_API_KEY, apiKey: process.env.ERP_API_KEY,
}, },
}, },
}, ]
}) })
``` ```
@@ -155,16 +155,16 @@ export default Module(RESTAURANT_MODULE, {
### Add Restaurant Module to Medusa Configuration ### Add Restaurant Module to Medusa Configuration
Finally, add the module to the list of modules in `medusa-config.js`: Finally, add the module to the list of modules in `medusa-config.ts`:
```js title="medusa-config.js" ```ts title="medusa-config.ts"
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
restaurantModuleService: { {
resolve: "./modules/restaurant", resolve: "./modules/restaurant",
}, },
}, ]
}) })
``` ```
@@ -299,17 +299,16 @@ export default Module(DELIVERY_MODULE, {
### Add Delivery Module to Medusa Configuration ### Add Delivery Module to Medusa Configuration
Finally, add the module to the list of modules in `medusa-config.js`: Finally, add the module to the list of modules in `medusa-config.ts`:
```js title="medusa-config.js" ```ts title="medusa-config.ts"
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
deliveryModuleService: { {
resolve: "./modules/delivery", resolve: "./modules/delivery",
}, },
// ... ]
},
}) })
``` ```
@@ -135,16 +135,16 @@ export default Module(MARKETPLACE_MODULE, {
### Add Module to Medusa Configuration ### Add Module to Medusa Configuration
Finally, add the module to the list of modules in `medusa-config.js`: Finally, add the module to the list of modules in `medusa-config.ts`:
```ts title="medusa-config.js" ```ts title="medusa-config.ts"
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
marketplaceModuleService: { {
resolve: "./modules/marketplace", resolve: "./modules/marketplace",
}, },
}, ]
}) })
``` ```
@@ -153,16 +153,16 @@ This sets the module’s name to `subscriptionModuleService` and its main servic
### Register Module in Medusa’s Configuration ### Register Module in Medusa’s Configuration
Finally, add the module into `medusa-config.js`: Finally, add the module into `medusa-config.ts`:
```ts title="medusa-config.js" ```ts title="medusa-config.ts"
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
subscriptionModuleService: { {
resolve: "./modules/subscription", resolve: "./modules/subscription",
}, },
}, ]
}) })
``` ```
@@ -36,11 +36,11 @@ npm install @medusajs/types@rc
## Configure CORS ## Configure CORS
The Medusa application’s API routes are guarded by a CORS middleware. Make sure to set the `storeCors` property of the `http` configuration in `medusa-config.js` to the storefront’s URL. The Medusa application’s API routes are guarded by a CORS middleware. Make sure to set the `storeCors` property of the `http` configuration in `medusa-config.ts` to the storefront’s URL.
For example: For example:
```js title="medusa-config.js" ```ts title="medusa-config.ts"
module.exports = defineConfig({ module.exports = defineConfig({
projectConfig: { projectConfig: {
http: { http: {
@@ -4,9 +4,9 @@ You might see a log in your browser console, that looks like this:
![CORS error log](https://res.cloudinary.com/dza7lstvk/image/upload/v1668003322/Medusa%20Docs/Other/jnHK115_udgf2n.png) ![CORS error log](https://res.cloudinary.com/dza7lstvk/image/upload/v1668003322/Medusa%20Docs/Other/jnHK115_udgf2n.png)
In your `medusa-config.js` , you should ensure that you've configured your CORS settings correctly: In your `medusa-config.ts` , you should ensure that you've configured your CORS settings correctly:
```js title="medusa-config.js" ```ts title="medusa-config.ts"
module.exports = defineConfig({ module.exports = defineConfig({
projectConfig: { projectConfig: {
http: { http: {
@@ -42,9 +42,9 @@ Refer to the [Admin Development Constraints](!docs!/advanced-development/admin/c
If you're using a Docker image to host your Medusa application, make sure that the image's root path is different than the Medusa Admin's `path` configuration. If you're using a Docker image to host your Medusa application, make sure that the image's root path is different than the Medusa Admin's `path` configuration.
For example, if your Docker image's root path is `/app`, make sure to change the `path` configuration in `medusa-config.js`, as it's `/app` by default: For example, if your Docker image's root path is `/app`, make sure to change the `path` configuration in `medusa-config.ts`, as it's `/app` by default:
```js title="medusa-config.js" ```ts title="medusa-config.ts"
module.exports = defineConfig({ module.exports = defineConfig({
admin: { admin: {
path: `/dashboard`, path: `/dashboard`,
@@ -48,17 +48,17 @@ export default {
This exports the module's definition, indicating that the \`MyAuthProviderService\` is the module's service.`, This exports the module's definition, indicating that the \`MyAuthProviderService\` is the module's service.`,
`## 4. Use Module `## 4. Use Module
To use your Auth Module Provider, add it to the \`providers\` array of the Auth Module: To use your Auth Module Provider, add it to the \`providers\` array of the Auth Module in \`medusa-config.ts\`:
\`\`\`js title="medusa-config.js" \`\`\`ts title="medusa-config.ts"
const { Modules } = require("@medusajs/framework/utils") import { Modules } from "@medusajs/framework/utils"
// ... // ...
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
[Modules.AUTH]: { {
resolve: "@medusajs/framework/auth", resolve: "@medusajs/framework/auth",
options: { options: {
providers: [ providers: [
@@ -72,7 +72,7 @@ module.exports = defineConfig({
], ],
}, },
}, },
} ]
}) })
\`\`\` \`\`\`
`, `,
@@ -48,7 +48,7 @@ export default {
This exports the module's definition, indicating that the \`MyFileProviderService\` is the module's service.`, This exports the module's definition, indicating that the \`MyFileProviderService\` is the module's service.`,
`## 4. Use Module `## 4. Use Module
To use your File Module Provider, add it to the \`providers\` array of the File Module: To use your File Module Provider, add it to the \`providers\` array of the File Module in \`medusa-config.ts\`:
<Note> <Note>
@@ -56,15 +56,15 @@ The File Module accepts one provider only.
</Note> </Note>
\`\`\`js title="medusa-config.js" \`\`\`ts title="medusa-config.ts"
const { Modules } = require("@medusajs/framework/utils") import { Modules } from "@medusajs/framework/utils"
// ... // ...
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
[Modules.FILE]: { {
resolve: "@medusajs/framework/file", resolve: "@medusajs/framework/file",
options: { options: {
providers: [ providers: [
@@ -78,7 +78,7 @@ module.exports = defineConfig({
], ],
}, },
}, },
} ]
}) })
\`\`\` \`\`\`
`, `,
@@ -48,17 +48,17 @@ export default {
This exports the module's definition, indicating that the \`MyFulfillmentProviderService\` is the module's service.`, This exports the module's definition, indicating that the \`MyFulfillmentProviderService\` is the module's service.`,
`## 4. Use Module `## 4. Use Module
To use your Fulfillment Module Provider, add it to the \`providers\` array of the Fulfillment Module: To use your Fulfillment Module Provider, add it to the \`providers\` array of the Fulfillment Module in \`medusa-config.ts\`:
\`\`\`js title="medusa-config.js" \`\`\`ts title="medusa-config.ts"
const { Modules } = require("@medusajs/framework/utils") import { Modules } from "@medusajs/framework/utils"
// ... // ...
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
[Modules.FULFILLMENT]: { {
resolve: "@medusajs/framework/fulfillment", resolve: "@medusajs/framework/fulfillment",
options: { options: {
providers: [ providers: [
@@ -72,7 +72,7 @@ module.exports = defineConfig({
], ],
}, },
}, },
} ]
}) })
\`\`\` \`\`\`
`, `,
@@ -9,7 +9,7 @@ const medusaConfigOptions: FormattingOptionsType = {
frontmatterData: { frontmatterData: {
slug: "/references/medusa-config", slug: "/references/medusa-config",
}, },
reflectionDescription: `In this document, you’ll learn how to create a file service in the Medusa backend and the methods you must implement in it.`, reflectionDescription: `In this document, you’ll learn how to create a file service in the Medusa application and the methods you must implement in it.`,
reflectionTitle: { reflectionTitle: {
fullReplacement: "Configure Medusa Backend", fullReplacement: "Configure Medusa Backend",
}, },
@@ -52,7 +52,7 @@ export default {
This exports the module's definition, indicating that the \`MyNotificationProviderService\` is the module's service.`, This exports the module's definition, indicating that the \`MyNotificationProviderService\` is the module's service.`,
`## 4. Use Module `## 4. Use Module
To use your Notification Module Provider, add it to the \`providers\` array of the Notification Module: To use your Notification Module Provider, add it to the \`providers\` array of the Notification Module in \`medusa-config.ts\`:
<Note> <Note>
@@ -60,15 +60,15 @@ The Notification Module accepts one provider per channel.
</Note> </Note>
\`\`\`js title="medusa-config.js" \`\`\`ts title="medusa-config.ts"
const { Modules } = require("@medusajs/framework/utils") import { Modules } from "@medusajs/framework/utils"
// ... // ...
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
[Modules.NOTIFICATION]: { {
resolve: "@medusajs/framework/notification", resolve: "@medusajs/framework/notification",
options: { options: {
providers: [ providers: [
@@ -83,7 +83,7 @@ module.exports = defineConfig({
], ],
}, },
}, },
} ]
}) })
\`\`\` \`\`\`
@@ -57,17 +57,17 @@ export default {
This exports the module's definition, indicating that the \`MyPaymentProviderService\` is the module's service.`, This exports the module's definition, indicating that the \`MyPaymentProviderService\` is the module's service.`,
`## 4. Use Module `## 4. Use Module
To use your Payment Module Provider, add it to the \`providers\` array of the Payment Module: To use your Payment Module Provider, add it to the \`providers\` array of the Payment Module in \`medusa-config.ts\`:
\`\`\`js title="medusa-config.js" \`\`\`ts title="medusa-config.ts"
const { Modules } = require("@medusajs/framework/utils") import { Modules } from "@medusajs/framework/utils"
// ... // ...
module.exports = defineConfig({ module.exports = defineConfig({
// ... // ...
modules: { modules: [
[Modules.PAYMENT]: { {
resolve: "@medusajs/framework/payment", resolve: "@medusajs/framework/payment",
options: { options: {
providers: [ providers: [
@@ -82,7 +82,7 @@ module.exports = defineConfig({
] ]
} }
} }
} ]
}) })
\`\`\` \`\`\`
`, `,