- aggiunto componenti per Home Template... ma ancora da provare

- sistemato catprods
- Sistemato menu
This commit is contained in:
Surya Paolo
2025-09-22 19:09:02 +02:00
parent 4a05ddee50
commit 08cf4b6d9f
31 changed files with 475 additions and 31 deletions

View File

@@ -0,0 +1,18 @@
// @ts-check
const { HomeModel } = require('../models/Home');
async function getHome(req, res) {
const doc = await HomeModel.findOne({});
if (!doc) return res.status(404).json({ message: 'Home non configurata' });
res.set('Cache-Control', 'public, max-age=60, stale-while-revalidate=300');
res.set('ETag', `"${doc.updatedAt?.getTime?.() || Date.now()}"`);
return res.json(doc);
}
async function upsertHome(req, res) {
const payload = req.body || {};
const doc = await HomeModel.findOneAndUpdate({}, payload, { upsert: true, new: true, setDefaultsOnInsert: true });
return res.json(doc);
}
module.exports = { getHome, upsertHome };