import { dataSource } from "../data-source"; import { invite } from "../entity/invite"; import InternalException from "../exceptions/internalException"; export default abstract class InviteService { /** * @description get invite by id * @param mail string * @param token string * @returns {Promise} */ static async getByMailAndToken(mail: string, token: string): Promise { return await dataSource .getRepository(invite) .createQueryBuilder("invite") .where("invite.mail = :mail", { mail: mail }) .andWhere("invite.token = :token", { token: token }) .getOneOrFail() .then((res) => { return res; }) .catch((err) => { throw new InternalException("invite not found by mail and token"); }); } }