Menu

Sealing notes until their day: a no-login Advent calendar on Cloudflare Workers and D1
📰

Sealing notes until their day: a no-login Advent calendar on Cloudflare Workers and D1

DEV Community: nextjs·秀秀·about 7 hours ago
#zGAUCIRR
#devtonextjs#devto#dev#door#calendar
Long article (961 words) — no AI summary yet.
Reading 0:00
15s threshold

I built Advent With Friends , a small site where you make a 24-door Advent calendar, send one link to your friends, and they leave short notes behind the doors. You open one door a day until December 24.

It has no accounts, and that one decision shaped most of the engineering. Here are the five problems that took the most thought, with the code that solved them. The stack is Next.js on Cloudflare Workers (through OpenNext) with a D1 database.

1. A note must not reach the browser before its day

The whole point of the calendar is that the owner cannot peek. Hiding the text with CSS, or sending it and trusting the client not to show it, would make every note one "view source" away.

So the server decides, for every request, whether a note's text is part of the response at all:

const today = localDate ( unlockNow , calendar . time_zone ) ; // ...for each door: const unlocked = doorDate ( number ) <= today ; if ( own || ( owner && unlocked ) ) note . body = row .…

Continue reading — create a free account

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