import { SetMetadata } from '@nestjs/common';
import { MAIN_MENU, UNPROTECTED_URL } from '../../constants';

/**
 * @deprecated
 * Use Public instead
 * This decorator will exclude the request from token check
 *
 * NOTE:
 * Because the request does'nt provide token,
 * the side effect are, function can't access `UserProvider`
 * or `UserProvider` will return null
 */
export const Unprotected = (isUnprotected = true) =>
  SetMetadata(UNPROTECTED_URL, isUnprotected);

export const Public = (isUnprotected = true) =>
  SetMetadata(UNPROTECTED_URL, isUnprotected);

export const MainMenu = () => SetMetadata(MAIN_MENU, true);
export const ExcludePrivilege = () => SetMetadata(MAIN_MENU, true);
