Cloudflare Worker that backs the TechnoVIT CMS: event data (D1) and media storage (R2), served behind one HTTP API.
- Serves uploaded images/videos directly from R2 at
/images/*and/videos/*, with HTTP range support for video streaming. - Events API (
/events): list, get, create, update, delete, backed by a D1eventstable. Deleting an event moves its row todeleted_eventsinstead of destroying it, so it can be restored. - Activity Log API (
/activity-logs): every create/update/delete/restore on an event is recorded with the actor who made it and what changed. Deletions can be undone via/activity-logs/:id/undo, which moves the row back fromdeleted_eventsintoevents. - Media API (
/media): list uploaded files, upload a new file (auto-sorted intoimages/photos/orvideos/, key-prefixed with a UUID), delete a file.
- Cloudflare Workers (TypeScript)
- D1 (SQLite) for event data
- R2 for image/video storage
bun install
bun run dev # wrangler dev
bun run deploy # wrangler deploywrangler.toml binds the cms_assets R2 bucket and cms_db D1 database.
Run schema.sql against the D1 database to create the events table.
Schema changes after the initial schema.sql live in migrations/,
applied in order and never re-run. Apply a new one against the remote
database with:
npx wrangler d1 execute technovit-cms-db --remote --file=migrations/0002_add_activity_log_and_deleted_events.sqlDrop --remote to apply it to your local dev database instead.
bun run dev— local dev viawrangler devbun run deploy— deploy to Cloudflarebun run cf-typegen— regenerate Cloudflare binding types