LocChat/server/app.module.ts

27 lines
1.0 KiB
TypeScript
Raw Normal View History

2021-11-16 21:14:46 -05:00
import { Module } from '@nestjs/common';
2021-12-01 22:18:26 -05:00
import { APP_GUARD } from '@nestjs/core';
2021-11-16 21:14:46 -05:00
import { TypeOrmModule } from '@nestjs/typeorm';
import { AppController } from './app.controller';
import { config } from './database/config';
import { UsersModule } from './modules/users.module';
2021-12-01 22:18:26 -05:00
import { AuthGuard } from './providers/guards/auth.guard';
import { RolesGuard } from './providers/guards/roles.guard';
2021-11-23 16:04:12 -05:00
import { JwtService } from './providers/services/jwt.service';
2021-12-01 22:18:26 -05:00
import { RolesService } from './providers/services/roles.service';
import { UsersService } from './providers/services/users.service';
2021-12-03 16:46:44 -05:00
import { GuardUtil } from './providers/util/guard.util';
2021-11-16 21:14:46 -05:00
@Module({
imports: [TypeOrmModule.forRoot(config), UsersModule],
controllers: [AppController],
2021-12-01 22:18:26 -05:00
providers: [
UsersService,
RolesService,
JwtService,
2021-12-03 16:46:44 -05:00
GuardUtil,
2021-12-01 22:18:26 -05:00
{ provide: APP_GUARD, useClass: AuthGuard }, // auth guard should come before roles guard
{ provide: APP_GUARD, useClass: RolesGuard }, // otherwise users won't be authenticated before roles check
],
2021-11-16 21:14:46 -05:00
})
export class AppModule {}