import { isCoolRound } from '../../../shared/cool' import { getCoolVoteTally, resetCoolRound } from '../../utils/cool-votes' interface ResetBody { round?: unknown } export default defineEventHandler(async (event) => { setHeader(event, 'cache-control', 'no-store') const body = await readBody(event) const round = body?.round ?? 'preselection' if (!isCoolRound(round)) { throw createError({ statusCode: 400, statusMessage: 'Invalid round. Expected preselection | final.' }) } const state = resetCoolRound(round) return { state, tally: getCoolVoteTally(round) } })