Menu

Keeping a daily word game's answers off the client with Cloudflare Workers and D1
📰

Keeping a daily word game's answers off the client with Cloudflare Workers and D1

DEV Community: javascript·Keiko's Words·18 days ago
#SFf4X7ca
#devtojavascript#devto#dev#word#answer
Reading 0:00
15s threshold

I build Keiko's Words , a free daily word game: three secret words a day, each guessed from up to five one-word clues that start abstract and get easier with every miss. This post covers three implementation choices that keep it fair: the answers never reach the browser, guesses are de-duplicated without storing them, and typos are forgiven without letting near-miss words win.

1. The browser never gets the answer

Many daily games ship the whole answer list in a JS bundle. Here the puzzle bank lives in a D1 table, and the Worker only returns what the player has earned: the clues revealed so far, and the answer once a word is finished.

export function publicProgress ( record , content ) { const state = typeof record . state === ' string ' ? JSON . parse ( record . state ) : record . state ; return { revision : record . revision , rounds : state . rounds . map (( round , index ) => ({ revealed : round . revealed , status : round . status , attempts : round . attempts , clues : content [ index ]. clues .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.