123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- 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 DB_USERNAME = process.env.DB_USERNAME;
- const DB_PASSWORD = process.env.DB_PASSWORD;
- const DB_HOST = process.env.DB_HOST;
- const DB_PORT = process.env.DB_PORT;
- const DB_DATABASE = process.env.DB_DATABASE;
- const DATABASE_URL = `postgres://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_DATABASE}`;
- // Medusa uses Redis, so this needs configuration as well
- const REDIS_URL = process.env.REDIS_URL || "redis://localhost:6379";
- // Stripe keys
- const STRIPE_API_KEY = process.env.STRIPE_API_KEY || "";
- const STRIPE_WEBHOOK_SECRET = process.env.STRIPE_WEBHOOK_SECRET || "";
- // This is the place to include plugins. See API documentation for a thorough guide on plugins.
- const plugins = [
- `medusa-fulfillment-manual`,
- `medusa-payment-manual`,
- // Uncomment to add Stripe support.
- // You can create a Stripe account via: https://stripe.com
- // {
- // resolve: `medusa-payment-stripe`,
- // options: {
- // api_key: STRIPE_API_KEY,
- // webhook_secret: STRIPE_WEBHOOK_SECRET,
- // },
- // },
- ];
- module.exports = {
- projectConfig: {
- redis_url: REDIS_URL,
- // For more production-like environment install PostgresQL
- database_url: DATABASE_URL,
- database_type: "postgres",
- store_cors: STORE_CORS,
- admin_cors: ADMIN_CORS,
- database_extra: { ssl: { rejectUnauthorized: false } }
- },
- plugins,
- };
|