filters + interceptors + guards added to app.module
This commit is contained in:
parent
4dc05ac180
commit
963797c7ae
@ -1,5 +1,5 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { ConfigModule } from '@nestjs/config';
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||||
import { AppController } from './app.controller';
|
import { AppController } from './app.controller';
|
||||||
import { AppService } from './app.service';
|
import { AppService } from './app.service';
|
||||||
|
|
||||||
@ -8,6 +8,12 @@ import databaseConfig from './config/database.config';
|
|||||||
import jwtConfig from './config/jwt.config';
|
import jwtConfig from './config/jwt.config';
|
||||||
import { configValidationSchema } from './config/validation.schema';
|
import { configValidationSchema } from './config/validation.schema';
|
||||||
import { AuthModule } from './routes/auth/auth.module';
|
import { AuthModule } from './routes/auth/auth.module';
|
||||||
|
import { UserModule } from './routes/user/user.module';
|
||||||
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
|
import { AllExceptionsFilter } from './common/filters/all_exceptions.filters';
|
||||||
|
import { APP_FILTER, APP_GUARD, APP_INTERCEPTOR } from '@nestjs/core';
|
||||||
|
import { TransformInterceptor } from './common/interceptors/transform.interceptor';
|
||||||
|
import { RolesGuard } from './common/guards/roles.guard';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
@ -21,9 +27,30 @@ import { AuthModule } from './routes/auth/auth.module';
|
|||||||
isGlobal: true,
|
isGlobal: true,
|
||||||
validationSchema: configValidationSchema,
|
validationSchema: configValidationSchema,
|
||||||
}),
|
}),
|
||||||
|
TypeOrmModule.forRootAsync({
|
||||||
|
imports: [ConfigModule],
|
||||||
|
inject: [ConfigService],
|
||||||
|
useFactory: (config: ConfigService) => ({
|
||||||
|
type: 'postgres',
|
||||||
|
host: config.get('database.host'),
|
||||||
|
port: config.get<number>('database.port'),
|
||||||
|
username: config.get('database.username'),
|
||||||
|
password: config.get('database.password'),
|
||||||
|
database: config.get('database.name'),
|
||||||
|
entities: [__dirname + '/**/*.entity{.ts,.js}'],
|
||||||
|
synchronize: false,
|
||||||
|
migrations: [__dirname + '/migrations/**/*{.ts,.js}'],
|
||||||
|
logging: true,
|
||||||
|
}),
|
||||||
|
}),
|
||||||
AuthModule,
|
AuthModule,
|
||||||
|
UserModule,
|
||||||
],
|
],
|
||||||
controllers: [AppController],
|
controllers: [AppController],
|
||||||
providers: [AppService],
|
providers: [AppService,
|
||||||
|
{ provide: APP_FILTER, useClass: AllExceptionsFilter },
|
||||||
|
{ provide: APP_INTERCEPTOR, useClass: TransformInterceptor },
|
||||||
|
{ provide: APP_GUARD, useClass: RolesGuard }
|
||||||
|
],
|
||||||
})
|
})
|
||||||
export class AppModule {}
|
export class AppModule {}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user