docs: change config snippets to use defineConfig (#7546)
This commit is contained in:
@@ -152,14 +152,20 @@ To use your Cache Module, add it to the `modules` object exported as part of the
|
||||
For example:
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const modules = {
|
||||
// other modules...
|
||||
cacheService: {
|
||||
resolve: "./dist/modules/my-cache/index.ts",
|
||||
options: {
|
||||
// any necessary options
|
||||
ttl: 30,
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
module.exports = defineConfig({
|
||||
// ...
|
||||
modules: {
|
||||
[Modules.CACHE]: {
|
||||
resolve: "./modules/my-cache",
|
||||
options: {
|
||||
// any options
|
||||
ttl: 30,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
@@ -16,6 +16,12 @@ For production, it’s recommended to use modules like [Redis Cache Module](../r
|
||||
|
||||
## Install the In-Memory Cache Module
|
||||
|
||||
<Note>
|
||||
|
||||
The In-Memory Cache Module is installed by default in your application.
|
||||
|
||||
</Note>
|
||||
|
||||
To install the In-Memory Cache Module, run the following command in the directory of your Medusa application:
|
||||
|
||||
```bash npm2yarn
|
||||
@@ -29,18 +35,17 @@ const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
module.exports = {
|
||||
module.exports = defineConfig({
|
||||
// ...
|
||||
modules: {
|
||||
// ...
|
||||
[Modules.CACHE]: {
|
||||
resolve: "@medusajs/cache-inmemory",
|
||||
options: {
|
||||
// optional options
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### In-Memory Cache Module Options
|
||||
|
||||
@@ -27,7 +27,7 @@ npm install @medusajs/cache-redis
|
||||
Next, add the module into the `modules` property of the exported object in `medusa-config.js`:
|
||||
|
||||
export const highlights = [
|
||||
["12", "redisUrl", "The Redis connection URL."]
|
||||
["11", "redisUrl", "The Redis connection URL."]
|
||||
]
|
||||
|
||||
```js title="medusa-config.js" highlights={highlights}
|
||||
@@ -35,18 +35,17 @@ const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
module.exports = {
|
||||
module.exports = defineConfig({
|
||||
// ...
|
||||
modules: {
|
||||
// ...
|
||||
[Modules.CACHE]: {
|
||||
resolve: "@medusajs/cache-redis",
|
||||
options: {
|
||||
redisUrl: process.env.CACHE_REDIS_URL,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Environment Variables
|
||||
|
||||
@@ -107,13 +107,19 @@ To use your Event Module, add it to the `modules` object exported as part of the
|
||||
For example:
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const modules = {
|
||||
// other modules...
|
||||
eventBus: {
|
||||
resolve: "./dist/modules/my-event/index.ts",
|
||||
options: {
|
||||
// any necessary options
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
module.exports = defineConfig({
|
||||
// ...
|
||||
modules: {
|
||||
[Modules.EVENT_BUS]: {
|
||||
resolve: "./modules/my-event",
|
||||
options: {
|
||||
// any options
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
@@ -14,6 +14,12 @@ For production, it’s recommended to use modules like [Redis Event Bus Module](
|
||||
|
||||
## Install the Local Event Bus Module
|
||||
|
||||
<Note>
|
||||
|
||||
The Local Event Bus Module is installed by default in your application.
|
||||
|
||||
</Note>
|
||||
|
||||
To install Local Event Bus Module, run the following command in the directory of your Medusa application:
|
||||
|
||||
```bash npm2yarn
|
||||
@@ -27,13 +33,12 @@ const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
module.exports = {
|
||||
module.exports = defineConfig({
|
||||
// ...
|
||||
modules: {
|
||||
// ...
|
||||
[Modules.EVENT_BUS]: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
@@ -31,7 +31,7 @@ npm install @medusajs/event-redis
|
||||
Next, add the module into the `modules` property of the exported object in `medusa-config.js`:
|
||||
|
||||
export const highlights = [
|
||||
["8", "redisUrl", "The Redis connection URL."]
|
||||
["11", "redisUrl", "The Redis connection URL."]
|
||||
]
|
||||
|
||||
```js title="medusa-config.js"
|
||||
@@ -39,18 +39,17 @@ const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
module.exports = {
|
||||
module.exports = defineConfig({
|
||||
// ...
|
||||
modules: {
|
||||
// ...
|
||||
[Modules.EVENT_BUS]: {
|
||||
resolve: "@medusajs/event-redis",
|
||||
options: {
|
||||
redisUrl: process.env.EVENTS_REDIS_URL,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Environment Variables
|
||||
|
||||
@@ -12,6 +12,12 @@ The Local File Provider Module stores files uploaded to your Medusa application
|
||||
|
||||
## Install the Local File Module
|
||||
|
||||
<Note>
|
||||
|
||||
The Local File Module is installed by default in your application.
|
||||
|
||||
</Note>
|
||||
|
||||
To install the Local File Provider Module, run the following command in the directory of your Medusa application:
|
||||
|
||||
```bash npm2yarn
|
||||
@@ -27,10 +33,13 @@ The File Module accepts one provider only.
|
||||
</Note>
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
module.exports = {
|
||||
// ...
|
||||
modules: {
|
||||
// ...
|
||||
[Modules.FILE]: {
|
||||
resolve: "@medusajs/file",
|
||||
options: {
|
||||
|
||||
@@ -85,6 +85,10 @@ The File Module accepts one provider only.
|
||||
</Note>
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
module.exports = {
|
||||
// ...
|
||||
modules: {
|
||||
|
||||
@@ -12,6 +12,12 @@ The Local Notification Provider Module simulates sending a notification, but onl
|
||||
|
||||
## Install the Local Notification Module
|
||||
|
||||
<Note>
|
||||
|
||||
The Local Notification Provider Module is installed by default in your application.
|
||||
|
||||
</Note>
|
||||
|
||||
To install the Local Notification Provider Module, run the following command in the directory of your Medusa application:
|
||||
|
||||
```bash npm2yarn
|
||||
@@ -27,10 +33,13 @@ Only one provider can be defined for a channel.
|
||||
</Note>
|
||||
|
||||
```js title="medusa-config.js"
|
||||
module.exports = {
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
module.exports = defineConfig({
|
||||
// ...
|
||||
modules: {
|
||||
// ...
|
||||
[Modules.NOTIFICATION]: {
|
||||
resolve: "@medusajs/notification",
|
||||
options: {
|
||||
@@ -49,8 +58,8 @@ module.exports = {
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Local Notification Module Options
|
||||
|
||||
@@ -30,7 +30,11 @@ When you send a notification, you specify the channel to send it through, such a
|
||||
|
||||
For example:
|
||||
|
||||
```js title="medusa-config.js" highlights={[["15"]]}
|
||||
```js title="medusa-config.js" highlights={[["19"]]}
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
module.exports = {
|
||||
// ...
|
||||
modules: {
|
||||
|
||||
@@ -35,10 +35,13 @@ Only one provider can be defined for a channel.
|
||||
</Note>
|
||||
|
||||
```js title="medusa-config.js"
|
||||
module.exports = {
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
module.exports = defineConfig({
|
||||
// ...
|
||||
modules: {
|
||||
// ...
|
||||
[Modules.NOTIFICATION]: {
|
||||
resolve: "@medusajs/notification",
|
||||
options: {
|
||||
@@ -59,8 +62,8 @@ module.exports = {
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Environment Variables
|
||||
|
||||
@@ -16,6 +16,12 @@ For production, it’s recommended to use modules like [Redis Workflow Engine Mo
|
||||
|
||||
## Install the In-Memory Workflow Engine Module
|
||||
|
||||
<Note>
|
||||
|
||||
The In-Memory Workflow Engine Module is installed by default in your application.
|
||||
|
||||
</Note>
|
||||
|
||||
To install the In-Memory Workflow Engine Module, run the following command in the directory of your Medusa application:
|
||||
|
||||
```bash npm2yarn
|
||||
@@ -29,11 +35,10 @@ const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
module.exports = {
|
||||
module.exports = defineConfig({
|
||||
// ...
|
||||
modules: {
|
||||
// ...
|
||||
[Modules.WORKFLOW_ENGINE]: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
@@ -27,7 +27,7 @@ npm install @medusajs/workflow-engine-redis
|
||||
Next, add the module into the `modules` property of the exported object in `medusa-config.js`:
|
||||
|
||||
export const highlights = [
|
||||
["8", "redisUrl", "The Redis connection URL."]
|
||||
["12", "url", "The Redis connection URL."]
|
||||
]
|
||||
|
||||
```js title="medusa-config.js" highlights={highlights}
|
||||
@@ -35,10 +35,9 @@ const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
module.exports = {
|
||||
module.exports = defineConfig({
|
||||
// ...
|
||||
modules: {
|
||||
// ...
|
||||
[Modules.WORKFLOW_ENGINE]: {
|
||||
resolve: "@medusajs/workflow-engine-redis",
|
||||
options: {
|
||||
@@ -47,8 +46,8 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Environment Variables
|
||||
|
||||
@@ -75,23 +75,6 @@ const newKey = await apiKeyModuleService.create({
|
||||
|
||||
---
|
||||
|
||||
## Configure API Key Module
|
||||
|
||||
To use the API Key Module, enable it in the `modules` object in `medusa-config.js`:
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
const modules = {
|
||||
// ...
|
||||
[Modules.API_KEY]: true,
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## How to Use API Key Module's Service
|
||||
|
||||
You can use the API Key Module's main service by resolving from the Medusa container the resource `ModuleRegistrationName.API_KEY` imported from `@medusajs/modules-sdk`.
|
||||
|
||||
@@ -27,7 +27,7 @@ By default, admin users and customers can login with all installed auth provider
|
||||
To limit the auth providers that used for admin users and customers, use the [authMethodsPerActor option](/references/medusa-config#http-authMethodsPerActor-1-3) in Medusa's configurations:
|
||||
|
||||
```js title="medusa-config.js"
|
||||
module.exports = {
|
||||
module.exports = defineConfig({
|
||||
projectConfig: {
|
||||
http: {
|
||||
authMethodsPerActor: {
|
||||
@@ -38,7 +38,7 @@ module.exports = {
|
||||
},
|
||||
// ...
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
@@ -15,35 +15,41 @@ In this document, you'll learn about the options of the Auth Module.
|
||||
## providers
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const modules = {
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
module.exports = defineConfig({
|
||||
// ...
|
||||
auth: {
|
||||
resolve: "@medusajs/auth",
|
||||
options: {
|
||||
providers: [
|
||||
{
|
||||
name: "emailpass",
|
||||
scopes: {
|
||||
store: {},
|
||||
admin: {},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "google",
|
||||
scopes: {
|
||||
admin: {
|
||||
clientID: process.env.GOOGLE_CLIENT_ID,
|
||||
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
|
||||
callbackURL: process.env.GOOGLE_CALLBACK_URL,
|
||||
successRedirectUrl:
|
||||
process.env.GOOGLE_SUCCESS_REDIRECT_URL,
|
||||
modules: {
|
||||
[Modules.AUTH]: {
|
||||
resolve: "@medusajs/auth",
|
||||
options: {
|
||||
providers: [
|
||||
{
|
||||
name: "emailpass",
|
||||
scopes: {
|
||||
store: {},
|
||||
admin: {},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
{
|
||||
name: "google",
|
||||
scopes: {
|
||||
admin: {
|
||||
clientID: process.env.GOOGLE_CLIENT_ID,
|
||||
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
|
||||
callbackURL: process.env.GOOGLE_CALLBACK_URL,
|
||||
successRedirectUrl:
|
||||
process.env.GOOGLE_SUCCESS_REDIRECT_URL,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
The `providers` option is an array of objects indicating the auth providers to register, their scopes, and configurations.
|
||||
|
||||
@@ -69,22 +69,7 @@ const { success, authIdentity } =
|
||||
|
||||
## Configure Auth Module
|
||||
|
||||
To use the Auth Module, enable it in the `modules` object in `medusa-config.js`:
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
const modules = {
|
||||
// ...
|
||||
[Modules.AUTH]: true,
|
||||
}
|
||||
```
|
||||
|
||||
{/* ### Module Options
|
||||
|
||||
Refer to [this documentation](./module-options/page.mdx) for details on the module's options. */}
|
||||
Refer to [this documentation](./module-options/page.mdx) for details on the module's options.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -63,23 +63,6 @@ When used with their respective modules and other commerce modules, you benefit
|
||||
|
||||
---
|
||||
|
||||
## Configure Cart Module
|
||||
|
||||
To use the Cart Module, enable it in the `modules` object in `medusa-config.js`:
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
const modules = {
|
||||
// ...
|
||||
[Modules.CART]: true,
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## How to Use Cart Module's Service
|
||||
|
||||
You can use the Cart Module's main service by resolving from the Medusa container the resource `ModuleRegistrationName.CART` imported from `@medusajs/modules-sdk`.
|
||||
|
||||
@@ -33,23 +33,6 @@ const currency = await currencyModuleService.retrieve(
|
||||
|
||||
---
|
||||
|
||||
## Configure Currency Module
|
||||
|
||||
To use the Currency Module, enable it in the `modules` object in `medusa-config.js`:
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
const modules = {
|
||||
// ...
|
||||
[Modules.CURRENCY]: true,
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## How to Use Currency Module's Service
|
||||
|
||||
You can use the Currency Module's main service by resolving from the Medusa container the resource `ModuleRegistrationName.CURRENCY` imported from `@medusajs/modules-sdk`.
|
||||
|
||||
@@ -40,23 +40,6 @@ await customerModuleService.addCustomerToGroup({
|
||||
|
||||
---
|
||||
|
||||
## Configure Customer Module
|
||||
|
||||
To use the Customer Module, enable it in the `modules` object in `medusa-config.js`:
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
const modules = {
|
||||
// ...
|
||||
[Modules.CUSTOMER]: true,
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## How to Use Customer Module's Service
|
||||
|
||||
You can use the Customer Module's main service by resolving from the Medusa container the resource `ModuleRegistrationName.CUSTOMER` imported from `@medusajs/modules-sdk`.
|
||||
|
||||
@@ -21,30 +21,36 @@ When the Medusa application starts, these providers are registered and can be us
|
||||
For example:
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const modules = {
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
module.exports = defineConfig({
|
||||
// ...
|
||||
fulfillment: {
|
||||
resolve: "@medusajs/fulfillment",
|
||||
options: {
|
||||
providers: [
|
||||
{
|
||||
resolve: `@medusajs/fulfillment-manual`,
|
||||
options: {
|
||||
config: {
|
||||
manual: {
|
||||
// provider options...
|
||||
modules: {
|
||||
[Modules.FULFILLMENT]: {
|
||||
resolve: "@medusajs/fulfillment",
|
||||
options: {
|
||||
providers: [
|
||||
{
|
||||
resolve: `@medusajs/fulfillment-manual`,
|
||||
options: {
|
||||
config: {
|
||||
manual: {
|
||||
// provider options...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
The `providers` option is an array of objects that accept the following properties:
|
||||
|
||||
- `resolve`: A string indicating either the package name of the fulfillment provider module or the path to it.
|
||||
- `resolve`: A string indicating either the package name of the fulfillment provider module or the path to it relative to the `src` directory.
|
||||
- `options`: An optional object of the fulfillment provider module's options. The object must have the following property:
|
||||
- `config`: An object whose key is the ID of the fulfillment provider, and its value is an object of options to pass to the provider module.
|
||||
@@ -106,24 +106,6 @@ const fulfillmentSets = await fulfillmentModuleService.create(
|
||||
|
||||
## Configure Fulfillment Module
|
||||
|
||||
To use the Fulfillment Module, enable it in the `modules` object in `medusa-config.js`:
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
const modules = {
|
||||
// ...
|
||||
[Modules.FULFILLMENT]: {
|
||||
resolve: "@medusajs/fulfillment",
|
||||
providers: [
|
||||
// ...
|
||||
],
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
### Module Options
|
||||
|
||||
Refer to [this documentation](./module-options/page.mdx) for details on the module's options.
|
||||
|
||||
---
|
||||
|
||||
@@ -66,23 +66,6 @@ const isAvailable =
|
||||
|
||||
---
|
||||
|
||||
## Configure Inventory Module
|
||||
|
||||
To use the Inventory Module, enable it in the `modules` object in `medusa-config.js`:
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
const modules = {
|
||||
// ...
|
||||
[Modules.INVENTORY]: true,
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## How to Use Inventory Module's Service
|
||||
|
||||
You can use the Inventory Module's main service by resolving from the Medusa container the resource `ModuleRegistrationName.INVENTORY` imported from `@medusajs/modules-sdk`.
|
||||
|
||||
@@ -100,23 +100,6 @@ await orderModuleService.confirmOrderChange("ord_123")
|
||||
|
||||
---
|
||||
|
||||
## Configure Order Module
|
||||
|
||||
To use the Order Module, enable it in the `modules` object in `medusa-config.js`:
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
const modules = {
|
||||
// ...
|
||||
[Modules.ORDER]: true,
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## How to Use Order Module's Service
|
||||
|
||||
You can use the Order Module's main service by resolving from the Medusa container the resource `ModuleRegistrationName.ORDER` imported from `@medusajs/modules-sdk`.
|
||||
|
||||
@@ -104,31 +104,32 @@ When the Medusa application starts, these providers are registered and can be us
|
||||
For example:
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const modules = {
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
module.exports = defineConfig({
|
||||
// ...
|
||||
payment: {
|
||||
resolve: "@medusajs/payment",
|
||||
options: {
|
||||
providers: [
|
||||
{
|
||||
resolve: "@medusajs/payment-stripe",
|
||||
options: {
|
||||
// ...
|
||||
modules: {
|
||||
[Modules.PAYMENT]: {
|
||||
resolve: "@medusajs/payment",
|
||||
options: {
|
||||
providers: [
|
||||
{
|
||||
resolve: "@medusajs/payment-stripe",
|
||||
options: {
|
||||
// ...
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
resolve: "medusa-payment-paypal",
|
||||
options: {
|
||||
// ...
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
The `providers` option is an array of objects that accept the following properties:
|
||||
|
||||
- `resolve`: A string indicating the package name of the payment provider module or the payment plugin, or the path to the file defining the payment provider.
|
||||
- `options`: An optional object of options to pass to the payment provider.
|
||||
- `resolve`: A string indicating the package name of the payment provider module or the path to it relative to the `src` directory.
|
||||
- `options`: An optional object of the payment provider module's options. The object must have the following property:
|
||||
- `config`: An object whose key is the ID of the payment provider, and its value is an object of options to pass to the provider module.
|
||||
@@ -72,26 +72,6 @@ await paymentModuleService.processEvent({
|
||||
|
||||
## Configure Payment Module
|
||||
|
||||
To use the Payment Module, enable it in the `modules` object in `medusa-config.js`:
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
const modules = {
|
||||
// ...
|
||||
[Modules.PAYMENT]: {
|
||||
resolve: "@medusajs/payment",
|
||||
options: {
|
||||
// ...
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
### Module Options
|
||||
|
||||
Refer to [this documentation](./module-options/page.mdx) for details on the module's options.
|
||||
|
||||
---
|
||||
|
||||
@@ -39,30 +39,36 @@ npm install @medusajs/payment-stripe
|
||||
Next, add the module to the array of providers passed to the Payment Module:
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const modules = {
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
module.exports = defineConfig({
|
||||
// ...
|
||||
payment: {
|
||||
resolve: "@medusajs/payment",
|
||||
options: {
|
||||
providers: [
|
||||
{
|
||||
resolve: "@medusajs/payment-stripe",
|
||||
options: {
|
||||
config: {
|
||||
stripe: {
|
||||
credentials: {
|
||||
usd: {
|
||||
apiKey: process.env.STRIPE_USD_API_KEY,
|
||||
modules: {
|
||||
[Modules.PAYMENT]: {
|
||||
resolve: "@medusajs/payment",
|
||||
options: {
|
||||
providers: [
|
||||
{
|
||||
resolve: "@medusajs/payment-stripe",
|
||||
options: {
|
||||
config: {
|
||||
stripe: {
|
||||
credentials: {
|
||||
usd: {
|
||||
apiKey: process.env.STRIPE_USD_API_KEY,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Environment Variables
|
||||
|
||||
@@ -102,23 +102,6 @@ const price = await pricingModuleService.calculatePrices(
|
||||
|
||||
---
|
||||
|
||||
## Configure Pricing Module
|
||||
|
||||
To use the Pricing Module, enable it in the `modules` object in `medusa-config.js`:
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
const modules = {
|
||||
// ...
|
||||
[Modules.PRICING]: true,
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## How to Use Pricing Module's Service
|
||||
|
||||
You can use the Pricing Module's main service by resolving from the Medusa container the resource `ModuleRegistrationName.PRICING` imported from `@medusajs/modules-sdk`.
|
||||
|
||||
@@ -60,23 +60,6 @@ const products = await productService.update([
|
||||
|
||||
---
|
||||
|
||||
## Configure Product Module
|
||||
|
||||
To use the Product Module, enable it in the `modules` object in `medusa-config.js`:
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
const modules = {
|
||||
// ...
|
||||
[Modules.PRODUCT]: true,
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## How to Use Product Module's Service
|
||||
|
||||
You can use the Product Module's main service by resolving from the Medusa container the resource `ModuleRegistrationName.PRODUCT` imported from `@medusajs/modules-sdk`.
|
||||
|
||||
@@ -72,23 +72,6 @@ const campaign = await promotionModuleService.createCampaigns(
|
||||
|
||||
---
|
||||
|
||||
## Configure Promotion Module
|
||||
|
||||
To use the Promotion Module, enable it in the `modules` object in `medusa-config.js`:
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
const modules = {
|
||||
// ...
|
||||
[Modules.PROMOTION]: true,
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## How to Use the Promotion Module's Service
|
||||
|
||||
You can use the Promotion Module's main service by resolving from the Medusa container the resource `ModuleRegistrationName.PROMOTION` imported from `@medusajs/modules-sdk`.
|
||||
|
||||
@@ -67,23 +67,6 @@ const regions = await regionModuleService.create([
|
||||
|
||||
---
|
||||
|
||||
## Configure Region Module
|
||||
|
||||
To use the Region Module, enable it in the `modules` object in `medusa-config.js`:
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
const modules = {
|
||||
// ...
|
||||
[Modules.REGION]: true,
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## How to Use Region Module's Service
|
||||
|
||||
You can use the Region Module's main service by resolving from the Medusa container the resource `ModuleRegistrationName.REGION` imported from `@medusajs/modules-sdk`.
|
||||
|
||||
@@ -51,23 +51,6 @@ Orders are also scoped to a sales channel due to the relation between the Sales
|
||||
|
||||
---
|
||||
|
||||
## Configure Sales Channel Module
|
||||
|
||||
To use the Sales Channel Module, enable it in the `modules` object in `medusa-config.js`:
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
const modules = {
|
||||
// ...
|
||||
[Modules.SALES_CHANNEL]: true,
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## How to Use Sales Channel Module's Service
|
||||
|
||||
You can use the Sales Channel Module's main service by resolving from the Medusa container the resource `ModuleRegistrationName.SALES_CHANNEL` imported from `@medusajs/modules-sdk`.
|
||||
|
||||
@@ -42,23 +42,6 @@ const stockLocation = await stockLocationModuleService.update(
|
||||
|
||||
---
|
||||
|
||||
## Configure Stock Location Module
|
||||
|
||||
To use the Stock Location Module, enable it in the `modules` object in `medusa-config.js`:
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
const modules = {
|
||||
// ...
|
||||
[Modules.STOCK_LOCATION]: true,
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## How to Use Stock Location Module's Service
|
||||
|
||||
You can use the Stock Location Module's main service by resolving from the Medusa container the resource `ModuleRegistrationName.STOCK_LOCATION` imported from `@medusajs/modules-sdk`.
|
||||
|
||||
@@ -40,23 +40,6 @@ const stores = await storeModuleService.create([
|
||||
|
||||
---
|
||||
|
||||
## Configure Store Module
|
||||
|
||||
To use the Store Module, enable it in the `modules` object in `medusa-config.js`:
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
const modules = {
|
||||
// ...
|
||||
[Modules.STORE]: true,
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## How to Use Store Module's Service
|
||||
|
||||
You can use the Store Module's main service by resolving from the Medusa container the resource `ModuleRegistrationName.STORE` imported from `@medusajs/modules-sdk`.
|
||||
|
||||
@@ -19,25 +19,31 @@ The `providers` option is an array of either tax provider modules, 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 = {
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
module.exports = defineConfig({
|
||||
// ...
|
||||
tax: {
|
||||
resolve: "@medusajs/tax",
|
||||
options: {
|
||||
providers: [
|
||||
{
|
||||
resolve: "my-provider",
|
||||
options: {
|
||||
// ...
|
||||
modules: {
|
||||
[Modules.TAX]: {
|
||||
resolve: "@medusajs/tax",
|
||||
options: {
|
||||
providers: [
|
||||
{
|
||||
resolve: "my-provider",
|
||||
options: {
|
||||
// ...
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
The objects in the array accept the following properties:
|
||||
|
||||
- `resolve`: A string indicating the package name of the tax provider module or the tax plugin, or the path to the file defining the tax provider.
|
||||
- `resolve`: A string indicating the package name of the tax provider module or the path to it relative to the `src` directory.
|
||||
- `options`: An object of options to pass to the tax provider.
|
||||
|
||||
@@ -78,21 +78,6 @@ const taxLines = await taxModuleService.getTaxLines(
|
||||
|
||||
## Configure Tax Module
|
||||
|
||||
To use the Tax Module, enable it in the `modules` object in `medusa-config.js`:
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
const modules = {
|
||||
// ...
|
||||
[Modules.TAX]: true,
|
||||
}
|
||||
```
|
||||
|
||||
### Module Options
|
||||
|
||||
Refer to [this documentation](./module-options/page.mdx) for details on the module's options.
|
||||
|
||||
---
|
||||
|
||||
@@ -15,15 +15,21 @@ In this document, you'll learn about the options of the User Module.
|
||||
## Module Options
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const modules = {
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
module.exports = defineConfig({
|
||||
// ...
|
||||
user: {
|
||||
resolve: "@medusajs/user",
|
||||
options: {
|
||||
jwt_secret: process.env.JWT_SECRET,
|
||||
modules: {
|
||||
[Modules.USER]: {
|
||||
resolve: "@medusajs/user",
|
||||
options: {
|
||||
jwt_secret: process.env.JWT_SECRET,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
<Table>
|
||||
|
||||
@@ -39,26 +39,6 @@ await userModuleService.refreshInviteTokens([invite.id])
|
||||
|
||||
## Configure User Module
|
||||
|
||||
To use the User Module, enable it in the `modules` object in `medusa-config.js`:
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
const modules = {
|
||||
// ...
|
||||
[Modules.USER]: {
|
||||
resolve: "@medusajs/user",
|
||||
options: {
|
||||
jwt_secret: process.env.JWT_SECRET ?? "supersecret",
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
### Module Options
|
||||
|
||||
Refer to [this documentation](./module-options/page.mdx) for details on the module's options.
|
||||
|
||||
---
|
||||
|
||||
@@ -4,18 +4,16 @@ You might see a log in your browser console, that looks like this:
|
||||
|
||||

|
||||
|
||||
In your `medusa-config.js` , you should ensure that you've configured your CORS settings correctly. By default, the Medusa starter runs on port `9000`, Medusa Admin runs on port `7001`, and the storefront starters run on port `8000`.
|
||||
|
||||
The default configuration uses the following CORS settings:
|
||||
In your `medusa-config.js` , you should ensure that you've configured your CORS settings correctly:
|
||||
|
||||
```js title="medusa-config.js"
|
||||
// CORS when consuming Medusa from admin
|
||||
const ADMIN_CORS = process.env.ADMIN_CORS ||
|
||||
"http://localhost:7000,http://localhost:7001"
|
||||
|
||||
// CORS to avoid issues when consuming Medusa from a client
|
||||
const STORE_CORS =
|
||||
process.env.STORE_CORS || "http://localhost:8000"
|
||||
module.exports = defineConfig({
|
||||
projectConfig: {
|
||||
http: {
|
||||
storeCors: process.env.STORE_CORS,
|
||||
adminCors: process.env.ADMIN_CORS,
|
||||
}
|
||||
// ...
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
If you wish to run your storefront or Medusa Admin on other ports, you should update the above settings accordingly.
|
||||
|
||||
Reference in New Issue
Block a user