LocChat/server/app.module.ts

29 lines
1.1 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';
2022-03-08 20:18:38 -05:00
import { PingGateway } from './providers/gateways/ping.gateway';
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: [
2022-03-08 20:18:38 -05:00
PingGateway,
2021-12-01 22:18:26 -05:00
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 {}