feat: commit
This commit is contained in:
+31
-15
@@ -3,32 +3,48 @@ import { AppController } from './app.controller';
|
||||
import { AppService } from './app.service';
|
||||
import { UserEntity } from './user/entities/user.entity';
|
||||
import { BannerEntity } from './banner/entities/banner.entity';
|
||||
import { AuthEntity } from './auth/entities/auth.entity';
|
||||
import { UserModule } from './user/user.module';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { TypeOrmModule, TypeOrmModuleOptions } from '@nestjs/typeorm';
|
||||
import { BannerModule } from './banner/banner.module';
|
||||
import { OssModule } from './oss/oss.module';
|
||||
import { SysUserModule } from './sys-user/sys-user.module';
|
||||
import { AuthModule } from './auth/auth.module';
|
||||
import { APP_GUARD } from '@nestjs/core';
|
||||
import { jwtAuthGuard } from './jwt/jwt-auth.grard';
|
||||
import { getConfig } from 'config/configuration';
|
||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||
|
||||
const ENTITIES = [UserEntity, BannerEntity];
|
||||
const ENTITIES = [UserEntity, BannerEntity, AuthEntity];
|
||||
|
||||
const MODULE = [UserModule, BannerModule, OssModule];
|
||||
const MODULE = [UserModule, BannerModule, OssModule, AuthModule];
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
TypeOrmModule.forRoot({
|
||||
type: 'mysql',
|
||||
host: 'localhost',
|
||||
port: 3306,
|
||||
username: 'root',
|
||||
password: '123456',
|
||||
database: 'travel-app',
|
||||
entities: ENTITIES, // 这里添加实体类
|
||||
synchronize: true,
|
||||
ConfigModule.forRoot({
|
||||
cache: true,
|
||||
load: [getConfig],
|
||||
isGlobal: true,
|
||||
}),
|
||||
TypeOrmModule.forRootAsync({
|
||||
imports: [ConfigModule],
|
||||
inject: [ConfigService],
|
||||
useFactory: (config: ConfigService) => {
|
||||
return {
|
||||
type: 'mysql',
|
||||
entities: ENTITIES,
|
||||
...config.get('db.mysql'),
|
||||
} as TypeOrmModuleOptions;
|
||||
},
|
||||
}),
|
||||
...MODULE,
|
||||
SysUserModule,
|
||||
],
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
providers: [
|
||||
AppService,
|
||||
{
|
||||
provide: APP_GUARD,
|
||||
useClass: jwtAuthGuard,
|
||||
},
|
||||
],
|
||||
})
|
||||
export class AppModule {}
|
||||
|
||||
Reference in New Issue
Block a user