clean up expiring auth tickets

This commit is contained in:
Julian 2023-04-25 20:03:36 -04:00
parent 2756694ac6
commit e01278e050
Signed by untrusted user: NotNite
GPG key ID: BD91A5402CCEB08A

View file

@ -43,8 +43,27 @@ async function refreshDiscordTokens() {
}
}
async function expireTickets() {
const expired = await prisma.authTicket.findMany({
where: {
expiresAt: {
lte: new Date()
}
}
});
for (const ticket of expired) {
await prisma.authTicket.delete({
where: {
id: ticket.id
}
});
}
}
setInterval(async () => {
await refreshDiscordTokens();
await expireTickets();
}, 60 * 1000);
export default prisma;