firefish/packages/backend/src/daemons/janitor.ts
naskya 30619301d3
chore: replace new Date().getTime() with Date.now()
959cc8ff37

Co-authored-by: zyoshoka <107108195+zyoshoka@users.noreply.github.com>
2024-04-08 17:00:41 +09:00

21 lines
401 B
TypeScript

// TODO: 消したい
const interval = 30 * 60 * 1000;
import { AttestationChallenges } from "@/models/index.js";
import { LessThan } from "typeorm";
/**
* Clean up database occasionally
*/
export default function () {
async function tick() {
await AttestationChallenges.delete({
createdAt: LessThan(new Date(Date.now() - 5 * 60 * 1000)),
});
}
tick();
setInterval(tick, interval);
}