import { HttpException } from '@nestjs/common'; export function requireFound(v: T | undefined, message?: string): T; export function requireFound(v: Promise, message?: string): Promise; export function requireFound(v: T | undefined | Promise, message?: string): T | Promise { if (v instanceof Promise) { return v.then((v) => requireFound(v)); } if (v === undefined || v === null) { throw new HttpException(message || 'Not Found', 404); } return v; }