GiftDoor is a Cloudflare-first, SvelteKit-powered digital advent calendar. Each day unlocks a private surpriseโmessages, media, or gift codesโdelivered fast at the edge.
This repository now includes ready-to-run examples for Cloudflare D1 (SQLite) and R2 (S3-compatible storage).
Install dependencies (already run if you used the CLI):
npm install
Create or point to your Cloudflare resources, then update wrangler.toml with their IDs/names:
```toml
[[d1_databases]]
binding = "DB"
database_name = "giftdoor-db"
database_id = "
[[r2_buckets]] binding = "BUCKET" bucket_name = "giftdoor-media" preview_bucket_name = "giftdoor-media-dev"
3) Run locally:
```sh
# Cloudflare runtime with Miniflare (needed to hit D1/R2)
wrangler dev --persist
# App will be served on http://127.0.0.1:8787
# Or fast Vite dev without bindings
npm run dev -- --open
src/routes/api/d1/+server.ts)GET /api/d1 โ creates a gifts table if needed and returns the 10 most recent rows.POST /api/d1 โ insert a gift row: { "title": "Day 1 surprise", "note": "A warm hello", "day": 1 }
You can hit these from the homepage UI or with curl:
curl -X POST http://localhost:5173/api/d1 \
-H "content-type: application/json" \
-d '{"title":"GiftDoor hello","day":1,"note":"stored in D1"}'
src/routes/api/r2/+server.ts)POST /api/r2 โ stores a text object at demos/<filename>.txt.GET /api/r2 โ lists objects in the demos/ prefix.GET /api/r2?key=demos/<filename>.txt โ fetches a specific object.Example upload:
curl -X POST http://localhost:5173/api/r2 \
-H "content-type: application/json" \
-d '{"filename":"first-note","content":"hello from GiftDoor"}'
src/routes/+page.svelte โ landing page with interactive D1/R2 testers.src/routes/api/d1/+server.ts โ Cloudflare D1 read/write demo with automatic table creation.src/routes/api/r2/+server.ts โ Cloudflare R2 upload/list demo.wrangler.toml โ bindings for DB (D1) and BUCKET (R2).svelte.config.js โ uses @sveltejs/adapter-cloudflare.GiftDoor allows a gifter to build a digital advent calendar by filling each of the 25 days with personalised digital gifts. A recipient receives a private link and can open one door per day, unlocking automatically by date.
Itโs designed for:
MIT โ free to use, modify, and distribute with attribution.