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 10:40:30 +00:00
committed by GitHub
parent 2a9fc0e514
commit b6df24463d
53 changed files with 319 additions and 324 deletions
@@ -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,
},
},
},
]
})
```
@@ -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
},
},
},
]
})
```
@@ -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,
},
},
},
]
})
```
@@ -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
},
},
},
]
})
```
@@ -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"
}
]
})
```
@@ -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,
},
},
},
}
]
})
```
@@ -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 = {
],
},
},
},
]
}
```
@@ -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({
],
},
},
},
]
})
```
---
@@ -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({
],
},
},
},
]
})
```
@@ -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 = {
],
},
},
},
]
}
```
@@ -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({
],
},
},
},
]
})
```
@@ -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"
}
],
})
```
@@ -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({
},
},
},
},
]
})
```
@@ -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"
// ...
@@ -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"
// ...
@@ -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"
// ...
@@ -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: {
@@ -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...
},
},
},
],
],
},
},
},
]
})
```
@@ -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"
}
]}
@@ -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"
}
]}
@@ -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({
],
},
},
},
]
})
```
@@ -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({
],
},
},
},
]
})
```
@@ -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({
],
},
},
},
]
})
```
@@ -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({
],
},
},
},
]
})
```
@@ -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,
},
},
},
]
})
```
@@ -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
@@ -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: {
@@ -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>
@@ -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,
},
},
},
]
})
```
@@ -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({
],
},
},
},
]
})
```
@@ -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,
},
},
},
]
})
```
@@ -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",
},
// ...
},
]
})
```
@@ -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",
},
},
]
})
```
@@ -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",
},
},
]
})
```
@@ -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: {
@@ -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: {
@@ -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`,