import { CoolConfig } from '@cool-midway/core';
import { MidwayConfig } from '@midwayjs/core';
import { entities } from '../entities';
import { TenantSubscriber } from '../modules/base/db/tenant';

const external = (global as any).__GPU_GUARD_EXTERNAL_CONFIG__;

export default {
  typeorm: {
    dataSource: {
      default: {
        type: external?.database?.type ?? 'mysql',
        host: external?.database?.host ?? '',
        port: external?.database?.port ?? 3306,
        username: external?.database?.username ?? '',
        password: external?.database?.password ?? '',
        database: external?.database?.database ?? '',
        synchronize: false,
        logging: false,
        charset: 'utf8mb4',
        cache: true,
        entities,
        subscribers: [TenantSubscriber],
      },
    },
  },
  cool: {
    eps: false,
    initDB: false,
    initJudge: 'db',
    initMenu: false,
  } as CoolConfig,
} as MidwayConfig;
