ff-admin-server/src/service/inviteService.ts

27 lines
807 B
TypeScript
Raw Normal View History

2024-08-25 11:36:19 +00:00
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) => {
2024-09-06 08:08:19 +00:00
throw new InternalException("invite not found by mail and token", err);
2024-08-25 11:36:19 +00:00
});
}
}