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
2024-10-14 13:40:30 +03:00
committed by GitHub
parent 2a9fc0e514
commit b6df24463d
53 changed files with 319 additions and 324 deletions

View File

@@ -20,7 +20,7 @@ These configurations accept a URL pattern to identify allowed origins.
For example:
```js title="medusa-config.js"
```js title="medusa-config.ts"
module.exports = defineConfig({
projectConfig: {
http: {
@@ -78,7 +78,7 @@ You can do that in the exported middlewares configurations in `src/api/middlewar
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"
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`.

View File

@@ -27,7 +27,7 @@ A service's constructor accepts as a first parameter an object used to resolve r
For example:
```ts highlights={[["4"], ["10"]]}
import { Logger } from "@medusajs/medusa"
import { Logger } from "@medusajs/framework/types"
type InjectedDependencies = {
logger: Logger
@@ -56,12 +56,14 @@ For example:
import {
LoaderOptions,
} from "@medusajs/framework/modules-sdk"
import { Logger } from "@medusajs/medusa"
import {
ContainerRegistrationKeys
} from "@medusajs/framework/utils"
export default async function helloWorldLoader({
container,
}: LoaderOptions) {
const logger: Logger = container.resolve("logger")
const logger = container.resolve(ContainerRegistrationKeys.LOGGER)
logger.info("[helloWorldLoader]: Hello, World!")
}

View File

@@ -100,7 +100,7 @@ export class ClientService {
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:

View File

@@ -16,21 +16,21 @@ For example, if youre creating a module that integrates a third-party service
## How to Pass Options to a Module?
To pass options to a module, add an `options` property to the modules configuration in `medusa-config.js`.
To pass options to a module, add an `options` property to the modules configuration in `medusa-config.ts`.
For example:
```js title="medusa-config.js"
```js title="medusa-config.ts"
module.exports = defineConfig({
// ...
modules: {
helloModuleService: {
modules: [
{
resolve: "./modules/hello",
options: {
capitalize: true,
},
},
},
]
})
```

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:
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.
### 4. Add Module to Configurations
The last step is to add the module in Medusas 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({
projectConfig: {
// ...
},
modules: {
helloModuleService: {
modules: [
{
resolve: "./modules/hello",
},
},
}
]
})
```
The key `helloModuleService` is the name of the modules main service. It will be registered in the Medusa container with that 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` packages 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` packages name.
### 5. Generate Migrations

View File

@@ -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.
- `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.

View File

@@ -97,16 +97,16 @@ Learn more about modules and services [in this guide](../../../basics/modules/pa
## 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({
// ...
modules: {
brandModuleService: {
modules: [
{
resolve: "./modules/brand",
},
},
}
]
})
```

View File

@@ -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.
`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.
@@ -180,19 +180,19 @@ In the main module service, you first resolve through dependency injection the `
## 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({
// ...
modules: {
brandModuleService: {
modules: [
{
resolve: "./modules/brand",
options: {
apiKey: process.env.BRAND_API_KEY || "temp",
},
},
},
]
})
```

View File

@@ -44,14 +44,13 @@ Also, install the dependencies relevant for the exporter you use. If you're usin
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"
const { registerOtel } = require("@medusajs/medusa")
// If using an exporter other than Zipkin, require it here.
const { ZipkinExporter } = require("@opentelemetry/exporter-zipkin")
```ts title="instrumentation.ts"
import { registerOtel } from "@medusajs/medusa"
import { ZipkinExporter } from "@opentelemetry/exporter-zipkin"
// If using an exporter other than Zipkin, initialize it here.
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.

View File

@@ -26,13 +26,13 @@ export const highlights = [
]
```ts title="src/jobs/log-message.ts" highlights={highlights}
import { Logger } from "@medusajs/medusa"
import { MedusaContainer } from "@medusajs/framework/types"
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
export default async function myCustomJob(
container: MedusaContainer
) {
const logger: Logger = container.resolve("logger")
const logger = container.resolve(ContainerRegistrationKeys.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:
```ts title="src/loaders/log-message.ts"
import { Logger, MedusaContainer } from "@medusajs/medusa"
```ts title="src/jobs/log-message.ts"
import { MedusaContainer } from "@medusajs/framework/types"
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
export default async (container: MedusaContainer) => {
const logger = container.resolve<Logger>("logger")
export default async function myCustomJob(
container: MedusaContainer
) {
const logger = container.resolve(ContainerRegistrationKeys.LOGGER)
const activityId = logger.activity("First log message")
@@ -141,7 +144,6 @@ export default async (container: MedusaContainer) => {
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:

View File

@@ -148,25 +148,25 @@ This exports the module's definition, indicating that the `MyCacheService` is th
## 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:
```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({
// ...
modules: {
[Modules.CACHE]: {
modules: [
{
resolve: "./modules/my-cache",
options: {
// any options
ttl: 30,
},
},
},
]
})
```

View File

@@ -22,23 +22,22 @@ The In-Memory Cache Module is registered by default in your application.
</Note>
Add the module into the `modules` property of the exported object in `medusa-config.js`:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/framework/utils")
Add the module into the `modules` property of the exported object in `medusa-config.ts`:
```ts title="medusa-config.ts"
import { Modules } from "@medusajs/framework/utils"
// ...
module.exports = defineConfig({
// ...
modules: {
[Modules.CACHE]: {
resolve: "@medusajs/medusa/cache-inmemory",
modules: [
{
resolve: "@medusajs/cache-inmemory",
options: {
// optional options
},
},
},
]
})
```

View File

@@ -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 = [
["11", "redisUrl", "The Redis connection URL."]
]
```js title="medusa-config.js" highlights={highlights}
const { Modules } = require("@medusajs/framework/utils")
```ts title="medusa-config.ts" highlights={highlights}
import { Modules } from "@medusajs/framework/utils"
// ...
module.exports = defineConfig({
// ...
modules: {
[Modules.CACHE]: {
resolve: "@medusajs/medusa/cache-redis",
modules: [
{
resolve: "@medusajs/cache-redis",
options: {
redisUrl: process.env.CACHE_REDIS_URL,
},
},
},
]
})
```

View File

@@ -103,24 +103,24 @@ This exports the module's definition, indicating that the `MyEventService` is th
## 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:
```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({
// ...
modules: {
[Modules.EVENT_BUS]: {
modules: [
{
resolve: "./modules/my-event",
options: {
// any options
},
},
},
]
})
```

View File

@@ -20,18 +20,20 @@ The Local Event Bus Module is registered by default in your application.
</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({
// ...
modules: {
[Modules.EVENT_BUS]: true,
},
modules: [
{
resolve: "@medusajs/event-bus-local"
}
]
})
```

View File

@@ -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 = [
["11", "redisUrl", "The Redis connection URL."]
]
```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({
// ...
modules: {
[Modules.EVENT_BUS]: {
resolve: "@medusajs/medusa/event-bus-redis",
modules: [
{
resolve: "@medusajs/event-bus-redis",
options: {
redisUrl: process.env.EVENTS_REDIS_URL,
},
},
},
}
]
})
```

View File

@@ -32,20 +32,20 @@ The File Module accepts one provider only.
</Note>
```js title="medusa-config.js"
const { Modules } = require("@medusajs/framework/utils")
```ts title="medusa-config.ts"
import { Modules } from "@medusajs/framework/utils"
// ...
module.exports = {
// ...
modules: {
[Modules.FILE]: {
resolve: "@medusajs/medusa/file",
modules: [
{
resolve: "@medusajs/file",
options: {
providers: [
{
resolve: "@medusajs/medusa/file-local-next",
resolve: "@medusajs/file-local-next",
id: "local",
options: {
// provider options...
@@ -54,7 +54,7 @@ module.exports = {
],
},
},
},
]
}
```

View File

@@ -112,21 +112,21 @@ The File Module accepts one provider only.
</Note>
```js title="medusa-config.js"
const { Modules } = require("@medusajs/framework/utils")
```ts title="medusa-config.ts"
import { Modules } from "@medusajs/framework/utils"
// ...
module.exports = {
// ...
modules: {
modules: [
// ...
[Modules.FILE]: {
resolve: "@medusajs/medusa/file",
{
resolve: "@medusajs/file",
options: {
providers: [
{
resolve: "@medusajs/medusa/file-s3",
resolve: "@medusajs/file-s3",
id: "s3",
options: {
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:
```js title="medusa-config.js"
```ts title="medusa-config.ts"
module.exports = defineConfig({
// ...
modules: {
[Modules.FILE]: {
resolve: "@medusajs/medusa/file",
modules: [
{
resolve: "@medusajs/file",
options: {
providers: [
{
resolve: "@medusajs/medusa/file-s3",
resolve: "@medusajs/file-s3",
id: "s3",
options: {
// ...
@@ -370,7 +370,7 @@ module.exports = defineConfig({
],
},
},
},
]
})
```
---

View File

@@ -26,21 +26,21 @@ Only one provider can be defined for a channel.
</Note>
```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({
// ...
modules: {
[Modules.NOTIFICATION]: {
resolve: "@medusajs/medusa/notification",
modules: [
{
resolve: "@medusajs/notification",
options: {
providers: [
// ...
{
resolve: "@medusajs/medusa/notification-local",
resolve: "@medusajs/notification-local",
id: "local",
options: {
channels: ["email"],
@@ -49,7 +49,7 @@ module.exports = defineConfig({
],
},
},
},
]
})
```

View File

@@ -30,22 +30,22 @@ When you send a notification, you specify the channel to send it through, such a
For example:
```js title="medusa-config.js" highlights={[["19"]]}
const { Modules } = require("@medusajs/framework/utils")
```ts title="medusa-config.ts" highlights={[["19"]]}
import { Modules } from "@medusajs/framework/utils"
// ...
module.exports = {
// ...
modules: {
modules: [
// ...
[Modules.NOTIFICATION]: {
resolve: "@medusajs/medusa/notification",
{
resolve: "@medusajs/notification",
options: {
providers: [
// ...
{
resolve: "@medusajs/medusa/notification-local",
resolve: "@medusajs/notification-local",
id: "notification",
options: {
channels: ["email"],
@@ -54,7 +54,7 @@ module.exports = {
],
},
},
},
]
}
```

View File

@@ -37,21 +37,21 @@ Only one provider can be defined for a channel.
</Note>
```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({
// ...
modules: {
[Modules.NOTIFICATION]: {
resolve: "@medusajs/medusa/notification",
modules: [
{
resolve: "@medusajs/notification",
options: {
providers: [
// ...
{
resolve: "@medusajs/medusa/notification-sendgrid",
resolve: "@medusajs/notification-sendgrid",
id: "sendgrid",
options: {
channels: ["email"],
@@ -62,7 +62,7 @@ module.exports = defineConfig({
],
},
},
},
]
})
```

View File

@@ -22,17 +22,19 @@ The In-Memory Workflow Engine Module is registered by default in your applicatio
</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({
// ...
modules: {
[Modules.WORKFLOW_ENGINE]: true,
},
modules: [
{
resolve: "@medusajs/workflow-engine-inmemory"
}
],
})
```

View File

@@ -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 = [
["12", "url", "The Redis connection URL."]
]
```js title="medusa-config.js" highlights={highlights}
const { Modules } = require("@medusajs/framework/utils")
```ts title="medusa-config.ts" highlights={highlights}
import { Modules } from "@medusajs/framework/utils"
// ...
module.exports = defineConfig({
// ...
modules: {
[Modules.WORKFLOW_ENGINE]: {
modules: [
{
resolve: "@medusajs/workflow-engine-redis",
options: {
redis: {
@@ -41,7 +41,7 @@ module.exports = defineConfig({
},
},
},
},
]
})
```

View File

@@ -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:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/framework/utils")
```ts title="medusa-config.ts"
import { Modules } from "@medusajs/framework/utils"
// ...

View File

@@ -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:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/framework/utils")
```ts title="medusa-config.ts"
import { Modules } from "@medusajs/framework/utils"
// ...

View File

@@ -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:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/framework/utils")
```ts title="medusa-config.ts"
import { Modules } from "@medusajs/framework/utils"
// ...

View File

@@ -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:
```js title="medusa-config.js"
```ts title="medusa-config.ts"
module.exports = defineConfig({
projectConfig: {
http: {

View File

@@ -26,27 +26,29 @@ By default, the `emailpass` provider is registered to authenticate customers and
For example:
```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({
// ...
modules: {
resolve: "@medusajs/medusa/auth",
options: {
providers: [
{
resolve: "@medusajs/medusa/auth-emailpass",
id: "emailpass",
options: {
// provider options...
modules: [
{
resolve: "@medusajs/auth",
options: {
providers: [
{
resolve: "@medusajs/auth-emailpass",
id: "emailpass",
options: {
// provider options...
},
},
},
],
],
},
},
},
]
})
```

View File

@@ -81,7 +81,7 @@ This defines a link between the `Cart` and `Custom` data models. Using this link
<Prerequisites
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"
}
]}

View File

@@ -87,7 +87,7 @@ This defines a link between the `Customer` and `Custom` data models. Using this
<Prerequisites
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"
}
]}

View File

@@ -20,20 +20,20 @@ When the Medusa application starts, these providers are registered and can be us
For example:
```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({
// ...
modules: {
[Modules.FULFILLMENT]: {
resolve: "@medusajs/medusa/fulfillment",
modules: [
{
resolve: "@medusajs/fulfillment",
options: {
providers: [
{
resolve: `@medusajs/medusa/fulfillment-manual`,
resolve: `@medusajs/fulfillment-manual`,
id: "manual",
options: {
// provider options...
@@ -42,7 +42,7 @@ module.exports = defineConfig({
],
},
},
},
]
})
```

View File

@@ -103,20 +103,20 @@ When the Medusa application starts, these providers are registered and can be us
For example:
```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({
// ...
modules: {
[Modules.PAYMENT]: {
resolve: "@medusajs/medusa/payment",
modules: [
{
resolve: "@medusajs/payment",
options: {
providers: [
{
resolve: "@medusajs/medusa/payment-stripe",
resolve: "@medusajs/payment-stripe",
id: "stripe",
options: {
// ...
@@ -125,7 +125,7 @@ module.exports = defineConfig({
],
},
},
},
]
})
```

View File

@@ -31,20 +31,20 @@ In this document, youll learn about the Stripe Module Provider and how to ins
Add the module to the array of providers passed to the Payment Module:
```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({
// ...
modules: {
[Modules.PAYMENT]: {
resolve: "@medusajs/medusa/payment",
modules: [
{
resolve: "@medusajs/payment",
options: {
providers: [
{
resolve: "@medusajs/medusa/payment-stripe",
resolve: "@medusajs/payment-stripe",
id: "stripe",
options: {
apiKey: process.env.STRIPE_API_KEY,
@@ -53,7 +53,7 @@ module.exports = defineConfig({
],
},
},
},
]
})
```

View File

@@ -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.
```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({
// ...
modules: {
[Modules.TAX]: {
resolve: "@medusajs/medusa/tax",
modules: [
{
resolve: "@medusajs/tax",
options: {
providers: [
{
@@ -40,7 +40,7 @@ module.exports = defineConfig({
],
},
},
},
]
})
```

View File

@@ -14,21 +14,21 @@ In this document, you'll learn about the options of the User Module.
## Module Options
```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({
// ...
modules: {
[Modules.USER]: {
resolve: "@medusajs/medusa/user",
modules: [
{
resolve: "@medusajs/user",
options: {
jwt_secret: process.env.JWT_SECRET,
},
},
},
]
})
```

View File

@@ -33,9 +33,9 @@ As Medusa v2 is still in active development, it's highly recommended not to depl
## 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({
// ...
admin: {
@@ -89,7 +89,7 @@ To create a Vercel project, on your Vercel dashboard:
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:
```bash npm2yarn

View File

@@ -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, youll 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({
projectConfig: {
// ...
@@ -74,9 +74,9 @@ To host the admin with the Medusa application, the hosting provider and plan sho
</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({
// ...
admin: {
@@ -89,9 +89,9 @@ Later, youll set different values of the `DISABLE_MEDUSA_ADMIN` environment v
### 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({
projectConfig: {
// ...
@@ -134,34 +134,33 @@ For example, add the following dependencies in `package.json` for the Cache, Eve
```json
"dependencies": {
// ...
"@medusajs/medusa/cache-redis": "rc",
"@medusajs/medusa/event-bus-redis": "rc",
"@medusajs/cache-redis": "rc",
"@medusajs/event-bus-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"
const { Modules } = require("@medusajs/framework/utils")
```ts title="medusa-config.ts"
import { Modules } from "@medusajs/framework/utils"
module.exports = defineConfig({
// ...
modules: {
// ...
[Modules.CACHE]: {
resolve: "@medusajs/medusa/cache-redis",
modules: [
{
resolve: "@medusajs/cache-redis",
options: {
redisUrl: process.env.REDIS_URL,
},
},
[Modules.EVENT_BUS]: {
resolve: "@medusajs/medusa/event-bus-redis",
{
resolve: "@medusajs/event-bus-redis",
options: {
redisUrl: process.env.REDIS_URL,
},
},
[Modules.WORKFLOW_ENGINE]: {
{
resolve: "@medusajs/workflow-engine-redis",
options: {
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 youre deploying the Medusa application in server mode with the admin, you have to make some changes now that youve obtained the applications 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({
// ...
admin: {

View File

@@ -48,7 +48,7 @@ Use the `ContainerRegistrationKeys` enum imported from `@medusajs/framework/util
</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>
@@ -120,12 +120,12 @@ Use the `ContainerRegistrationKeys` enum imported from `@medusajs/framework/util
</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>
- 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`.
</Table.Cell>
@@ -229,7 +229,7 @@ Use the `ContainerRegistrationKeys` enum imported from `@medusajs/framework/util
</Table.Cell>
<Table.Cell>
The configurations exported from `medusa-config.js`.
The configurations exported from `medusa-config.ts`.
</Table.Cell>
<Table.Cell>

View File

@@ -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({
// ...
modules: {
"restockNotificationModuleService": {
modules: [
{
resolve: "./modules/restock-notification",
definition: {
isQueryable: true,
},
},
},
]
})
```

View File

@@ -189,16 +189,16 @@ export default Module(DIGITAL_PRODUCT_MODULE, {
### 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({
// ...
modules: {
digitalProductModuleService: {
modules: [
{
resolve: "./modules/digital-product",
},
},
]
})
```
@@ -1502,21 +1502,21 @@ export default providerExport
### 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...
const { Modules } = require("@medusajs/framework/utils")
import { Modules } from "@medusajs/framework/utils"
module.exports = defineConfig({
modules: {
modules: [
// ...
[Modules.FULFILLMENT]: {
resolve: "@medusajs/medusa/fulfillment",
{
resolve: "@medusajs/fulfillment",
options: {
providers: [
{
resolve: "@medusajs/medusa/fulfillment-manual",
resolve: "@medusajs/fulfillment-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.
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({
// ...
modules: {
modules: [
// ...
[Modules.NOTIFICATION]: {
resolve: "@medusajs/medusa/notification",
{
resolve: "@medusajs/notification",
options: {
providers: [
{
resolve: "@medusajs/medusa/notification-local",
resolve: "@medusajs/notification-local",
id: "local",
options: {
name: "Local Notification Provider",
@@ -2022,7 +2022,7 @@ module.exports = defineConfig({
],
},
},
},
]
})
```

View File

@@ -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({
// ...
modules: {
erpModuleService: {
modules: [
{
resolve: "./modules/erp",
options: {
apiKey: process.env.ERP_API_KEY,
},
},
},
]
})
```

View File

@@ -155,16 +155,16 @@ export default Module(RESTAURANT_MODULE, {
### 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({
// ...
modules: {
restaurantModuleService: {
modules: [
{
resolve: "./modules/restaurant",
},
},
]
})
```
@@ -299,17 +299,16 @@ export default Module(DELIVERY_MODULE, {
### 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({
// ...
modules: {
deliveryModuleService: {
modules: [
{
resolve: "./modules/delivery",
},
// ...
},
]
})
```

View File

@@ -135,16 +135,16 @@ export default Module(MARKETPLACE_MODULE, {
### 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({
// ...
modules: {
marketplaceModuleService: {
modules: [
{
resolve: "./modules/marketplace",
},
},
]
})
```

View File

@@ -153,16 +153,16 @@ This sets the modules name to `subscriptionModuleService` and its main servic
### Register Module in Medusas 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({
// ...
modules: {
subscriptionModuleService: {
modules: [
{
resolve: "./modules/subscription",
},
},
]
})
```

View File

@@ -36,11 +36,11 @@ npm install @medusajs/types@rc
## Configure CORS
The Medusa applications 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 storefronts URL.
The Medusa applications 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 storefronts URL.
For example:
```js title="medusa-config.js"
```ts title="medusa-config.ts"
module.exports = defineConfig({
projectConfig: {
http: {

View File

@@ -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)
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({
projectConfig: {
http: {

View File

@@ -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.
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({
admin: {
path: `/dashboard`,

View File

@@ -48,17 +48,17 @@ export default {
This exports the module's definition, indicating that the \`MyAuthProviderService\` is the module's service.`,
`## 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"
const { Modules } = require("@medusajs/framework/utils")
\`\`\`ts title="medusa-config.ts"
import { Modules } from "@medusajs/framework/utils"
// ...
module.exports = defineConfig({
// ...
modules: {
[Modules.AUTH]: {
modules: [
{
resolve: "@medusajs/framework/auth",
options: {
providers: [
@@ -72,7 +72,7 @@ module.exports = defineConfig({
],
},
},
}
]
})
\`\`\`
`,

View File

@@ -48,7 +48,7 @@ export default {
This exports the module's definition, indicating that the \`MyFileProviderService\` is the module's service.`,
`## 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>
@@ -56,15 +56,15 @@ The File Module accepts one provider only.
</Note>
\`\`\`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({
// ...
modules: {
[Modules.FILE]: {
modules: [
{
resolve: "@medusajs/framework/file",
options: {
providers: [
@@ -78,7 +78,7 @@ module.exports = defineConfig({
],
},
},
}
]
})
\`\`\`
`,

View File

@@ -48,17 +48,17 @@ export default {
This exports the module's definition, indicating that the \`MyFulfillmentProviderService\` is the module's service.`,
`## 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"
const { Modules } = require("@medusajs/framework/utils")
\`\`\`ts title="medusa-config.ts"
import { Modules } from "@medusajs/framework/utils"
// ...
module.exports = defineConfig({
// ...
modules: {
[Modules.FULFILLMENT]: {
modules: [
{
resolve: "@medusajs/framework/fulfillment",
options: {
providers: [
@@ -72,7 +72,7 @@ module.exports = defineConfig({
],
},
},
}
]
})
\`\`\`
`,

View File

@@ -9,7 +9,7 @@ const medusaConfigOptions: FormattingOptionsType = {
frontmatterData: {
slug: "/references/medusa-config",
},
reflectionDescription: `In this document, youll learn how to create a file service in the Medusa backend and the methods you must implement in it.`,
reflectionDescription: `In this document, youll learn how to create a file service in the Medusa application and the methods you must implement in it.`,
reflectionTitle: {
fullReplacement: "Configure Medusa Backend",
},

View File

@@ -52,7 +52,7 @@ export default {
This exports the module's definition, indicating that the \`MyNotificationProviderService\` is the module's service.`,
`## 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>
@@ -60,15 +60,15 @@ The Notification Module accepts one provider per channel.
</Note>
\`\`\`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({
// ...
modules: {
[Modules.NOTIFICATION]: {
modules: [
{
resolve: "@medusajs/framework/notification",
options: {
providers: [
@@ -83,7 +83,7 @@ module.exports = defineConfig({
],
},
},
}
]
})
\`\`\`

View File

@@ -57,17 +57,17 @@ export default {
This exports the module's definition, indicating that the \`MyPaymentProviderService\` is the module's service.`,
`## 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"
const { Modules } = require("@medusajs/framework/utils")
\`\`\`ts title="medusa-config.ts"
import { Modules } from "@medusajs/framework/utils"
// ...
module.exports = defineConfig({
// ...
modules: {
[Modules.PAYMENT]: {
modules: [
{
resolve: "@medusajs/framework/payment",
options: {
providers: [
@@ -82,7 +82,7 @@ module.exports = defineConfig({
]
}
}
}
]
})
\`\`\`
`,