1.8 KiB
1.8 KiB
backend
Install
bun install
Environment
Create a .env file:
cp .env.example .env
Set:
DATABASE_URL=postgres://username:password@localhost:5432/database_name
JWT_SECRET=replace_with_a_long_random_secret
JWT_EXPIRES_IN=7d
PORT=3000
MINIO_ENDPOINT=localhost
MINIO_PORT=9000
MINIO_USE_SSL=false
MINIO_ACCESS_KEY=minioadmin
MINIO_SECRET_KEY=minioadmin
MINIO_BUCKET=videos
MINIO_REGION=us-east-1
MINIO_PRESIGNED_EXPIRY_SECONDS=600
Run app
bun run dev
Drizzle ORM
Generate migrations:
bun run db:generate
Apply migrations:
bun run db:migrate
Open Drizzle Studio:
bun run db:studio
Auth API
Register:
POST /auth/register
{
"email": "user@example.com",
"password": "password123",
"name": "User Name"
}
Login:
POST /auth/login
{
"email": "user@example.com",
"password": "password123"
}
Get current user:
GET /auth/me
Authorization: Bearer <token>
Video API (Dummy MinIO S3 Integration)
All routes require a JWT Bearer token.
Create a presigned upload URL:
POST /videos/upload-url
Authorization: Bearer <token>
{
"fileName": "sample.mp4",
"prefix": "raw"
}
Get a presigned download URL:
GET /videos/download-url?objectKey=raw/<user-id>/<timestamp>-sample.mp4
Authorization: Bearer <token>
List video objects:
GET /videos?prefix=raw&limit=20
Authorization: Bearer <token>
Delete a video object:
DELETE /videos?objectKey=raw/<user-id>/<timestamp>-sample.mp4
Authorization: Bearer <token>
Self-hosted MinIO note Make sure the backend can reach your MinIO endpoint (network, TLS, credentials) and mirror any bucket changes you make outside of the app in MINIO_BUCKET, otherwise uploads/downloads fail.