Rust file-hosting CDN API
- TypeScript 42.8%
- Rust 34.7%
- CSS 19.1%
- Dockerfile 1.3%
- HTML 1.2%
- Other 0.9%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| .forgejo/workflows | ||
| deploy | ||
| frontend | ||
| migrations | ||
| src | ||
| .dockerignore | ||
| .env.example | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| compose.yml | ||
| Dockerfile | ||
| README.md | ||
CDN
Rust file-hosting API with a React UI. Anyone can browse and download; uploading requires a logged-in (approved) account. Admins approve or create users.
Quick start
cp .env.example .env
# set ADMIN_PASSWORD (required, min 8 chars)
cargo run
# UI (dev) — separate terminal
cd frontend && npm install && npm run dev
- API / production UI:
http://127.0.0.1:8080 - Vite UI:
http://127.0.0.1:5173(proxies/apito the API)
On first boot the admin from ADMIN_USERNAME / ADMIN_PASSWORD is created if none exists.
Production (single process)
cd frontend && npm install && npm run build
cd .. && cargo run
Auth model
| Who | Can do |
|---|---|
| Public | List, view, download, copy share links |
| Logged-in approved user | Upload, delete |
| Admin | Manage accounts (create / approve / reject / delete) |
Self-registration creates a pending account until an admin approves it.
API
| Method | Path | Auth | Description |
|---|---|---|---|
GET |
/health |
no | Liveness |
GET |
/api/files |
no | List files (q, type) |
GET |
/{id} |
no | Download / view file |
POST |
/api/auth/register |
no | Request account (pending) |
POST |
/api/auth/login |
no | Login (session cookie) |
POST |
/api/auth/logout |
session | Logout |
GET |
/api/auth/me |
session | Current user |
POST |
/api/upload |
session | Multipart upload (file) |
DELETE |
/api/files/{id} |
session | Delete file |
GET |
/api/admin/users |
admin | List users |
POST |
/api/admin/users |
admin | Create approved user |
POST |
/api/admin/users/{id}/approve |
admin | Approve pending |
POST |
/api/admin/users/{id}/reject |
admin | Reject pending |
DELETE |
/api/admin/users/{id} |
admin | Delete user |
Examples
# public list
curl -sS "http://127.0.0.1:8080/api/files"
# login (stores cdn_session cookie)
curl -sS -c cookies.txt -X POST http://127.0.0.1:8080/api/auth/login \
-H 'Content-Type: application/json' \
-d '{"username":"admin","password":"your-password"}'
# upload
curl -sS -b cookies.txt -X POST http://127.0.0.1:8080/api/upload \
-F "file=@./photo.jpg"
Deployment
Docker Compose
cp .env.example .env
# set ADMIN_PASSWORD and ideally PUBLIC_BASE_URL=https://your.domain
docker compose up -d --build
See compose.yml, Dockerfile, deploy/Caddyfile.example, and deploy/cdn.service.
Configuration
See .env.example.