Werk hoofdapplicatie bij
Legt de bestaande wijzigingen in de hoofdworktree vast voordat de laatste worktree wordt gemerged.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
const router = require("express").Router();
|
||||
|
||||
const auth = require("../middleware/auth");
|
||||
|
||||
const ProductRepository = require("../repositories/ProductRepository");
|
||||
const ShoppingListRepository = require("../repositories/ShoppingListRepository");
|
||||
|
||||
// Get all products
|
||||
router.get("/products", auth, (req, res) => {
|
||||
|
||||
const products = ProductRepository.getAll();
|
||||
|
||||
res.json(products);
|
||||
|
||||
});
|
||||
|
||||
// Get shopping lists for household
|
||||
router.get("/lists", auth, (req, res) => {
|
||||
|
||||
const lists = ShoppingListRepository.getByHousehold(
|
||||
req.user.household_id
|
||||
);
|
||||
|
||||
res.json(lists);
|
||||
|
||||
});
|
||||
|
||||
// Get shopping list items
|
||||
router.get("/lists/:id/items", auth, (req, res) => {
|
||||
|
||||
const list = ShoppingListRepository.getById(req.params.id);
|
||||
|
||||
if (!list || list.household_id !== req.user.household_id) {
|
||||
return res.status(403).json({ error: "Not authorized" });
|
||||
}
|
||||
|
||||
const items = ShoppingListRepository.getItems(req.params.id);
|
||||
|
||||
res.json(items);
|
||||
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user