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';
|
2022-03-30 17:18:16 -04:00
|
|
|
import { ChatRoomModule } from './modules/chat_room.module';
|
2021-11-16 21:14:46 -05:00
|
|
|
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';
|
2022-03-30 17:18:16 -04:00
|
|
|
import { ChatRoomService } from './providers/services/chat_room.service';
|
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({
|
2022-03-30 17:18:16 -04:00
|
|
|
imports: [TypeOrmModule.forRoot(config), UsersModule, ChatRoomModule],
|
2021-11-16 21:14:46 -05:00
|
|
|
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,
|
2022-03-30 17:18:16 -04:00
|
|
|
ChatRoomService,
|
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 {}
|