chore: Rename config properties to camelCase (#7498)

* refactor: rename config types to camelCase

* refactor: update config references to use renamed options

* refactor: update more references

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
Harminder Virk
2024-05-28 18:19:29 +05:30
committed by GitHub
parent e60b4bafe1
commit 82be054a1a
15 changed files with 297 additions and 140 deletions

View File

@@ -13,7 +13,7 @@ describe("Database options", () => {
const cwd = path.resolve(path.join(__dirname, "..", ".."))
dbConnection = await initDb({
cwd,
database_extra: { idle_in_transaction_session_timeout: 1000 },
databaseExtra: { idle_in_transaction_session_timeout: 1000 },
})
medusaProcess = await setupServer({ cwd })
})

View File

@@ -21,9 +21,9 @@ module.exports = {
disable: true,
},
projectConfig: {
redis_url: redisUrl,
database_url: DB_URL,
database_type: "postgres",
redisUrl: redisUrl,
databaseUrl: DB_URL,
databaseType: "postgres",
http: {
compression: {
enabled: enableResponseCompression,

View File

@@ -91,7 +91,7 @@ const instance = DbTestUtil
module.exports = {
initDb: async function ({
cwd,
database_extra,
databaseExtra,
env,
force_modules_migration,
}) {
@@ -145,7 +145,7 @@ module.exports = {
url: DB_URL,
entities: enabledEntities.concat(moduleModels),
migrations: enabledMigrations.concat(moduleMigrations),
extra: database_extra ?? {},
extra: databaseExtra ?? {},
name: "integration-tests",
})

View File

@@ -36,8 +36,8 @@ module.exports = {
},
plugins: [],
projectConfig: {
database_url: DB_URL,
database_type: "postgres",
databaseUrl: DB_URL,
databaseType: "postgres",
http: {
jwtSecret: "test",
cookieSecret: "test",

View File

@@ -103,8 +103,8 @@ export function medusaIntegrationTestRunner({
rootDirectory: string
) => {
const config = originalConfigLoader(rootDirectory)
config.projectConfig.database_url = dbConfig.clientUrl
config.projectConfig.database_driver_options = dbConfig.clientUrl.includes(
config.projectConfig.databaseUrl = dbConfig.clientUrl
config.projectConfig.databaseDriverOptions = dbConfig.clientUrl.includes(
"localhost"
)
? {}

View File

@@ -118,7 +118,7 @@ export type HttpCompressionOptions = {
*/
export type ProjectConfigOptions = {
/**
* The name of the database to connect to. If specified in `database_url`, then its not required to include it.
* The name of the database to connect to. If specified in `databaseUrl`, then its not required to include it.
*
* Make sure to create the PostgreSQL database before using it. You can check how to create a database in
* [PostgreSQL's documentation](https://www.postgresql.org/docs/current/sql-createdatabase.html).
@@ -127,7 +127,7 @@ export type ProjectConfigOptions = {
* ```js title="medusa-config.js"
* module.exports = {
* projectConfig: {
* database_database: process.env.DATABASE_DATABASE ||
* databaseName: process.env.DATABASE_DATABASE ||
* "medusa-store",
* // ...
* },
@@ -135,7 +135,7 @@ export type ProjectConfigOptions = {
* }
* ```
*/
database_database?: string
databaseName?: string
/**
* The connection URL of the database. The format of the connection URL for PostgreSQL is:
@@ -166,21 +166,22 @@ export type ProjectConfigOptions = {
* ```js title="medusa-config.js"
* module.exports = {
* projectConfig: {
* database_url: process.env.DATABASE_URL,
* databaseUrl: process.env.DATABASE_URL,
* // ...
* },
* // ...
* }
* ```
*/
database_url?: string
databaseUrl?: string
/**
* The database schema to connect to. This is not required to provide if youre using the default schema, which is `public`.
*
* ```js title="medusa-config.js"
* module.exports = {
* projectConfig: {
* database_schema: process.env.DATABASE_SCHEMA ||
* databaseSchema: process.env.DATABASE_SCHEMA ||
* "custom",
* // ...
* },
@@ -188,7 +189,7 @@ export type ProjectConfigOptions = {
* }
* ```
*/
database_schema?: string
databaseSchema?: string
/**
* This configuration specifies what database messages to log. Its value can be one of the following:
@@ -203,7 +204,7 @@ export type ProjectConfigOptions = {
* ```js title="medusa-config.js"
* module.exports = {
* projectConfig: {
* database_logging: [
* databaseLogging: [
* "query", "error",
* ],
* // ...
@@ -212,7 +213,7 @@ export type ProjectConfigOptions = {
* }
* ```
*/
database_logging: LoggerOptions
databaseLogging: LoggerOptions
/**
* @ignore
@@ -221,7 +222,7 @@ export type ProjectConfigOptions = {
* @privateRemarks
* only postgres is supported, so this config has no effect
*/
database_type?: string
databaseType?: string
/**
* An object that includes additional configurations to pass to the database connection. You can pass any configuration. One defined configuration to pass is
@@ -234,7 +235,7 @@ export type ProjectConfigOptions = {
* ```js title="medusa-config.js"
* module.exports = {
* projectConfig: {
* database_extra:
* databaseExtra:
* process.env.NODE_ENV !== "development"
* ? { ssl: { rejectUnauthorized: false } }
* : {},
@@ -244,7 +245,7 @@ export type ProjectConfigOptions = {
* }
* ```
*/
database_extra?: Record<string, unknown> & {
databaseExtra?: Record<string, unknown> & {
/**
* Configure support for TLS/SSL connection
*/
@@ -267,7 +268,7 @@ export type ProjectConfigOptions = {
* ```js title="medusa-config.js"
* module.exports = {
* projectConfig: {
* database_driver_options:
* databaseDriverOptions:
* process.env.NODE_ENV !== "development"
* ? { connection: { ssl: { rejectUnauthorized: false } } }
* : {},
@@ -277,7 +278,7 @@ export type ProjectConfigOptions = {
* }
* ```
*/
database_driver_options?: Record<string, unknown> & {
databaseDriverOptions?: Record<string, unknown> & {
connection?: {
/**
* Configure support for TLS/SSL connection
@@ -312,7 +313,7 @@ export type ProjectConfigOptions = {
* ```js title="medusa-config.js"
* module.exports = {
* projectConfig: {
* redis_url: process.env.REDIS_URL ||
* redisUrl: process.env.REDIS_URL ||
* "redis://localhost:6379",
* // ...
* },
@@ -320,7 +321,7 @@ export type ProjectConfigOptions = {
* }
* ```
*/
redis_url?: string
redisUrl?: string
/**
* The prefix set on all keys stored in Redis. The default value is `sess:`.
@@ -331,7 +332,7 @@ export type ProjectConfigOptions = {
* ```js title="medusa-config.js"
* module.exports = {
* projectConfig: {
* redis_prefix: process.env.REDIS_PREFIX ||
* redisPrefix: process.env.REDIS_PREFIX ||
* "medusa:",
* // ...
* },
@@ -339,7 +340,7 @@ export type ProjectConfigOptions = {
* }
* ```
*/
redis_prefix?: string
redisPrefix?: string
/**
* An object of options to pass ioredis. You can refer to [iorediss RedisOptions documentation](https://redis.github.io/ioredis/index.html#RedisOptions)
@@ -349,7 +350,7 @@ export type ProjectConfigOptions = {
* ```js title="medusa-config.js"
* module.exports = {
* projectConfig: {
* redis_options: {
* redisOptions: {
* connectionName: process.env.REDIS_CONNECTION_NAME ||
* "medusa",
* },
@@ -359,7 +360,7 @@ export type ProjectConfigOptions = {
* }
* ```
*/
redis_options?: RedisOptions
redisOptions?: RedisOptions
/**
* An object of options to pass to [express-session](https://www.npmjs.com/package/express-session).
@@ -368,7 +369,7 @@ export type ProjectConfigOptions = {
* ```js title="medusa-config.js"
* module.exports = {
* projectConfig: {
* session_options: {
* sessionOptions: {
* name: process.env.SESSION_NAME ||
* "custom",
* },
@@ -378,7 +379,7 @@ export type ProjectConfigOptions = {
* }
* ```
*/
session_options?: SessionOptions
sessionOptions?: SessionOptions
/**
* Configure HTTP compression from the application layer. If you have access to the HTTP server, the recommended approach would be to enable it there.
@@ -390,7 +391,7 @@ export type ProjectConfigOptions = {
* ```js title="medusa-config.js"
* module.exports = {
* projectConfig: {
* http_compression: {
* httpCompression: {
* enabled: true,
* level: 6,
* memLevel: 8,
@@ -405,7 +406,7 @@ export type ProjectConfigOptions = {
* @deprecated use {@link http }'s `compression` property instead.
*
*/
http_compression?: HttpCompressionOptions
httpCompression?: HttpCompressionOptions
/**
* Configure the number of staged jobs that are polled from the database. Default is `1000`.
@@ -414,14 +415,14 @@ export type ProjectConfigOptions = {
* ```js title="medusa-config.js"
* module.exports = {
* projectConfig: {
* jobs_batch_size: 100
* jobsBatchSize: 100
* // ...
* },
* // ...
* }
* ```
*/
jobs_batch_size?: number
jobsBatchSize?: number
/**
* Configure the application's worker mode. Default is `shared`.
@@ -436,14 +437,14 @@ export type ProjectConfigOptions = {
* ```js title="medusa-config.js"
* module.exports = {
* projectConfig: {
* worker_mode: "shared"
* workerMode: "shared"
* // ...
* },
* // ...
* }
* ```
*/
worker_mode?: "shared" | "worker" | "server"
workerMode?: "shared" | "worker" | "server"
/**
* Configure the application's http-specific settings
@@ -652,6 +653,7 @@ export type ProjectConfigOptions = {
* ```
*/
storeCors: string
/**
* The Medusa backends API Routes are protected by Cross-Origin Resource Sharing (CORS). So, only allowed URLs or URLs matching a specified pattern can send requests to the backends API Routes.
*

View File

@@ -57,30 +57,30 @@ const buildHttpConfig = (projectConfig: ConfigModule["projectConfig"]) => {
const normalizeProjectConfig = (
projectConfig: ConfigModule["projectConfig"]
) => {
if (!projectConfig?.redis_url) {
if (!projectConfig?.redisUrl) {
console.log(
`[medusa-config] ⚠️ redis_url not found. A fake redis instance will be used.`
`[medusa-config] ⚠️ redisUrl not found. A fake redis instance will be used.`
)
}
projectConfig.http = buildHttpConfig(projectConfig)
let worker_mode = projectConfig?.worker_mode
let workedMode = projectConfig?.workerMode
if (!isDefined(worker_mode)) {
if (!isDefined(workedMode)) {
const env = process.env.MEDUSA_WORKER_MODE
if (isDefined(env)) {
if (env === "shared" || env === "worker" || env === "server") {
worker_mode = env
workedMode = env
}
} else {
worker_mode = "shared"
workedMode = "shared"
}
}
return {
...projectConfig,
worker_mode,
workerMode: workedMode,
}
}

View File

@@ -28,33 +28,33 @@ export default async ({
sameSite = "none"
}
const { http, session_options } = configModule.projectConfig
const { http, sessionOptions } = configModule.projectConfig
const sessionOpts = {
name: session_options?.name ?? "connect.sid",
resave: session_options?.resave ?? true,
rolling: session_options?.rolling ?? false,
saveUninitialized: session_options?.saveUninitialized ?? true,
name: sessionOptions?.name ?? "connect.sid",
resave: sessionOptions?.resave ?? true,
rolling: sessionOptions?.rolling ?? false,
saveUninitialized: sessionOptions?.saveUninitialized ?? true,
proxy: true,
secret: session_options?.secret ?? http?.cookieSecret,
secret: sessionOptions?.secret ?? http?.cookieSecret,
cookie: {
sameSite,
secure,
maxAge: session_options?.ttl ?? 10 * 60 * 60 * 1000,
maxAge: sessionOptions?.ttl ?? 10 * 60 * 60 * 1000,
},
store: null,
}
let redisClient
if (configModule?.projectConfig?.redis_url) {
if (configModule?.projectConfig?.redisUrl) {
const RedisStore = createStore(session)
redisClient = new Redis(
configModule.projectConfig.redis_url,
configModule.projectConfig.redis_options ?? {}
configModule.projectConfig.redisUrl,
configModule.projectConfig.redisOptions ?? {}
)
sessionOpts.store = new RedisStore({
client: redisClient,
prefix: `${configModule?.projectConfig?.redis_prefix ?? ""}sess:`,
prefix: `${configModule?.projectConfig?.redisPrefix ?? ""}sess:`,
})
}

View File

@@ -6,7 +6,7 @@ export const storeGlobalMiddlewareMock = jest.fn()
export const config: ConfigModule = {
projectConfig: {
database_logging: false,
databaseLogging: false,
http: {
authCors: "http://localhost:9000",
storeCors: "http://localhost:8000",

View File

@@ -27,7 +27,7 @@ type Options = {
}
const isWorkerMode = (configModule) => {
return configModule.projectConfig.worker_mode === "worker"
return configModule.projectConfig.workerMode === "worker"
}
async function subscribersLoader(

View File

@@ -85,9 +85,9 @@ async function runMedusaAppMigrations({
clientUrl:
injectedDependencies[ContainerRegistrationKeys.PG_CONNECTION]?.client
?.config?.connection?.connectionString ??
configModule.projectConfig.database_url,
driverOptions: configModule.projectConfig.database_driver_options,
debug: !!(configModule.projectConfig.database_logging ?? false),
configModule.projectConfig.databaseUrl,
driverOptions: configModule.projectConfig.databaseDriverOptions,
debug: !!(configModule.projectConfig.databaseLogging ?? false),
},
}
const configModules = mergeDefaultModules(configModule.modules)
@@ -175,9 +175,9 @@ export const loadMedusaApp = async (
const sharedResourcesConfig = {
database: {
clientUrl: configModule.projectConfig.database_url,
driverOptions: configModule.projectConfig.database_driver_options,
debug: !!(configModule.projectConfig.database_logging ?? false),
clientUrl: configModule.projectConfig.databaseUrl,
driverOptions: configModule.projectConfig.databaseDriverOptions,
debug: !!(configModule.projectConfig.databaseLogging ?? false),
},
}
@@ -187,7 +187,7 @@ export const loadMedusaApp = async (
const configModules = mergeDefaultModules(configModule.modules)
const medusaApp = await MedusaApp({
workerMode: configModule.projectConfig.worker_mode,
workerMode: configModule.projectConfig.workerMode,
modulesConfig: configModules,
sharedContainer: container,
linkModules,
@@ -256,9 +256,9 @@ export async function runModulesLoader({
const sharedResourcesConfig = {
database: {
clientUrl: configModule.projectConfig.database_url,
driverOptions: configModule.projectConfig.database_driver_options,
debug: !!(configModule.projectConfig.database_logging ?? false),
clientUrl: configModule.projectConfig.databaseUrl,
driverOptions: configModule.projectConfig.databaseDriverOptions,
debug: !!(configModule.projectConfig.databaseLogging ?? false),
},
}

View File

@@ -13,10 +13,10 @@ export default async ({ container, configModule }: Options): Promise<any> => {
}
// Share a knex connection to be consumed by the shared modules
const connectionString = configModule.projectConfig.database_url
const connectionString = configModule.projectConfig.databaseUrl
const driverOptions: any =
configModule.projectConfig.database_driver_options || {}
const schema = configModule.projectConfig.database_schema || "public"
configModule.projectConfig.databaseDriverOptions || {}
const schema = configModule.projectConfig.databaseSchema || "public"
const idleTimeoutMillis = driverOptions.pool?.idleTimeoutMillis ?? undefined // prevent null to be passed
const poolMax = driverOptions.pool?.max

View File

@@ -19,11 +19,11 @@ async function redisLoader({
}: Options): Promise<{ shutdown: () => Promise<void> }> {
let client!: Redis | FakeRedis
if (configModule.projectConfig.redis_url) {
client = new Redis(configModule.projectConfig.redis_url, {
if (configModule.projectConfig.redisUrl) {
client = new Redis(configModule.projectConfig.redisUrl, {
// Lazy connect to properly handle connection errors
lazyConnect: true,
...(configModule.projectConfig.redis_options ?? {}),
...(configModule.projectConfig.redisOptions ?? {}),
})
try {

View File

@@ -13,7 +13,7 @@ export default async ({
if (!redisUrl) {
throw Error(
"No `redis_url` provided in project config. It is required for the Redis Event Bus."
"No `redisUrl` provided in project config. It is required for the Redis Event Bus."
)
}
@@ -27,7 +27,7 @@ export default async ({
})
try {
await new Promise(async resolve => {
await new Promise(async (resolve) => {
await connection.connect(resolve)
})
logger?.info(`Connection to Redis in module 'event-bus-redis' established`)

View File

@@ -11,7 +11,7 @@ In this document, youll learn how to create a file service in the Medusa back
## Prerequisites
This document assumes you already followed along with the [Prepare Environment documentation](https://docs.medusajs.com/development/backend/prepare-environment) and have a Medusa backend installed.
---
The configurations for your Medusa backend are in `medusa-config.js` located in the root of your Medusa project. The configurations include database, modules, and plugin configurations, among other configurations.
@@ -49,7 +49,7 @@ setting the environment variables depends on the hosting provider.
This property holds essential configurations related to the Medusa backend, such as database and CORS configurations.
### store\_cors
### store_cors
The Medusa backends API Routes are protected by Cross-Origin Resource Sharing (CORS). So, only allowed URLs or URLs matching a specified pattern can send requests to the backends API Routes.
@@ -99,7 +99,7 @@ module.exports = {
}
```
### admin\_cors
### admin_cors
The Medusa backends API Routes are protected by Cross-Origin Resource Sharing (CORS). So, only allowed URLs or URLs matching a specified pattern can send requests to the backends API Routes.
@@ -149,7 +149,7 @@ module.exports = {
}
```
### auth\_cors
### authCors
The Medusa backends API Routes are protected by Cross-Origin Resource Sharing (CORS). So, only allowed URLs or URLs matching a specified pattern can send requests to the backends API Routes.
@@ -180,7 +180,7 @@ Then, set the configuration in `medusa-config.js`:
```js title="medusa-config.js"
module.exports = {
projectConfig: {
auth_cors: process.env.AUTH_CORS,
authCors: process.env.AUTH_CORS,
// ...
},
// ...
@@ -192,14 +192,14 @@ If youre adding the value directly within `medusa-config.js`, make sure to ad
```js title="medusa-config.js"
module.exports = {
projectConfig: {
auth_cors: "/http:\\/\\/localhost:700\\d+$/",
authCors: "/http:\\/\\/localhost:700\\d+$/",
// ...
},
// ...
}
```
### cookie\_secret
### cookieSecret
A random string used to create cookie tokens. Although this configuration option is not required, its highly recommended to set it for better security.
@@ -211,15 +211,14 @@ the backend crashes.
```js title="medusa-config.js"
module.exports = {
projectConfig: {
cookie_secret: process.env.COOKIE_SECRET ||
"supersecret",
cookieSecret: process.env.COOKIE_SECRET || "supersecret",
// ...
},
// ...
}
```
### jwt\_secret
### jwtSecret
A random string used to create authentication tokens. Although this configuration option is not required, its highly recommended to set it for better security.
@@ -231,17 +230,16 @@ error is thrown and the backend crashes.
```js title="medusa-config.js"
module.exports = {
projectConfig: {
jwt_secret: process.env.JWT_SECRET ||
"supersecret",
jwtSecret: process.env.JWT_SECRET || "supersecret",
// ...
},
// ...
}
```
### database\_database
### databaseName
The name of the database to connect to. If specified in `database_url`, then its not required to include it.
The name of the database to connect to. If specified in `databaseUrl`, then its not required to include it.
Make sure to create the PostgreSQL database before using it. You can check how to create a database in
[PostgreSQL's documentation](https://www.postgresql.org/docs/current/sql-createdatabase.html).
@@ -251,15 +249,14 @@ Make sure to create the PostgreSQL database before using it. You can check how t
```js title="medusa-config.js"
module.exports = {
projectConfig: {
database_database: process.env.DATABASE_DATABASE ||
"medusa-store",
databaseName: process.env.DATABASE_DATABASE || "medusa-store",
// ...
},
// ...
}
```
### database\_url
### databaseUrl
The connection URL of the database. The format of the connection URL for PostgreSQL is:
@@ -290,29 +287,28 @@ Then, use the value in `medusa-config.js`:
```js title="medusa-config.js"
module.exports = {
projectConfig: {
database_url: process.env.DATABASE_URL,
databaseUrl: process.env.DATABASE_URL,
// ...
},
// ...
}
```
### database\_schema
### databaseSchema
The database schema to connect to. This is not required to provide if youre using the default schema, which is `public`.
```js title="medusa-config.js"
module.exports = {
projectConfig: {
database_schema: process.env.DATABASE_SCHEMA ||
"custom",
databaseSchema: process.env.DATABASE_SCHEMA || "custom",
// ...
},
// ...
}
```
### database\_logging
### databaseLogging
This configuration specifies what database messages to log. Its value can be one of the following:
@@ -327,16 +323,14 @@ If this configuration isn't set, its default value is `false`, meaning no databa
```js title="medusa-config.js"
module.exports = {
projectConfig: {
database_logging: [
"query", "error",
],
databaseLogging: ["query", "error"],
// ...
},
// ...
}
```
### database\_extra
### databaseExtra
An object that includes additional configurations to pass to the database connection. You can pass any configuration. One defined configuration to pass is
`ssl` which enables support for TLS/SSL connections.
@@ -349,7 +343,7 @@ During development, its recommended not to pass this option.
```js title="medusa-config.js"
module.exports = {
projectConfig: {
database_extra:
databaseExtra:
process.env.NODE_ENV !== "development"
? { ssl: { rejectUnauthorized: false } }
: {},
@@ -361,9 +355,33 @@ module.exports = {
#### Properties
<TypeList types={[{"name":"ssl","type":"`object`","description":"Configure support for TLS/SSL connection","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"rejectUnauthorized","type":"`false`","description":"Whether to fail connection if the server certificate is verified against the list of supplied CAs and the hostname and no match is found.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} sectionTitle="database_extra"/>
<TypeList
types={[
{
name: "ssl",
type: "`object`",
description: "Configure support for TLS/SSL connection",
optional: false,
defaultValue: "",
expandable: false,
children: [
{
name: "rejectUnauthorized",
type: "`false`",
description:
"Whether to fail connection if the server certificate is verified against the list of supplied CAs and the hostname and no match is found.",
optional: false,
defaultValue: "",
expandable: false,
children: [],
},
],
},
]}
sectionTitle="database_extra"
/>
### database\_driver\_options
### databaseDriverOptions
An object that includes additional configurations to pass to the database connection for v2. You can pass any configuration. One defined configuration to pass is
`ssl` which enables support for TLS/SSL connections.
@@ -376,7 +394,7 @@ During development, its recommended not to pass this option.
```js title="medusa-config.js"
module.exports = {
projectConfig: {
database_driver_options:
databaseDriverOptions:
process.env.NODE_ENV !== "development"
? { connection: { ssl: { rejectUnauthorized: false } } }
: {},
@@ -388,9 +406,43 @@ module.exports = {
#### Properties
<TypeList types={[{"name":"connection","type":"`object`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"ssl","type":"`object`","description":"Configure support for TLS/SSL connection","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"rejectUnauthorized","type":"`false`","description":"Whether to fail connection if the server certificate is verified against the list of supplied CAs and the hostname and no match is found.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} sectionTitle="database_driver_options"/>
<TypeList
types={[
{
name: "connection",
type: "`object`",
description: "",
optional: true,
defaultValue: "",
expandable: false,
children: [
{
name: "ssl",
type: "`object`",
description: "Configure support for TLS/SSL connection",
optional: true,
defaultValue: "",
expandable: false,
children: [
{
name: "rejectUnauthorized",
type: "`false`",
description:
"Whether to fail connection if the server certificate is verified against the list of supplied CAs and the hostname and no match is found.",
optional: true,
defaultValue: "",
expandable: false,
children: [],
},
],
},
],
},
]}
sectionTitle="database_driver_options"
/>
### redis\_url
### redisUrl
Used to specify the URL to connect to Redis. This is only used for scheduled jobs. If you omit this configuration, scheduled jobs won't work.
@@ -413,15 +465,14 @@ For a local Redis installation, the connection URL should be `redis://localhost:
```js title="medusa-config.js"
module.exports = {
projectConfig: {
redis_url: process.env.REDIS_URL ||
"redis://localhost:6379",
redisUrl: process.env.REDIS_URL || "redis://localhost:6379",
// ...
},
// ...
}
```
### redis\_prefix
### redisPrefix
The prefix set on all keys stored in Redis. The default value is `sess:`.
@@ -432,15 +483,14 @@ If this configuration option is provided, it is prepended to `sess:`.
```js title="medusa-config.js"
module.exports = {
projectConfig: {
redis_prefix: process.env.REDIS_PREFIX ||
"medusa:",
redisPrefix: process.env.REDIS_PREFIX || "medusa:",
// ...
},
// ...
}
```
### redis\_options
### redisOptions
An object of options to pass ioredis. You can refer to [iorediss RedisOptions documentation](https://redis.github.io/ioredis/index.html#RedisOptions)
for the list of available options.
@@ -450,9 +500,8 @@ for the list of available options.
```js title="medusa-config.js"
module.exports = {
projectConfig: {
redis_options: {
connectionName: process.env.REDIS_CONNECTION_NAME ||
"medusa",
redisOptions: {
connectionName: process.env.REDIS_CONNECTION_NAME || "medusa",
},
// ...
},
@@ -460,7 +509,7 @@ module.exports = {
}
```
### session\_options
### sessionOptions
An object of options to pass to [express-session](https://www.npmjs.com/package/express-session).
@@ -469,9 +518,8 @@ An object of options to pass to [express-session](https://www.npmjs.com/package/
```js title="medusa-config.js"
module.exports = {
projectConfig: {
session_options: {
name: process.env.SESSION_NAME ||
"custom",
sessionOptions: {
name: process.env.SESSION_NAME || "custom",
},
// ...
},
@@ -481,9 +529,73 @@ module.exports = {
#### Properties
<TypeList types={[{"name":"name","type":"`string`","description":"The name of the session ID cookie to set in the response (and read from in the request). The default value is `connect.sid`.\nRefer to [express-sessions documentation](https://www.npmjs.com/package/express-session#name) for more details.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"resave","type":"`boolean`","description":"Whether the session should be saved back to the session store, even if the session was never modified during the request. The default value is `true`.\nRefer to [express-sessions documentation](https://www.npmjs.com/package/express-session#resave) for more details.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rolling","type":"`boolean`","description":"Whether the session identifier cookie should be force-set on every response. The default value is `false`.\nRefer to [express-sessions documentation](https://www.npmjs.com/package/express-session#rolling) for more details.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"saveUninitialized","type":"`boolean`","description":"Whether a session that is \"uninitialized\" is forced to be saved to the store. The default value is `true`.\nRefer to [express-sessions documentation](https://www.npmjs.com/package/express-session#saveUninitialized) for more details.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"secret","type":"`string`","description":"The secret to sign the session ID cookie. By default, the value of `cookie_secret` is used.\nRefer to [express-sessions documentation](https://www.npmjs.com/package/express-session#secret) for details.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ttl","type":"`number`","description":"Used when calculating the `Expires` `Set-Cookie` attribute of cookies. By default, its value is `10 * 60 * 60 * 1000`.\nRefer to [express-sessions documentation](https://www.npmjs.com/package/express-session#cookiemaxage) for details.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="session_options"/>
<TypeList
types={[
{
name: "name",
type: "`string`",
description:
"The name of the session ID cookie to set in the response (and read from in the request). The default value is `connect.sid`.\nRefer to [express-sessions documentation](https://www.npmjs.com/package/express-session#name) for more details.",
optional: true,
defaultValue: "",
expandable: false,
children: [],
},
{
name: "resave",
type: "`boolean`",
description:
"Whether the session should be saved back to the session store, even if the session was never modified during the request. The default value is `true`.\nRefer to [express-sessions documentation](https://www.npmjs.com/package/express-session#resave) for more details.",
optional: true,
defaultValue: "",
expandable: false,
children: [],
},
{
name: "rolling",
type: "`boolean`",
description:
"Whether the session identifier cookie should be force-set on every response. The default value is `false`.\nRefer to [express-sessions documentation](https://www.npmjs.com/package/express-session#rolling) for more details.",
optional: true,
defaultValue: "",
expandable: false,
children: [],
},
{
name: "saveUninitialized",
type: "`boolean`",
description:
'Whether a session that is "uninitialized" is forced to be saved to the store. The default value is `true`.\nRefer to [express-sessions documentation](https://www.npmjs.com/package/express-session#saveUninitialized) for more details.',
optional: true,
defaultValue: "",
expandable: false,
children: [],
},
{
name: "secret",
type: "`string`",
description:
"The secret to sign the session ID cookie. By default, the value of `cookie_secret` is used.\nRefer to [express-sessions documentation](https://www.npmjs.com/package/express-session#secret) for details.",
optional: true,
defaultValue: "",
expandable: false,
children: [],
},
{
name: "ttl",
type: "`number`",
description:
"Used when calculating the `Expires` `Set-Cookie` attribute of cookies. By default, its value is `10 * 60 * 60 * 1000`.\nRefer to [express-sessions documentation](https://www.npmjs.com/package/express-session#cookiemaxage) for details.",
optional: true,
defaultValue: "",
expandable: false,
children: [],
},
]}
sectionTitle="session_options"
/>
### http\_compression
### http_compression
Configure HTTP compression from the application layer. If you have access to the HTTP server, the recommended approach would be to enable it there.
However, some platforms don't offer access to the HTTP layer and in those cases, this is a good alternative.
@@ -511,9 +623,53 @@ module.exports = {
#### Properties
<TypeList types={[{"name":"enabled","type":"`boolean`","description":"Whether HTTP compression is enabled. By default, it's `false`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"level","type":"`number`","description":"The level of zlib compression to apply to responses. A higher level will result in better compression but will take longer to complete.\nA lower level will result in less compression but will be much faster. The default value is `6`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"memLevel","type":"`number`","description":"How much memory should be allocated to the internal compression state. It's an integer in the range of 1 (minimum level) and 9 (maximum level).\nThe default value is `8`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"threshold","type":"`string` \\| `number`","description":"The minimum response body size that compression is applied on. Its value can be the number of bytes or any string accepted by the\n[bytes](https://www.npmjs.com/package/bytes) module. The default value is `1024`.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="http_compression"/>
<TypeList
types={[
{
name: "enabled",
type: "`boolean`",
description:
"Whether HTTP compression is enabled. By default, it's `false`.",
optional: true,
defaultValue: "",
expandable: false,
children: [],
},
{
name: "level",
type: "`number`",
description:
"The level of zlib compression to apply to responses. A higher level will result in better compression but will take longer to complete.\nA lower level will result in less compression but will be much faster. The default value is `6`.",
optional: true,
defaultValue: "",
expandable: false,
children: [],
},
{
name: "memLevel",
type: "`number`",
description:
"How much memory should be allocated to the internal compression state. It's an integer in the range of 1 (minimum level) and 9 (maximum level).\nThe default value is `8`.",
optional: true,
defaultValue: "",
expandable: false,
children: [],
},
{
name: "threshold",
type: "`string` \\| `number`",
description:
"The minimum response body size that compression is applied on. Its value can be the number of bytes or any string accepted by the\n[bytes](https://www.npmjs.com/package/bytes) module. The default value is `1024`.",
optional: true,
defaultValue: "",
expandable: false,
children: [],
},
]}
sectionTitle="http_compression"
/>
### jobs\_batch\_size
### jobs_batch_size
Configure the number of staged jobs that are polled from the database. Default is `1000`.
@@ -522,14 +678,14 @@ Configure the number of staged jobs that are polled from the database. Default i
```js title="medusa-config.js"
module.exports = {
projectConfig: {
jobs_batch_size: 100
jobs_batch_size: 100,
// ...
},
// ...
}
```
### worker\_mode
### worker_mode
Configure the application's worker mode. Default is `shared`.
@@ -544,14 +700,14 @@ Learn more in [this guide](https://docs.medusajs.com/development/medusa-worker).
```js title="medusa-config.js"
module.exports = {
projectConfig: {
worker_mode: "shared"
worker_mode: "shared",
// ...
},
// ...
}
```
___
---
## plugins
@@ -564,8 +720,8 @@ The items in the array can either be:
- A string, which is the name of the plugin to add. You can pass a plugin as a string if it doesnt require any configurations.
- An object having the following properties:
- `resolve`: The name of the plugin.
- `options`: An object that includes the plugins options. These options vary for each plugin, and you should refer to the plugins documentation for available options.
- `resolve`: The name of the plugin.
- `options`: An object that includes the plugins options. These options vary for each plugin, and you should refer to the plugins documentation for available options.
### Example
@@ -576,8 +732,7 @@ module.exports = {
{
resolve: `medusa-my-plugin`,
options: {
apiKey: process.env.MY_API_KEY ||
`test`,
apiKey: process.env.MY_API_KEY || `test`,
},
},
// ...
@@ -586,7 +741,7 @@ module.exports = {
}
```
___
---
## modules
@@ -600,11 +755,11 @@ The keys of the `modules` configuration object refer to the type of module. Its
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 modules 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 cant 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. `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 modules 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 cant 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.
### Example
@@ -627,7 +782,7 @@ module.exports = {
}
```
___
---
## featureFlags