medusa-config.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. }
  22. // CORS when consuming Medusa from admin
  23. const ADMIN_CORS = 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. // Database URL (here we use a local database called medusa-development)
  27. const DATABASE_URL =
  28. process.env.DATABASE_URL || "postgres://localhost/medusa-store";
  29. // Medusa uses Redis, so this needs configuration as well
  30. const REDIS_URL = process.env.REDIS_URL || "redis://localhost:6379";
  31. // Stripe keys
  32. const STRIPE_API_KEY = process.env.STRIPE_API_KEY || "";
  33. const STRIPE_WEBHOOK_SECRET = process.env.STRIPE_WEBHOOK_SECRET || "";
  34. // This is the place to include plugins. See API documentation for a thorough guide on plugins.
  35. const plugins = [
  36. `medusa-fulfillment-manual`,
  37. `medusa-payment-manual`,
  38. // Uncomment to add Stripe support.
  39. // You can create a Stripe account via: https://stripe.com
  40. // {
  41. // resolve: `medusa-payment-stripe`,
  42. // options: {
  43. // api_key: STRIPE_API_KEY,
  44. // webhook_secret: STRIPE_WEBHOOK_SECRET,
  45. // },
  46. // },
  47. ];
  48. module.exports = {
  49. projectConfig: {
  50. // redis_url: REDIS_URL,
  51. // For more production-like environment install PostgresQL
  52. // database_url: DATABASE_URL,
  53. // database_type: "postgres",
  54. database_database: "./medusa-db.sql",
  55. database_type: "sqlite",
  56. store_cors: STORE_CORS,
  57. admin_cors: ADMIN_CORS,
  58. },
  59. plugins,
  60. };