import { createParamDecorator , ExecutionContext } from '@nestjs/common' ; import { UserModel } from '../profile/user.entity' ; export const User = createParamDecorator < string [ ] > ( async ( relations , ctx ) => { const request = ctx . switchToHttp ( ) . getRequest ( ) ; return await UserModel . findOne ( request . user . userId , { relations } ) ; } ) ; export const UserId = createParamDecorator ( ( data , ctx ) => { const request = ctx . switchToHttp ( ) . getRequest ( ) ; return Number ( request . user . userId ) ; } ) ;