An Express + TypeScript API for managing users and video metadata.
Uses Prisma (PostgreSQL), optional Redis caching, JWT auth, and Swagger for docs.
- User registration & login with JWT auth
- CRUD for videos (create, update, list, delete)
- Query videos with filters (
genre,tags,page,limit) - Swagger UI documentation
- Optional Redis caching for video queries
- Prisma ORM with PostgreSQL
- Node.js (16+ recommended)
- PostgreSQL
- Redis (optional, only for caching)
- Docker (optional, for running Postgres & Redis locally)
git clone <your-repo-url>
cd <your-repo>
npm installCreate a .env file in project root:
DATABASE_URL="postgresql://postgres:password@localhost:5432/videoDb?schema=public"
REDIS_URL="redis://127.0.0.1:6379"
PORT=4000Generate client and apply schema:
npx prisma generate
npx prisma migrate dev --name init
# OR if you prefer without migrations
npx prisma db pushnpm run devApp runs at:
👉 http://localhost:4000
Swagger UI:
👉 http://localhost:4000/api-docs
docker-compose.yml (example):
version: "3.8"
services:
postgres:
image: postgres:15
environment:
POSTGRES_DB: videoDb
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
ports:
- "5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data
redis:
image: redis:7
ports:
- "6379:6379"
volumes:
pgdata:Run:
docker compose up -dThen migrate:
npx prisma migrate dev --name init- Register:
POST /auth/register - Login:
POST /auth/login - Use JWT in requests:
Authorization: Bearer <token>
POST /auth/register→ create new userPOST /auth/login→ login and get JWT
POST /videos→ add new video (auth required)GET /videos→ list videos (supports filters & pagination)PATCH /videos/:id→ update video (auth required)DELETE /videos/:id→ delete video (auth required)
Visit: http://localhost:4000/api-docs
Use the Authorize button to test secured routes.
Project uses Jest + Supertest.
Run:
npm testMake sure to disconnect Prisma in afterAll to avoid open handles warnings.