import type { CallHandler , ExecutionContext , NestInterceptor , } from '@nestjs/common' ; import { Injectable } from '@nestjs/common' ; import type { UserEntity } from '../modules/user/user.entity' ; import { ContextProvider } from '../providers' ; @ Injectable ( ) export class AuthUserInterceptor implements NestInterceptor { intercept ( context , next ) { const request = context . switchToHttp ( ) . getRequest ( ) ; const user = < UserEntity > request . user ; ContextProvider . setAuthUser ( user ) ; return next . handle ( ) ; } }