13 lines
425 B
TypeScript
13 lines
425 B
TypeScript
import { CallHandler, ExecutionContext, Injectable, NestInterceptor } from '@nestjs/common'
|
|
import { Observable } from 'rxjs'
|
|
|
|
@Injectable()
|
|
export class TenantInterceptor implements NestInterceptor {
|
|
intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
|
|
const req = context.switchToHttp().getRequest()
|
|
req.tenantId = req.headers['x-tenant-id'] || 'mock-tenant'
|
|
return next.handle()
|
|
}
|
|
}
|
|
|