Applicatie afmaken en GUI-flow herstellen

Voegt boodschappenlijsten, productbeheer, realtime synchronisatie en browsercache-updates toe. Herstelt login- en sessiegedrag en maakt database-seeding herhaalbaar.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-08-07 20:44:05 +02:00
parent 26a820b41a
commit ce68182c08
23 changed files with 552 additions and 163 deletions
+27 -6
View File
@@ -1,29 +1,50 @@
const ProductService =
require("../services/ProductService");
const db = require("../config/database");
class ProductController {
index(req,res) {
index(req, res) {
const products =
ProductService.getProducts();
const categories = db.prepare(
"SELECT * FROM categories ORDER BY name"
).all();
res.render(
"products/index",
{
title:"Producten",
products
products,
categories
}
);
}
create(req, res) {
const name = (req.body.name || "").trim();
const categoryId = req.body.category_id
? Number.parseInt(req.body.category_id, 10)
: null;
if (!name || (categoryId !== null && !Number.isInteger(categoryId))) {
req.flash("error", "Geef een geldige productnaam en categorie op.");
return res.redirect("/products");
}
ProductService.createProduct({
name,
category_id: categoryId
});
req.flash("success", "Product toegevoegd.");
res.redirect("/products");
}