feat: add entity and swagger
This commit is contained in:
1 parent
0416c356b8
commit
346742b157
12 files changed
+652
-66
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import { Global, Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule.forRoot({
|
||||
isGlobal: true,
|
||||
envFilePath: [
|
||||
'.env', // 通用配置,最低优先级
|
||||
`.env.${process.env.NODE_ENV}`, // 环境配置,如 .env.development
|
||||
`.env.${process.env.NODE_ENV}.local`, // 本地配置,最高优先级
|
||||
],
|
||||
}),
|
||||
TypeOrmModule.forRootAsync({
|
||||
useFactory: async (configService: ConfigService) => ({
|
||||
type: 'mysql',
|
||||
host: configService.get<string>('DB_HOST'),
|
||||
port: configService.get<number>('DB_PORT'),
|
||||
username: configService.get<string>('DB_USERNAME'),
|
||||
password: configService.get<string>('DB_PASSWORD'),
|
||||
database: configService.get<string>('DB_NAME'),
|
||||
autoLoadEntities: true,
|
||||
synchronize: process.env.NODE_ENV === 'development',
|
||||
}),
|
||||
inject: [ConfigService],
|
||||
}),
|
||||
],
|
||||
})
|
||||
@Global()
|
||||
export class CoreModule {}
|
||||
Reference in new issue
Block a user