26 lines
807 B
TypeScript
26 lines
807 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", err);
|
|
});
|
|
}
|
|
}
|