// 共享配置；环境相关变量放在 config.development.js / config.production.js

const env = process.env.NODE_ENV || "development";

let env_config = {};
try {
  if (env === "production") {
    env_config = require("./config.production.js");
  } else {
    env_config = require("./config.development.js");
  }
} catch (error) {
  console.warn(`Warning: failed to load ${env} config, using defaults.`);
}

const base_config = {
  port: {
    node: 9098,
    web: 9090,
  },
  allowUrls: [
    "/admin_api/sys_user/login",
    "/admin_api/sys_user/authorityMenus",
    "/admin_api/sys_user/register",
    "/file/",
    "/sys_file/",
    "/api/docs",
    "/api/swagger.json",
  ],
};

module.exports = {
  ...base_config,
  ...env_config,
  wechat: {
    ...(base_config.wechat || {}),
    ...(env_config.wechat || {}),
  },
};

console.log(`Config env: ${env}`);
