feat: add CampusScope request-level provider for data isolation
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { Module, NestModule, MiddlewareConsumer } from '@nestjs/common';
|
||||
import { APP_GUARD } from '@nestjs/core';
|
||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||
import { EventEmitterModule } from '@nestjs/event-emitter';
|
||||
@@ -54,6 +54,8 @@ import { ClassroomRentalsModule } from './classroom-rentals/classroom-rentals.mo
|
||||
import { SyncModule } from './sync/sync.module';
|
||||
import { NotificationsModule } from './notifications/notifications.module';
|
||||
import { DepartmentsModule } from './departments/departments.module';
|
||||
import { CampusScope } from './common/campus-scope';
|
||||
import { CampusScopeMiddleware } from './common/campus-scope.middleware';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -139,9 +141,14 @@ import { DepartmentsModule } from './departments/departments.module';
|
||||
DepartmentsModule,
|
||||
],
|
||||
providers: [
|
||||
CampusScope,
|
||||
{ provide: APP_GUARD, useClass: ThrottlerGuard },
|
||||
{ provide: APP_GUARD, useClass: JwtAuthGuard },
|
||||
{ provide: APP_GUARD, useClass: PermissionGuard },
|
||||
],
|
||||
})
|
||||
export class AppModule {}
|
||||
export class AppModule implements NestModule {
|
||||
configure(consumer: MiddlewareConsumer) {
|
||||
consumer.apply(CampusScopeMiddleware).forRoutes('*');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user