When responding to a Public route, I want to ensure that my users' emails are not exposed. However, I still need to access them from other routes that utilize a bearer JWT authentication system. This is the type of code I am looking to implement:
@Column()
@Exclude()
password: string;
@Column({ unique: true })
@ExcludeIfPublic()
email: string;
Below is the Public decorator I am using:
import { SetMetadata } from '@nestjs/common';
export const IS_PUBLIC_KEY = 'isPublic';
export const Public = () => SetMetadata(IS_PUBLIC_KEY, true);