Skip to content

Repository files navigation

Cap QA — Backend

Express + Prisma + PostgreSQL API. Auth (JWT + bcrypt), Organizations, and Projects.

Model

Organization → Projects, with users joined to orgs via Membership (OWNER/ADMIN/MEMBER). A seeded admin user owns a default org.

Setup

npm install
cp .env.example .env            # edit secrets

# 1) Start Postgres (Docker) — or point DATABASE_URL at your own instance
docker compose up -d

# 2) Create the schema + generate the client
npx prisma migrate dev          # applies migrations
npm run generate                # (migrate already generates; here for CI)

# 3) Seed the admin user + default org
npm run seed
#   → admin@cap.local / admin123   (change in .env)

# 4) Run the API
npm run dev                     # http://localhost:4000

Endpoints

Method Path Auth Purpose
GET /api/health liveness
POST /api/auth/login { email, password }{ token, user, orgs }
GET /api/auth/me Bearer current user + orgs
GET /api/orgs Bearer orgs the user belongs to
POST /api/orgs Bearer create an org (creator = OWNER)
GET /api/projects Bearer projects in the user's orgs (?orgId= to filter)
POST /api/projects Bearer { name, description?, key?, orgId? } — key auto-derived if omitted
GET /api/projects/:id Bearer one project

Notes

  • Passwords are bcrypt-hashed; tokens are JWT (JWT_EXPIRES_IN, default 7d).
  • PORT defaults to 4000; the frontend proxies /api → this port in dev.
  • Switch to a managed Postgres for production by changing DATABASE_URL only.
  • Compose live hydrate prefers local CapBO trees when set:
    • CAPQA_LOCAL_UI_ROOT — frontend repo root (e.g. …/capbo-frontend)
    • CAPQA_LOCAL_API_ROOT — backend repo root (e.g. …/capbo-backend) If unset, Compose falls back to GitLab live fetch from connected repos.

Next steps (planned)

  • Move GitLab/Jira connector tokens here (encrypted at rest) so they leave the browser.
  • Per-project connectors, test suites, runs, and members endpoints.
  • Login rate-limiting + refresh tokens.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages