How legspcpd/cloudreve-worker works
Cloudreve-Worker is a Cloudreve v4 backend on Cloudflare Workers, shipped with the official patched frontend. The main workflow is a user request through the Worker and request context into domain routes, file services, storage policies, and database/KV state, with a response back to the client. Separate branches cover authentication, sharing, WebDAV, administration, search, workflows, payments, and audit. The index and excerpts support the runtime wiring shown; broader feature links are documented in the README, while unsampled route internals are represented at their exact paths.
Main entry points: routes API route handlers · app.ts Request context · fs.ts File operations · App.tsx Web application
Components 25
Client
- User / client
Worker runtime
- Worker entry
src/index.ts - Request context
src/middleware/app.ts - Settings provider
src/settings/provider.ts - API route handlers
src/routes
Cloudreve domains
- Sessions and identity
src/routes/session.ts - File operations
src/services/fs.ts - Upload and download
src/services/upload.ts - Sharing and links
src/services/share.ts - WebDAV access
src/routes/dav.ts - Full-text search
src/services/search.ts - Offline workflows
src/services/workflow.ts - Payments and gifts
src/services/payment.ts - Administration
src/routes/admin.ts - Audit events
src/services/audit.ts
State and storage
- Storage driver factory
src/storage/index.ts - Storage providers
src/storage - Data repositories
src/db/repo.ts - Neon Postgres
src/db/index.ts - Database routing
src/db/shard.ts - KV role router
src/lib/kvRouter.ts
Web frontend
- Web application
frontend-patches/src/App.tsx - Frontend API client
frontend-patches/src/api/api.ts - File explorer UI
frontend-patches/src/api/explorer.ts - Admin dashboard UI
frontend-patches/src/api/dashboard.ts
Connections 29
- User / client → Web application: uses
- Web application → Frontend API client: calls
frontend-patches/src/api/api.ts - Frontend API client → Worker entry: requests
- User / client → Worker entry: requests
- Worker entry → Request context: builds context
src/index.ts - Worker entry → API route handlers: dispatches
src/index.ts - Request context → Settings provider: loads
src/middleware/app.ts - Request context → Database routing: resolves database
src/middleware/app.ts - API route handlers → Sessions and identity: routes requests
src/index.ts - API route handlers → File operations: routes requests
src/index.ts - API route handlers → Sharing and links: routes requests
- API route handlers → WebDAV access: routes requests
- API route handlers → Full-text search: routes requests
- API route handlers → Offline workflows: routes requests
- API route handlers → Payments and gifts: routes requests
- API route handlers → Administration: routes requests
- File operations → Upload and download: uses
src/services/fs.ts - File operations → Storage driver factory: selects driver
src/services/fs.ts - Storage driver factory → Storage providers: creates driver
src/storage/index.ts - File operations → Data repositories: reads and writes
src/services/fs.ts - Data repositories → Neon Postgres: executes SQL
src/db/repo.ts - Database routing → Neon Postgres: selects connection
src/db/shard.ts - Request context → KV role router: uses role bindings
src/middleware/app.ts - Data repositories → KV role router: uses cached records
src/db/repo.ts - Administration → Audit events: records events
- File explorer UI → Frontend API client: uses API
frontend-patches/src/api/api.ts - Admin dashboard UI → Frontend API client: uses API
frontend-patches/src/api/api.ts - Web application → File explorer UI: presents files
- Web application → Admin dashboard UI: presents administration