Files
shop-server/AGENTS.md
T
2026-06-11 13:41:38 +05:00

1.9 KiB

AGENTS.md — shop-server

Project structure

  • server/ — Fastify + Prisma + SQLite backend
  • shared/constants/ — JS + .d.ts shared with client (order statuses, delivery carriers, payment methods, upload limits)

Developer commands

Command What it does
npm run dev node --env-file=.env --watch src/index.js (requires Node 20.6+)
npm run dev:classic node --watch src/index.js (loads .env via dotenv)
npm run lint ESLint (flat config)
npm run lint:fix ESLint with --fix
npm run format Prettier write all
npm run format:check Prettier check only
npm test vitest run
npm run db:reset:test Reset SQLite DB + re-run migrations + seed (uses .env)

Conventions

  • Language: Отвечай пользователю на русском.
  • Single quotes, no semicolons, trailing commas, 120 print width (Prettier + ESLint enforce).
  • Alias: @shared → shared/ (configured in vitest.config.js for tests).
  • Admin access: Only users with email matching ADMIN_EMAIL env var can access admin routes. Server auto-creates the admin user on startup.
  • Server helpers: slugify, parseMaterialsInput, mapProductForApi are decorated on fastify instance, accessed via request.server.*.

Testing

  • Vitest with globals enabled.
  • Test files live in tests/ directories next to the code they test.

OAuth

  • VK callback: {SERVER_PUBLIC_URL}/api/auth/oauth/vk/callback
  • Yandex callback: {SERVER_PUBLIC_URL}/api/auth/oauth/yandex/callback

Infrastructure (deployment)

  • VPS runs Nginx Proxy Manager (NPM), connected via Netbird VPN to the server machine
  • Server machine runs the project
  • Traffic flow: Browser → Domain → VPS (NPM) → Netbird → Server machine (3333)
  • trustProxy: true on Fastify

Notable quirks

  • .env is gitignored. Copy .env.example to .env for local dev.
  • db:reset:test runs prisma migrate reset --force, which destroys all data.