This repository contains the Fairplay backend API built with:
- TypeScript
- Express.js
- PostgreSQL
- Prisma
- MinIO
- FFmpeg
- Bun
It uses session-based authentication and versioned Prisma migrations.
Documentation is available at: https://apiv2.fairplay.video/docs
You need:
- Bun -> https://bun.sh
- A PostgreSQL database
- A MinIO instance (or compatible S3 storage)
- FFmpeg installed on your system
To simplify the setup of PostgreSQL and MinIO, you can use Docker Desktop. Running them with Docker is usually faster and avoids manual installation issues.
- Install dependencies
bun i- Create your environment file
cp .env.example .envThen fill in the values you want to use.
Important environment notes:
FRONTEND_URLis used to build email verification linksPLAYBACK_TOKEN_SECRETshould be set in production to sign short-lived HLS playback URLs returned byGET /videos/:idPLAYBACK_TOKEN_TTL_SECONDScontrols how long those signed playback URLs stay valid (default: 3600 seconds)TRUST_PROXYshould be set in production if the API is behind Nginx, Caddy, Cloudflare, or another reverse proxy. Use1for a single trusted proxy hop, ortrueif your full proxy chain is trusted.JSON_BODY_LIMIT_BYTESandURLENCODED_BODY_LIMIT_BYTEScap non-file request payloads globally (defaults: 1MB JSON, 256KB URL-encoded)CLEANUP_INTERVAL_MINUTEScontrols how often expired sessions and stale chunk upload folders are cleaned upSMTP_HOST,SMTP_PORT,SMTP_USER,SMTP_PASS, andSMTP_FROMare required to send verification emails- The API can start without SMTP configured, but registration and resend-verification endpoints will return
503until those values are set - Direct upload endpoints accept videos up to 95MB to stay under Cloudflare's request limit; use the chunked upload flow for larger files
- Chunked uploads are capped to protect temporary disk usage and currently allow up to 3040MB total
- Generate Prisma client
bunx prisma generate- Apply the initial migration
bun run prisma:migrate:deployFor local schema changes during development:
bun run prisma:migrate:devRun in development mode:
bun run devRun the lightweight verification suite:
bun run checkContribution notes: CONTRIBUTING.md
Check migration state:
bun run prisma:migrate:statusBuild:
bun run buildStart:
bun run startDatabase deployment:
bun run prisma:migrate:deployIf something does not work, check:
- Your
.envvalues - That PostgreSQL is running
- That MinIO is accessible
- That FFmpeg is installed
- That
FRONTEND_URLpoints to your frontend - That
TRUST_PROXYis configured correctly if you are behind a reverse proxy - That your SMTP settings are configured if you want registration and email verification to work