ff-admin-server/src/service/inviteService.ts
2024-08-25 13:36:19 +02:00

26 lines
802 B
TypeScript

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<invite>}
*/
static async getByMailAndToken(mail: string, token: string): Promise<invite> {
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");
});
}
}