1.8 KiB
1.8 KiB
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
docker compose up --build
This starts PostgreSQL and API, runs Prisma generate/db push/seed automatically.
Auth (JWT in Cookie)
POST /api/users/registerPOST /api/users/loginGET /api/users/me(requires cookie)POST /api/users/logout(requires cookie)
Cookie is HTTP-only and set with sameSite=lax.
Shop endpoints
GET /api/healthGET /api/shop/categoriesGET /api/shop/productsGET /api/shop/products/:productIdPOST /api/shop/products(multipart/form-datais 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/<filename>.
Product responses include image_url with an absolute URL when an image exists.
Order payload:
{
"customer_name": "Jane Doe",
"customer_email": "jane@example.com",
"items": [
{ "product_id": 1, "quantity": 2 }
]
}
Image extraction batch
scripts\extract-images-from-build.bat "..\build" ".\public\images"
Defaults (if arguments omitted):
- Source:
..\build - Target:
.\public\images