diff options
| author | ertopogo <erwin.t.pombett@gmail.com> | 2026-01-18 20:32:59 +0100 |
|---|---|---|
| committer | ertopogo <erwin.t.pombett@gmail.com> | 2026-01-18 20:32:59 +0100 |
| commit | 09a949092c59856962e4a7d132bc5a5e76fe5e55 (patch) | |
| tree | 990d6b8f24ff9c6dbc0fcb15b5512067d09b17fd /backend/medusa-config.js | |
Initial commit: Medusa Backend + storefront + config
Diffstat (limited to 'backend/medusa-config.js')
| -rw-r--r-- | backend/medusa-config.js | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/backend/medusa-config.js b/backend/medusa-config.js new file mode 100644 index 0000000..739a553 --- /dev/null +++ b/backend/medusa-config.js @@ -0,0 +1,103 @@ +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) {}
+
+// 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";
+
+const DATABASE_URL =
+ process.env.DATABASE_URL || "postgres://localhost/medusa-store";
+
+const REDIS_URL = process.env.REDIS_URL || "redis://localhost:6379";
+
+const plugins = [
+ `medusa-fulfillment-manual`,
+ `medusa-payment-manual`,
+ {
+ resolve: `@medusajs/file-local`,
+ options: {
+ upload_dir: "uploads",
+ },
+ },
+ {
+ resolve: "@medusajs/admin",
+ /** @type {import('@medusajs/admin').PluginOptions} */
+ options: {
+ autoRebuild: true,
+ develop: {
+ open: false,
+ },
+ },
+ },
+ // Example for Stripe (uncomment and configure in .env)
+ // {
+ // resolve: `medusa-payment-stripe`,
+ // options: {
+ // api_key: process.env.STRIPE_API_KEY,
+ // webhook_secret: process.env.STRIPE_WEBHOOK_SECRET,
+ // },
+ // },
+];
+
+const modules = {
+ /*
+ * Enable the Redis event bus to sync events
+ */
+ eventBus: {
+ resolve: "@medusajs/event-bus-redis",
+ options: {
+ redisUrl: REDIS_URL
+ }
+ },
+ /*
+ * Enable Redis cache
+ */
+ cacheService: {
+ resolve: "@medusajs/cache-redis",
+ options: {
+ redisUrl: REDIS_URL
+ }
+ },
+};
+
+/** @type {import('@medusajs/medusa').ConfigModule["projectConfig"]} */
+const projectConfig = {
+ jwtSecret: process.env.JWT_SECRET,
+ cookieSecret: process.env.COOKIE_SECRET,
+ store_cors: STORE_CORS,
+ database_url: DATABASE_URL,
+ admin_cors: ADMIN_CORS,
+ // Uncomment the following lines to enable REDIS
+ redis_url: REDIS_URL
+};
+
+/** @type {import('@medusajs/medusa').ConfigModule} */
+module.exports = {
+ projectConfig,
+ plugins,
+ modules,
+};
+
|
