summaryrefslogtreecommitdiff
path: root/packages/backend/src/daemons/janitor.ts
blob: 72568cfe18dc080fd04e67e6af3acf773498f80d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// TODO: 消したい

const interval = 30 * 60 * 1000;
import { AttestationChallenges } from '@/models/index';
import { LessThan } from 'typeorm';

/**
 * Clean up database occasionally
 */
export default function() {
	async function tick() {
		await AttestationChallenges.delete({
			createdAt: LessThan(new Date(new Date().getTime() - 5 * 60 * 1000))
		});
	}

	tick();

	setInterval(tick, interval);
}