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:
co-authored by
Oli Juhl
parent
e60b4bafe1
commit
82be054a1a
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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:`,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -27,7 +27,7 @@ type Options = {
|
||||
}
|
||||
|
||||
const isWorkerMode = (configModule) => {
|
||||
return configModule.projectConfig.worker_mode === "worker"
|
||||
return configModule.projectConfig.workerMode === "worker"
|
||||
}
|
||||
|
||||
async function subscribersLoader(
|
||||
|
||||
@@ -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),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user