rudeshark.net/packages/backend/src/daemons/janitor.ts

21 lines
411 B
TypeScript
Raw Normal View History

2021-03-21 09:38:09 +01:00
// TODO: 消したい
const interval = 30 * 60 * 1000;
2023-01-13 05:40:33 +01:00
import { AttestationChallenges } from "@/models/index.js";
import { LessThan } from "typeorm";
/**
* Clean up database occasionally
*/
2023-01-13 05:40:33 +01:00
export default function () {
async function tick() {
await AttestationChallenges.delete({
2021-12-09 15:58:30 +01:00
createdAt: LessThan(new Date(new Date().getTime() - 5 * 60 * 1000)),
});
}
tick();
setInterval(tick, interval);
}