Merge laatste worktree in master
Neemt de laatste PantryHub-implementatie over in de hoofdbranch.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
+2
-37
@@ -1,43 +1,8 @@
|
||||
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);
|
||||
|
||||
});
|
||||
router.use(auth);
|
||||
router.get("/products", (req, res) => res.json(ProductRepository.getAll()));
|
||||
|
||||
module.exports = router;
|
||||
|
||||
+21
-18
@@ -20,6 +20,27 @@ router.get(
|
||||
DashboardController.index
|
||||
);
|
||||
|
||||
router.get(
|
||||
"/household",
|
||||
auth,
|
||||
HouseholdController.index.bind(HouseholdController)
|
||||
);
|
||||
|
||||
router.get(
|
||||
"/products",
|
||||
|
||||
auth,
|
||||
|
||||
ProductController.index.bind(ProductController)
|
||||
|
||||
);
|
||||
|
||||
router.post(
|
||||
"/products",
|
||||
auth,
|
||||
ProductController.create.bind(ProductController)
|
||||
);
|
||||
|
||||
router.get(
|
||||
"/lists",
|
||||
auth,
|
||||
@@ -56,22 +77,4 @@ router.delete(
|
||||
ShoppingListController.deleteItem.bind(ShoppingListController)
|
||||
);
|
||||
|
||||
router.get(
|
||||
"/household",
|
||||
auth,
|
||||
HouseholdController.index.bind(HouseholdController)
|
||||
);
|
||||
|
||||
router.get(
|
||||
"/products",
|
||||
auth,
|
||||
ProductController.index.bind(ProductController)
|
||||
);
|
||||
|
||||
router.post(
|
||||
"/products",
|
||||
auth,
|
||||
ProductController.create.bind(ProductController)
|
||||
);
|
||||
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user