add config module

This commit is contained in:
2025-06-08 14:26:04 +08:00
parent 88ba3f5a16
commit e5912600ce
27 changed files with 383 additions and 161 deletions
+16 -14
View File
@@ -1,15 +1,17 @@
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
import { toNumber } from 'lodash';
export const database = (): TypeOrmModuleOptions => ({
charset: 'utf8mb4',
logging: ['error'],
type: 'mysql',
host: '192.168.50.26',
port: 3306,
username: '3r',
password: '12345678',
database: '3r',
synchronize: true,
autoLoadEntities: true,
timezone: '+08:00',
});
import { createDBConfig } from '@/modules/database/config';
export const database = createDBConfig((configure) => ({
common: { synchronize: true },
connections: [
{
type: 'mysql',
host: configure.env.get('DB_HOST', '127.0.0.1'),
port: configure.env.get<number>('DB_PORT', (v) => toNumber(v), 3306),
username: configure.env.get('DB_USERNAME', 'root'),
password: configure.env.get('DB_PASSWORD', '12345678'),
database: configure.env.get('DB_NAME', '3r'),
},
],
}));