Skip to content

jiayx/edge-drop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

edge-drop

Anonymous temporary room chat and file drop built with Vite, Cloudflare Workers, Durable Objects, and R2.

Features

  • 6-digit temporary rooms
  • Real-time room presence and chat over WebSocket
  • File upload and download through the Worker
  • Image, audio, and video previews
  • Room expiry and room extension
  • Desktop and mobile room presence UI
  • Dark, light, and system theme support
  • Local slash commands:
    • /name <new name>
    • /theme
    • /help

Stack

  • Vite
  • TypeScript
  • Hono
  • Cloudflare Workers
  • Durable Objects
  • R2

Project Structure

  • src/views/*: page HTML rendering
  • src/client/*: frontend behavior
  • src/app.css: app styles
  • src/index.ts: Worker entry
  • src/routes/*: HTTP and page routes
  • src/room/durable/*: room state Durable Objects

Requirements

  • Node.js 20+
  • pnpm
  • Wrangler 4
  • A Cloudflare account with:
    • one R2 bucket
    • Durable Objects enabled
    • a Rate Limiting binding

Install

pnpm install

Local Development

pnpm dev

The app runs on http://localhost:5173.

Build

pnpm build

Deploy

pnpm run deploy

The deploy script reads .env.prod by default. Values in .env.prod override [vars] in wrangler.toml.

You can also override the env file:

pnpm run deploy -- .env.staging

To bypass the sync step and run Wrangler directly:

pnpm run deploy:raw

Configuration

Main config lives in wrangler.toml.

Current bindings and vars:

  • Durable Objects: ROOMS, ROOM_INDEX
  • Rate limit: ROOM_JOIN_RATE_LIMIT
  • Default vars in wrangler.toml: MAX_FILE_SIZE_MB, ROOM_TTL_HOURS, BLOCKED_MIME_TYPES
  • Required deploy vars from .env.prod unless you also hardcode them into wrangler.toml: ADMIN_AUTH_TOKEN, R2_ACCOUNT_ID, R2_BUCKET_NAME, R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY

You should update at least:

  • rate limit namespace
  • ADMIN_AUTH_TOKEN
  • R2_ACCOUNT_ID
  • R2_BUCKET_NAME
  • R2_ACCESS_KEY_ID
  • R2_SECRET_ACCESS_KEY

Stats Endpoint

Internal stats endpoint:

GET /api/v1/admin/stats
X-Admin-Token: <token>

Example:

curl -s http://127.0.0.1:5173/api/v1/admin/stats \
  -H 'X-Admin-Token: your_token'

Room Flow

  1. Create a room with POST /api/v1/rooms
  2. Open /room/<roomKey>
  3. Join via POST /api/v1/rooms/:key/join
  4. Chat and upload files
  5. Extend room lifetime with POST /api/v1/rooms/:key/extend

Notes

  • Files are stored in R2 under rooms/<roomKey>/...
  • Uploads are direct-to-R2 via presigned PUT URLs generated by the Worker
  • Downloads are proxied by the Worker through the R2 S3 API instead of exposing R2 directly
  • Room metadata and presence are stored in Durable Objects
  • Expired rooms are cleaned up by the scheduled cleanup job through the R2 S3 API
  • Your R2 bucket must allow browser CORS for direct uploads. At minimum, allow:
    • origin: your site origin
    • methods: PUT
    • headers: content-type, content-disposition, x-amz-meta-originalfilename

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors