feat: add CampusScope request-level provider for data isolation
This commit is contained in:
13
apps/server/src/common/campus-scope.middleware.ts
Normal file
13
apps/server/src/common/campus-scope.middleware.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { Injectable, NestMiddleware } from '@nestjs/common';
|
||||
import { Request, Response, NextFunction } from 'express';
|
||||
import { CampusScope, CampusRequest } from './campus-scope';
|
||||
|
||||
@Injectable()
|
||||
export class CampusScopeMiddleware implements NestMiddleware {
|
||||
constructor(private readonly scope: CampusScope) {}
|
||||
|
||||
use(req: Request, _res: Response, next: NextFunction): void {
|
||||
(req as CampusRequest).campusScope = this.scope;
|
||||
next();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user