docs: change config snippets to use defineConfig (#7546)

This commit is contained in:
Shahed Nasser
2024-05-30 16:47:28 +03:00
committed by GitHub
parent ddfd757277
commit fe96bd39b1
51 changed files with 489 additions and 718 deletions
@@ -17,16 +17,15 @@ You configure allowed origins for Store and Admin API Routes using the `storeCor
For example:
```js title="medusa-config.js"
module.exports = {
module.exports = defineConfig({
projectConfig: {
http: {
adminCors: "http://localhost:7001",
storeCors: "http://localhost:8000",
adminCors: "http://localhost:7001",
// ...
}
},
// ...
}
},
}
})
```
This allows the `http://localhost:7001` origin to access the Admin API Routes, and the `http://localhost:8000` origin to access Store API Routes.
@@ -209,22 +209,24 @@ This creates a relationship to the `Product` data model of the Product Module us
### 2. Adjust Module Configuration
To use relationships in a module, adjust its configuration object passed to the `modules` object in `medusa-config.js`:
To use relationships in a module, adjust its configuration object passed to `modules` in `medusa-config.js`:
export const configHighlights = [
["7", "isQueryable", "Enable this property to use relationships in a module."]
]
```js title="medusa-config.js" highlights={configHighlights}
const modules = {
helloModuleService: {
// ...
definition: {
isQueryable: true,
},
},
module.exports = defineConfig({
// ...
}
modules: {
helloModuleService: {
// ...
definition: {
isQueryable: true
}
}
}
})
```
Enabling the `isQueryable` property is required to use relationships in a module.
@@ -23,15 +23,18 @@ To pass options to a module, add an `options` property to the modules configu
For example:
```js title="medusa-config.js"
const modules = {
helloModuleService: {
resolve: "./dist/modules/hello",
options: {
capitalize: true,
},
},
module.exports = defineConfig({
// ...
}
modules: {
helloModuleService: {
resolve: "./modules/hello",
options: {
capitalize: true,
},
}
}
})
```
The `options` propertys value is an object. You can pass any properties you want.
@@ -62,13 +62,15 @@ The last step is to add the module in Medusas configurations.
In `medusa-config.js`, add the module to the `modules` object:
```js title="medusa-config.js" highlights={[["2", "helloModuleService", "The key of the main service to be registered in the Medusa container."]]}
const modules = {
helloModuleService: {
resolve: "./dist/modules/hello",
},
// other modules...
}
```js title="medusa-config.js" highlights={[["4", "helloModuleService", "The key of the main service to be registered in the Medusa container."]]}
module.exports = defineConfig({
// ...
modules: {
helloModuleService: {
resolve: "./modules/hello",
}
}
})
```
Its key (`helloModuleService`) is the name of the modules main service. It will be registered in the Medusa container with that name.
@@ -64,11 +64,12 @@ To test out your scheduled job:
1. Uncomment the following line in the `medusa-config.js` file:
```js title="medusa-config.js"
const projectConfig = {
// ...
// Uncomment the following lines to enable REDIS
redisUrl: REDIS_URL,
}
module.exports = defineConfig({
projectConfig: {
redisUrl: REDIS_URL
// ...
}
})
```
2. Start the Medusa application:
@@ -46,17 +46,17 @@ MEDUSA_FF_TAX_INCLUSIVE_PRICING=true
A feature flag also has an associated key that can be used to toggle its value in Medusas configurations.
The configuration object exported in `medusa-config.js` has a `featureFlags` property. Its value is an object where each key is the key of a feature flag, and its value is a boolean indicating whether to enable or disable the flag.
The configurations exported in `medusa-config.js` has a `featureFlags` property. Its value is an object where each key is the key of a feature flag, and its value is a boolean indicating whether to enable or disable the flag.
For example:
```js title="medusa-config.js"
module.exports = {
module.exports = defineConfig({
featureFlags: {
tax_inclusive_pricing: true,
},
// ...
}
})
```
<Note title="Tip">
@@ -29,15 +29,15 @@ The Medusa applications API routes are guarded by a CORS middleware. Make sur
For example:
```js title="medusa-config.js"
module.exports = {
module.exports = defineConfig({
projectConfig: {
http: {
storeCors: "http://localhost:3000",
// ...
}
},
}
// ...
}
})
```
---