import { z } from "zod/v4";
import {
	apiProcedure,
	createTRPCRouter,
	publicProcedure,
} from "~/server/api/trpc";
import {
	addEventToQueue,
	processEvents,
} from "~/server/controllers/event_queue.controller";
import { zEventDataTypes } from "~/server/utils/zod_types";

export const eventQueueRouter = createTRPCRouter({
	addEvent: publicProcedure
		.input(
			z.object({
				data: zEventDataTypes,
				lock_expires: z.date(),
			}),
		)
		.mutation(async ({ input }) => {
			return await addEventToQueue(input);
		}),
	processEvents: apiProcedure.query(async () => {
		return await processEvents();
	}),
});
