add config module
This commit is contained in:
@@ -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'),
|
||||
},
|
||||
],
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user