API reference
All API routes under app/api/** use dynamic = "force-dynamic". Auth is enforced inside handlers.
Upload APIs
POST /api/upload
Auth: portal access (canAccessUploadPortal) — valid portal cookie with usable link, or valid admin cookie.
Body: multipart/form-data
file— video filedateRecorded—YYYY-MM-DD
Use when file size ≤ maxSimpleFileSizeBytes (default 4 MB).
Success 200: { id, name, webUrl, size }
POST /api/upload/session
Auth: same portal access gate.
Body (JSON): { filename, fileSize, dateRecorded }
Creates a Graph upload session. Client then uploads chunks with PUT directly to Microsoft uploadUrl using Content-Range headers (default chunk 10 MB).
Use when file is larger than the simple-upload threshold (up to maxFileSizeBytes, default 4 GB).
POST /api/upload/complete
Auth: same portal access gate.
Body (JSON): { webUrl?, name? }
Server steps:
- If portal token +
webUrlpresent → send notification email - Consume link (
usedAt) - Clear portal
upload_accesscookie
Email failures are logged and do not fail the response.
GET /api/upload/context
Returns { childName, edc, availableAt, expiresAt, fromLink } for the upload UI.
End-to-end client upload sequence
- Parent selects video + date recorded
- If size ≤ simple limit →
POST /api/upload
Else →POST /api/upload/session, then chunkedPUTs to Microsoft POST /api/upload/completewith{ webUrl, name }- UI shows success; link is single-use thereafter
Mobile Safari notes: use a native full-size transparent <input type="file">. Empty MIME types are accepted when the file looks like video. Do not clear input.value in the same turn as reading the File.
Config and link management
| Method | Path | Auth | Notes |
|---|---|---|---|
GET | /api/config | None (public) | Full merged AppConfig |
PUT | /api/config | Admin | Partial config patch |
DELETE | /api/config | Admin | Clears Redis overrides |
POST | /api/generate-link | Admin | Body { childName, edc } |
GET | /api/links | ⚠️ currently unauthenticated | Hardening candidate |
DELETE | /api/links | ⚠️ currently unauthenticated | Body { token } |
OneDrive browse (admin)
GET /api/onedrive/browse— folders & workbooksGET /api/onedrive/child-names— children from reference Excel
Authentication APIs
| Method | Path | Purpose |
|---|---|---|
GET | /api/auth/admin/login | Start admin Microsoft login |
GET | /api/auth/upload-access/login | Start upload-access OAuth |
GET | /api/auth/upload-access/callback | OAuth callback |
GET | /api/auth/onedrive/login | Connect/replace receiving OneDrive |
GET | /api/auth/onedrive/callback | OAuth callback for setup flow |
GET | /api/auth/onedrive/status | Connection status |
DELETE | /api/auth/onedrive/status | Disconnect receiving OneDrive |
Non-API route
GET /portalaccess/[token] activates a parent session when the link is usable, sets the signed portal cookie, and redirects to /.