# Webstore Backend (Laxer + CQRS + Prisma) Educational Node.js backend for frontend students. ## Structure ``` backend/ prisma/ schema.prisma seed.js public/ images/ scripts/ extract-images-from-build.bat src/ Api/ Controller/ Router/ Middleware/ app.js server.js Application/ User/ Command/ command.js commandhandler.js Querry/ query.js queryhandler.js Services/ DTO/ Domain/ IRepository/ Models/ Infrastructure/ Repository/ config/ env.js prisma.js ``` ## Run with Docker Compose ```bash docker compose up --build ``` This starts PostgreSQL and API, runs Prisma generate/db push/seed automatically. ## Auth (JWT in Cookie) - `POST /api/users/register` - `POST /api/users/login` - `GET /api/users/me` (requires cookie) - `POST /api/users/logout` (requires cookie) Cookie is HTTP-only and set with `sameSite=lax`. ## Shop endpoints - `GET /api/health` - `GET /api/shop/categories` - `GET /api/shop/products` - `GET /api/shop/products/:productId` - `POST /api/shop/products` (`multipart/form-data` is supported, field name: `image`) - `POST /api/shop/products/:productId/image` (`multipart/form-data`, field name: `image`) - `POST /api/shop/orders` Uploaded files are stored in `images/uploads` and are served at `/images/uploads/`. Product responses include `image_url` with an absolute URL when an image exists. Order payload: ```json { "customer_name": "Jane Doe", "customer_email": "jane@example.com", "items": [ { "product_id": 1, "quantity": 2 } ] } ``` ## Image extraction batch ```bat scripts\extract-images-from-build.bat "..\build" ".\public\images" ``` Defaults (if arguments omitted): - Source: `..\build` - Target: `.\public\images`