Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

Repository files navigation

Video Metadata API

An Express + TypeScript API for managing users and video metadata.
Uses Prisma (PostgreSQL), optional Redis caching, JWT auth, and Swagger for docs.


🚀 Features

  • 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

📦 Requirements

  • Node.js (16+ recommended)
  • PostgreSQL
  • Redis (optional, only for caching)
  • Docker (optional, for running Postgres & Redis locally)

⚙️ Setup

1. Clone & install

git clone <your-repo-url>
cd <your-repo>
npm install

2. Environment variables

Create 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=4000

3. Prisma

Generate client and apply schema:

npx prisma generate
npx prisma migrate dev --name init
# OR if you prefer without migrations
npx prisma db push

4. Run dev server

npm run dev

App runs at:
👉 http://localhost:4000
Swagger UI:
👉 http://localhost:4000/api-docs


🐳 Docker (optional)

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 -d

Then migrate:

npx prisma migrate dev --name init

🔑 Authentication

  • Register: POST /auth/register
  • Login: POST /auth/login
  • Use JWT in requests:
    Authorization: Bearer <token>

📖 API Endpoints

Auth

  • POST /auth/register → create new user
  • POST /auth/login → login and get JWT

Videos

  • 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)

🔍 Swagger

Visit: http://localhost:4000/api-docs
Use the Authorize button to test secured routes.


🧪 Testing

Project uses Jest + Supertest.

Run:

npm test

Make sure to disconnect Prisma in afterAll to avoid open handles warnings.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages