docs: change config snippets to use defineConfig (#7546)
This commit is contained in:
@@ -125,14 +125,14 @@ export type ProjectConfigOptions = {
|
||||
*
|
||||
* @example
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* module.exports = defineConfig({
|
||||
* projectConfig: {
|
||||
* databaseName: process.env.DATABASE_DATABASE ||
|
||||
* databaseName: process.env.DATABASE_NAME ||
|
||||
* "medusa-store",
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
databaseName?: string
|
||||
@@ -164,13 +164,13 @@ export type ProjectConfigOptions = {
|
||||
* Then, use the value in `medusa-config.js`:
|
||||
*
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* module.exports = defineConfig({
|
||||
* projectConfig: {
|
||||
* databaseUrl: process.env.DATABASE_URL,
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
databaseUrl?: string
|
||||
@@ -179,14 +179,14 @@ export type ProjectConfigOptions = {
|
||||
* The database schema to connect to. This is not required to provide if you’re using the default schema, which is `public`.
|
||||
*
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* module.exports = defineConfig({
|
||||
* projectConfig: {
|
||||
* databaseSchema: process.env.DATABASE_SCHEMA ||
|
||||
* "custom",
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
databaseSchema?: string
|
||||
@@ -202,15 +202,13 @@ export type ProjectConfigOptions = {
|
||||
*
|
||||
* @example
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* module.exports = defineConfig({
|
||||
* projectConfig: {
|
||||
* databaseLogging: [
|
||||
* "query", "error",
|
||||
* ],
|
||||
* databaseLogging: ["query", "error"]
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
databaseLogging?: LoggerOptions
|
||||
@@ -233,16 +231,14 @@ export type ProjectConfigOptions = {
|
||||
*
|
||||
* @example
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* module.exports = defineConfig({
|
||||
* projectConfig: {
|
||||
* databaseExtra:
|
||||
* process.env.NODE_ENV !== "development"
|
||||
* ? { ssl: { rejectUnauthorized: false } }
|
||||
* : {},
|
||||
* databaseExtra: process.env.NODE_ENV !== "development" ?
|
||||
* { ssl: { rejectUnauthorized: false } } : {}
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
databaseExtra?: Record<string, unknown> & {
|
||||
@@ -266,16 +262,14 @@ export type ProjectConfigOptions = {
|
||||
*
|
||||
* @example
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* module.exports = defineConfig({
|
||||
* projectConfig: {
|
||||
* databaseDriverOptions:
|
||||
* process.env.NODE_ENV !== "development"
|
||||
* ? { connection: { ssl: { rejectUnauthorized: false } } }
|
||||
* : {},
|
||||
* databaseDriverOptions: process.env.NODE_ENV !== "development" ?
|
||||
* { ssl: { rejectUnauthorized: false } } : {}
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
databaseDriverOptions?: Record<string, unknown> & {
|
||||
@@ -311,14 +305,14 @@ export type ProjectConfigOptions = {
|
||||
*
|
||||
* @example
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* module.exports = defineConfig({
|
||||
* projectConfig: {
|
||||
* redisUrl: process.env.REDIS_URL ||
|
||||
* redisUrl: process.env.REDIS_URL ||
|
||||
* "redis://localhost:6379",
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
redisUrl?: string
|
||||
@@ -330,14 +324,13 @@ export type ProjectConfigOptions = {
|
||||
*
|
||||
* @example
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* module.exports = defineConfig({
|
||||
* projectConfig: {
|
||||
* redisPrefix: process.env.REDIS_PREFIX ||
|
||||
* "medusa:",
|
||||
* redisPrefix: process.env.REDIS_URL || "medusa:",
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
redisPrefix?: string
|
||||
@@ -348,16 +341,16 @@ export type ProjectConfigOptions = {
|
||||
*
|
||||
* @example
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* module.exports = defineConfig({
|
||||
* projectConfig: {
|
||||
* redisOptions: {
|
||||
* connectionName: process.env.REDIS_CONNECTION_NAME ||
|
||||
* connectionName: process.env.REDIS_CONNECTION_NAME ||
|
||||
* "medusa",
|
||||
* },
|
||||
* }
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
redisOptions?: RedisOptions
|
||||
@@ -367,16 +360,15 @@ export type ProjectConfigOptions = {
|
||||
*
|
||||
* @example
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* module.exports = defineConfig({
|
||||
* projectConfig: {
|
||||
* sessionOptions: {
|
||||
* name: process.env.SESSION_NAME ||
|
||||
* "custom",
|
||||
* },
|
||||
* name: process.env.SESSION_NAME || "custom",
|
||||
* }
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
sessionOptions?: SessionOptions
|
||||
@@ -387,21 +379,7 @@ export type ProjectConfigOptions = {
|
||||
*
|
||||
* If you enable HTTP compression and you want to disable it for specific API Routes, you can pass in the request header `"x-no-compression": true`.
|
||||
*
|
||||
* @example
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* projectConfig: {
|
||||
* httpCompression: {
|
||||
* enabled: true,
|
||||
* level: 6,
|
||||
* memLevel: 8,
|
||||
* threshold: 1024,
|
||||
* },
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* }
|
||||
* ```
|
||||
* @ignore
|
||||
*
|
||||
* @deprecated use {@link http }'s `compression` property instead.
|
||||
*
|
||||
@@ -413,13 +391,13 @@ export type ProjectConfigOptions = {
|
||||
*
|
||||
* @example
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* module.exports = defineConfig({
|
||||
* projectConfig: {
|
||||
* jobsBatchSize: 100
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
jobsBatchSize?: number
|
||||
@@ -435,13 +413,13 @@ export type ProjectConfigOptions = {
|
||||
*
|
||||
* @example
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* module.exports = defineConfig({
|
||||
* projectConfig: {
|
||||
* workerMode: "shared"
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
workerMode?: "shared" | "worker" | "server"
|
||||
@@ -451,16 +429,18 @@ export type ProjectConfigOptions = {
|
||||
*
|
||||
* @example
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* module.exports = defineConfig({
|
||||
* projectConfig: {
|
||||
* http: {
|
||||
* cookieSecret: "some-super-secret",
|
||||
* compression: { ... },
|
||||
* cookieSecret: "supersecret",
|
||||
* compression: {
|
||||
* // ...
|
||||
* }
|
||||
* }
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
http: {
|
||||
@@ -472,14 +452,15 @@ export type ProjectConfigOptions = {
|
||||
*
|
||||
* @example
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* module.exports = defineConfig({
|
||||
* projectConfig: {
|
||||
* http: {
|
||||
* cookieSecret: "supersecret"
|
||||
* jwtSecret: "supersecret",
|
||||
* }
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
jwtSecret?: string
|
||||
@@ -488,14 +469,15 @@ export type ProjectConfigOptions = {
|
||||
*
|
||||
* @example
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* module.exports = defineConfig({
|
||||
* projectConfig: {
|
||||
* http: {
|
||||
* jwtExpiresIn: "2d"
|
||||
* }
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
jwtExpiresIn?: string
|
||||
@@ -507,15 +489,15 @@ export type ProjectConfigOptions = {
|
||||
*
|
||||
* @example
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* module.exports = defineConfig({
|
||||
* projectConfig: {
|
||||
* http: {
|
||||
* cookieSecret: "supersecret"
|
||||
* cookieSecret: "supersecret"
|
||||
* }
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
cookieSecret?: string
|
||||
@@ -546,7 +528,7 @@ export type ProjectConfigOptions = {
|
||||
* Then, set the configuration in `medusa-config.js`:
|
||||
*
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* module.exports = defineConfig({
|
||||
* projectConfig: {
|
||||
* http: {
|
||||
* authCors: process.env.AUTH_CORS
|
||||
@@ -554,13 +536,13 @@ export type ProjectConfigOptions = {
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* If you’re adding the value directly within `medusa-config.js`, make sure to add an extra escaping `/` for every backslash in the pattern. For example:
|
||||
*
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* module.exports = defineConfig({
|
||||
* projectConfig: {
|
||||
* http: {
|
||||
* authCors: "/http:\\/\\/localhost:700\\d+$/",
|
||||
@@ -568,7 +550,7 @@ export type ProjectConfigOptions = {
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
authCors: string
|
||||
@@ -583,20 +565,20 @@ export type ProjectConfigOptions = {
|
||||
*
|
||||
* @example
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* module.exports = defineConfig({
|
||||
* projectConfig: {
|
||||
* http: {
|
||||
* compression: {
|
||||
* enabled: true,
|
||||
* level: 6,
|
||||
* memLevel: 8,
|
||||
* threshold: 1024,
|
||||
* threshold: 1024
|
||||
* }
|
||||
* },
|
||||
* }
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
compression?: HttpCompressionOptions
|
||||
@@ -627,7 +609,7 @@ export type ProjectConfigOptions = {
|
||||
* Then, set the configuration in `medusa-config.js`:
|
||||
*
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* module.exports = defineConfig({
|
||||
* projectConfig: {
|
||||
* http: {
|
||||
* storeCors: process.env.STORE_CORS,
|
||||
@@ -635,13 +617,13 @@ export type ProjectConfigOptions = {
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* If you’re adding the value directly within `medusa-config.js`, make sure to add an extra escaping `/` for every backslash in the pattern. For example:
|
||||
*
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* module.exports = defineConfig({
|
||||
* projectConfig: {
|
||||
* http: {
|
||||
* storeCors: "/vercel\\.app$/",
|
||||
@@ -649,7 +631,7 @@ export type ProjectConfigOptions = {
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
storeCors: string
|
||||
@@ -681,7 +663,7 @@ export type ProjectConfigOptions = {
|
||||
* Then, set the configuration in `medusa-config.js`:
|
||||
*
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* module.exports = defineConfig({
|
||||
* projectConfig: {
|
||||
* http: {
|
||||
* adminCors: process.env.ADMIN_CORS,
|
||||
@@ -689,21 +671,21 @@ export type ProjectConfigOptions = {
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* If you’re adding the value directly within `medusa-config.js`, make sure to add an extra escaping `/` for every backslash in the pattern. For example:
|
||||
*
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* module.exports = defineConfig({
|
||||
* projectConfig: {
|
||||
* http: {
|
||||
* adminCors: process.env.ADMIN_CORS,
|
||||
* adminCors: "/vercel\\.app$/",
|
||||
* }
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
adminCors: string
|
||||
@@ -721,18 +703,18 @@ export type ProjectConfigOptions = {
|
||||
* Then, set the configuration in `medusa-config.js`:
|
||||
*
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* module.exports = defineConfig({
|
||||
* projectConfig: {
|
||||
* http: {
|
||||
* authMethodsPerActor: {
|
||||
* user: ['sso'],
|
||||
* customer: ["emailpass", "google"]
|
||||
* },
|
||||
* },
|
||||
* user: ["email"],
|
||||
* customer: ["emailpas", "google"]
|
||||
* }
|
||||
* }
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
authMethodsPerActor?: Record<string, string[]>
|
||||
@@ -755,12 +737,20 @@ export type ProjectConfigOptions = {
|
||||
* For example:
|
||||
*
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* projectConfig,
|
||||
* admin,
|
||||
* modules,
|
||||
* featureFlags,
|
||||
* }
|
||||
* module.exports = defineConfig({
|
||||
* projectConfig: {
|
||||
* // ...
|
||||
* },
|
||||
* admin: {
|
||||
* // ...
|
||||
* },
|
||||
* modules: {
|
||||
* // ...
|
||||
* },
|
||||
* featureFlags: {
|
||||
* // ...
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* ---
|
||||
@@ -785,12 +775,13 @@ export type ConfigModule = {
|
||||
*
|
||||
* @example
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* module.exports = defineConfig({
|
||||
* admin: {
|
||||
* backendUrl: process.env.MEDUSA_BACKEND_URL || "http://localhost:9000"
|
||||
* }
|
||||
* backendUrl: process.env.MEDUSA_BACKEND_URL ||
|
||||
* "http://localhost:9000"
|
||||
* },
|
||||
* // ...
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
admin?: AdminOptions
|
||||
@@ -825,6 +816,11 @@ export type ConfigModule = {
|
||||
* // ...
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @ignore
|
||||
*
|
||||
* @privateRemarks
|
||||
* Added the `@\ignore` tag for now so it's not generated in the main docs until we figure out what to do with plugins
|
||||
*/
|
||||
plugins: (
|
||||
| {
|
||||
@@ -840,35 +836,24 @@ export type ConfigModule = {
|
||||
*
|
||||
* Aside from installing the module with NPM, you must add it to the exported object in `medusa-config.js`.
|
||||
*
|
||||
* The keys of the `modules` configuration object refer to the type of module. Its value can be one of the following:
|
||||
* The keys of the `modules` configuration object refer to the module's registration name. Its value can be one of the following:
|
||||
*
|
||||
* 1. A boolean value indicating whether the module type is enabled;
|
||||
* 2. Or a string value indicating the name of the module to be used for the module type. This can be used if the module does not require any options;
|
||||
* 3. Or an object having the following properties, but typically you would mainly use the `resolve` and `options` properties only:
|
||||
* 1. `resolve`: a string indicating the name of the module.
|
||||
* 2. `options`: an object indicating the options to pass to the module. These options vary for each module, and you should refer to the module’s documentation for details on them.
|
||||
* 3. `resources`: a string indicating whether the module shares the dependency container with the Medusa core. Its value can either be `shared` or `isolated`. Refer to the [Modules documentation](https://docs.medusajs.com/development/modules/create#module-scope) for more details.
|
||||
* 4. `alias`: a string indicating a unique alias to register the module under. Other modules can’t use the same alias.
|
||||
* 5. `main`: a boolean value indicating whether this module is the main registered module. This is useful when an alias is used.
|
||||
* 1. A boolean value indicating whether the module type is enabled. This is only supported for Medusa's commerce and architectural modules;
|
||||
* 2. Or an object having the following properties:
|
||||
* 1. `resolve`: a string indicating the path to the module relative to `src`, or the module's NPM package name.
|
||||
* 2. `options`: (optional) an object indicating the options to pass to the module.
|
||||
* 3. `definition`: (optional) an object of extra configurations, such as `isQueryable` used when a module has relationships.
|
||||
*
|
||||
* @example
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* module.exports = defineConfig({
|
||||
* modules: {
|
||||
* eventBus: {
|
||||
* resolve: "@medusajs/event-bus-local",
|
||||
* },
|
||||
* cacheService: {
|
||||
* resolve: "@medusajs/cache-redis",
|
||||
* options: {
|
||||
* redisUrl: process.env.CACHE_REDIS_URL,
|
||||
* ttl: 30,
|
||||
* },
|
||||
* },
|
||||
* // ...
|
||||
* },
|
||||
* helloModuleService: {
|
||||
* resolve: "./modules/hello"
|
||||
* }
|
||||
* }
|
||||
* // ...
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
modules?: Record<
|
||||
@@ -882,26 +867,24 @@ export type ConfigModule = {
|
||||
* You can specify whether a feature should or shouldn’t be used in your backend by enabling its feature flag. Feature flags can be enabled through either environment
|
||||
* variables or through this configuration exported in `medusa-config.js`.
|
||||
*
|
||||
* If you want to use the environment variables method, learn more about it in the [Feature Flags documentation](https://docs.medusajs.com/development/feature-flags/toggle#method-one-using-environment-variables).
|
||||
*
|
||||
* The `featureFlags` configuration is an object. Its properties are the names of the feature flags. Each property’s value is a boolean indicating whether the feature flag is enabled.
|
||||
*
|
||||
* You can find available feature flags and their key name [here](https://github.com/medusajs/medusa/tree/master/packages/medusa/src/loaders/feature-flags).
|
||||
* You can find available feature flags and their key name [here](https://github.com/medusajs/medusa/tree/develop/packages/medusa/src/loaders/feature-flags).
|
||||
*
|
||||
* @example
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
* module.exports = defineConfig({
|
||||
* featureFlags: {
|
||||
* product_categories: true,
|
||||
* // ...
|
||||
* },
|
||||
* }
|
||||
* // ...
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* :::note
|
||||
*
|
||||
* After enabling a feature flag, make sure to [run migrations](https://docs.medusajs.com/development/entities/migrations/overview#migrate-command) as it may require making changes to the database.
|
||||
* After enabling a feature flag, make sure to run migrations as it may require making changes to the database.
|
||||
*
|
||||
* :::
|
||||
*/
|
||||
|
||||
@@ -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 module’s 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` property’s value is an object. You can pass any properties you want.
|
||||
|
||||
@@ -62,13 +62,15 @@ The last step is to add the module in Medusa’s 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 module’s 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 Medusa’s 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 application’s 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",
|
||||
// ...
|
||||
}
|
||||
},
|
||||
}
|
||||
// ...
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -55,26 +55,28 @@ const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
const modules = {
|
||||
module.exports = defineConfig({
|
||||
// ...
|
||||
[Modules.AUTH]: {
|
||||
resolve: "@medusajs/auth",
|
||||
options: {
|
||||
providers: [
|
||||
{
|
||||
resolve: "./dist/modules/my-auth",
|
||||
options: {
|
||||
config: {
|
||||
"my-auth": {
|
||||
// provider options...
|
||||
modules: {
|
||||
[Modules.AUTH]: {
|
||||
resolve: "@medusajs/auth",
|
||||
options: {
|
||||
providers: [
|
||||
{
|
||||
resolve: "./modules/my-auth",
|
||||
options: {
|
||||
config: {
|
||||
"my-auth": {
|
||||
// provider options...
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
\`\`\`
|
||||
`,
|
||||
],
|
||||
|
||||
@@ -61,26 +61,28 @@ const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
const modules = {
|
||||
module.exports = defineConfig({
|
||||
// ...
|
||||
[Modules.FILE]: {
|
||||
resolve: "@medusajs/file",
|
||||
options: {
|
||||
providers: [
|
||||
{
|
||||
resolve: "./dist/modules/my-file",
|
||||
options: {
|
||||
config: {
|
||||
"my-file": {
|
||||
// provider options...
|
||||
modules: {
|
||||
[Modules.FILE]: {
|
||||
resolve: "@medusajs/file",
|
||||
options: {
|
||||
providers: [
|
||||
{
|
||||
resolve: "./modules/my-file",
|
||||
options: {
|
||||
config: {
|
||||
"my-file": {
|
||||
// provider options...
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
\`\`\`
|
||||
`,
|
||||
],
|
||||
|
||||
@@ -55,26 +55,28 @@ const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
const modules = {
|
||||
module.exports = defineConfig({
|
||||
// ...
|
||||
[Modules.FULFILLMENT]: {
|
||||
resolve: "@medusajs/fulfillment",
|
||||
options: {
|
||||
providers: [
|
||||
{
|
||||
resolve: "./dist/modules/my-fulfillment",
|
||||
options: {
|
||||
config: {
|
||||
"my-fulfillment": {
|
||||
// provider options...
|
||||
modules: {
|
||||
[Modules.FULFILLMENT]: {
|
||||
resolve: "@medusajs/fulfillment",
|
||||
options: {
|
||||
providers: [
|
||||
{
|
||||
resolve: "./dist/modules/my-fulfillment",
|
||||
options: {
|
||||
config: {
|
||||
"my-fulfillment": {
|
||||
// provider options...
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
\`\`\`
|
||||
`,
|
||||
],
|
||||
|
||||
@@ -70,27 +70,29 @@ const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
const modules = {
|
||||
module.exports = defineConfig({
|
||||
// ...
|
||||
[Modules.NOTIFICATION]: {
|
||||
resolve: "@medusajs/notification",
|
||||
options: {
|
||||
providers: [
|
||||
{
|
||||
resolve: "./dist/modules/my-notification",
|
||||
options: {
|
||||
config: {
|
||||
"my-notification": {
|
||||
channels: ["email"],
|
||||
// provider options...
|
||||
modules: {
|
||||
[Modules.NOTIFICATION]: {
|
||||
resolve: "@medusajs/notification",
|
||||
options: {
|
||||
providers: [
|
||||
{
|
||||
resolve: "./dist/modules/my-notification",
|
||||
options: {
|
||||
config: {
|
||||
"my-notification": {
|
||||
channels: ["email"],
|
||||
// provider options...
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
\`\`\`
|
||||
`,
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user