Create polls with an optional closing time, let each user cast one vote they can change while the poll is open, and count the results.
30 minute budget0.0% acceptanceCRUD · voting · time
Requirements
01POST /polls takes { question, options, closesAt? } and returns 201 with the poll; each option gets an id. Invalid input is a 400 with { error }.
02POST /polls/:id/votes { optionId } records the vote of the user named in the x-user header: 201 for a first vote, 200 when it replaces that user's earlier vote. A missing x-user is a 401, an unknown optionId a 400, an unknown poll a 404.
03Each user has one vote per poll and may change it while the poll is open; a poll with no closesAt stays open.
04GET /polls/:id/results returns { pollId, closed, totalVotes, options: [{ id, text, votes }], winners } with every option in creation order.
05Time comes from the x-now header (ISO date) when present, otherwise the real clock.
What the hidden tests check
Everything the interviewer tells you is checked.
Each test creates its own polls and controls the clock with x-now.
4 more details are held back. In a mock interview they come out only when you ask the interviewer the right question; in practice they are listed in the workspace.