-
Notifications
You must be signed in to change notification settings - Fork 0
/
medusa-config.js
100 lines (90 loc) · 1.84 KB
/
medusa-config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
const dotenv = require("dotenv");
let ENV_FILE_NAME = "";
switch (process.env.NODE_ENV) {
case "production":
ENV_FILE_NAME = ".env.production";
break;
case "staging":
ENV_FILE_NAME = ".env.staging";
break;
case "test":
ENV_FILE_NAME = ".env.test";
break;
case "development":
default:
ENV_FILE_NAME = ".env";
break;
}
try {
dotenv.config({
path:
process.cwd() +
"/" +
ENV_FILE_NAME,
});
} catch (e) {
console.error(
"No environment file found, using .env: " +
e
);
}
// 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:3000,http://localhost:8000";
const DATABASE_TYPE =
process.env.DATABASE_TYPE || "sqlite";
const DATABASE_URL =
process.env.DATABASE_URL ||
"postgres://localhost/medusa-store";
const REDIS_URL =
process.env.REDIS_URL ||
"redis://localhost:6379";
const plugins = [
{
resolve: "@medusajs/admin",
/** @type {import('@medusajs/admin').PluginOptions} */
},
];
const modules = {};
/** @type {import('@medusajs/medusa').ConfigModule["projectConfig"]} */
const projectConfig = {
jwtSecret: process.env.JWT_SECRET,
cookieSecret:
process.env.COOKIE_SECRET,
database_database: "./medusa-db.sql",
database_type: DATABASE_TYPE,
store_cors: STORE_CORS,
admin_cors: ADMIN_CORS,
redis_url: REDIS_URL,
database_extra:
// process.env.NODE_ENV !==
// "dvelopment"
// ?
{
ssl: {
rejectUnauthorized: false,
},
},
// : {},
};
if (
DATABASE_URL &&
DATABASE_TYPE === "postgres"
) {
projectConfig.database_url =
DATABASE_URL;
delete projectConfig[
"database_database"
];
}
/** @type {import('@medusajs/medusa').ConfigModule} */
module.exports = {
projectConfig,
plugins,
modules,
};