feat: Phase 1 — Fastify backend with auth, users, admin API

Backend stack:
- Fastify v5 with JWT auth, CORS, cookies, rate limiting
- PostgreSQL via Drizzle ORM with full schema:
  users, presets, game_progress, shared_patches, likes, refresh_tokens
- Argon2 password hashing, httpOnly refresh cookie rotation

API endpoints:
- POST /api/v1/auth/register|login|refresh|logout
- GET|PATCH /api/v1/users/me (profile)
- GET /api/v1/admin/stats (dashboard KPIs)
- GET|PATCH /api/v1/admin/users (list, role change, ban)
- GET|PATCH /api/v1/admin/patches (moderation)
- GET /api/health

Infrastructure:
- Vite proxy /api → localhost:3001 for dev
- .env.example with all config vars
- Dockerfile updated: installs server deps, serves SPA + API
- npm run dev:server for backend hot-reload
- npm run db:push for schema sync

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jose Luis
2026-03-21 19:58:21 +01:00
parent b058997889
commit 6a4a308fd9
15 changed files with 3539 additions and 8 deletions

View File

@@ -9,9 +9,11 @@ RUN npm run build
FROM node:20-alpine
WORKDIR /app
COPY package.json package-lock.json* ./
COPY packages/server/package.json packages/server/
RUN npm install -w packages/server --omit=dev
COPY --from=build /app/dist ./dist
COPY packages/server/server.js ./packages/server/server.js
COPY packages/server/package.json ./packages/server/package.json
COPY package.json ./
COPY packages/server packages/server
ENV NODE_ENV=production
EXPOSE 80
CMD ["node", "packages/server/server.js"]
CMD ["node", "packages/server/src/index.js"]