# 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 ## Deployment - Gitea CI/CD deploys to the server machine on push to main - Traffic flow: Browser → Domain → Nginx (server machine) → Fastify (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.