import { runSendReminders } from "@kk/api/routers/index";
import {
	createStartHandler,
	defaultStreamHandler,
} from "@tanstack/react-start/server";

const fetch = createStartHandler(defaultStreamHandler);

export default {
	fetch,
	async scheduled(
		_event: { cron: string; scheduledTime: number },
		_env: Record<string, unknown>,
		ctx: { waitUntil: (promise: Promise<unknown>) => void },
	) {
		ctx.waitUntil(runSendReminders());
	},
};
