server/tasks/cleanup.task.ts
Scheduled Task
Example
Run a scheduled task with a six-field cron expression.
export const config = {
active: false,
cron: "0 0 3 * * *",
};
export default async () => {
const removed = await db.session.deleteMany({
where: { expiresAt: { lt: now() } },
});
return { removed: removed.count };
};