medusa-config.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. const dotenv = require("dotenv");
  2. let ENV_FILE_NAME = "";
  3. switch (process.env.NODE_ENV) {
  4. case "production":
  5. ENV_FILE_NAME = ".env.production";
  6. break;
  7. case "staging":
  8. ENV_FILE_NAME = ".env.staging";
  9. break;
  10. case "test":
  11. ENV_FILE_NAME = ".env.test";
  12. break;
  13. case "development":
  14. default:
  15. ENV_FILE_NAME = ".env";
  16. break;
  17. }
  18. try {
  19. dotenv.config({ path: process.cwd() + "/" + ENV_FILE_NAME });
  20. } catch (e) {}
  21. // CORS when consuming Medusa from admin
  22. const ADMIN_CORS =
  23. process.env.ADMIN_CORS || "http://localhost:7000,http://localhost:7001";
  24. // CORS to avoid issues when consuming Medusa from a client
  25. const STORE_CORS = process.env.STORE_CORS || "http://localhost:8000";
  26. const DATABASE_URL =
  27. process.env.DATABASE_URL || "postgres://localhost/medusa-db";
  28. const REDIS_URL = process.env.REDIS_URL || "redis://localhost:6379";
  29. const plugins = [
  30. `medusa-fulfillment-manual`,
  31. `medusa-payment-manual`,
  32. `@medusajs/file-local`,
  33. // To enable the admin plugin, uncomment the following lines and run `yarn add @medusajs/admin`
  34. // {
  35. // resolve: "@medusajs/admin",
  36. // /** @type {import('@medusajs/admin').PluginOptions} */
  37. // options: {
  38. // autoRebuild: true,
  39. // },
  40. // },
  41. ];
  42. const modules = {
  43. /*eventBus: {
  44. resolve: "@medusajs/event-bus-redis",
  45. options: {
  46. redisUrl: REDIS_URL
  47. }
  48. },
  49. cacheService: {
  50. resolve: "@medusajs/cache-redis",
  51. options: {
  52. redisUrl: REDIS_URL
  53. }
  54. },*/
  55. };
  56. /** @type {import('@medusajs/medusa').ConfigModule["projectConfig"]} */
  57. const projectConfig = {
  58. jwtSecret: process.env.JWT_SECRET,
  59. cookieSecret: process.env.COOKIE_SECRET,
  60. store_cors: STORE_CORS,
  61. database_url: DATABASE_URL,
  62. admin_cors: ADMIN_CORS,
  63. // Uncomment the following lines to enable REDIS
  64. // redis_url: REDIS_URL
  65. };
  66. /** @type {import('@medusajs/medusa').ConfigModule} */
  67. module.exports = {
  68. projectConfig,
  69. plugins,
  70. modules,
  71. };