- inizio di modifiche all'editor di Pagine Web

This commit is contained in:
Surya Paolo
2025-09-05 01:06:46 +02:00
parent 7ba408c053
commit a2dd06bd68
8 changed files with 60 additions and 9 deletions

View File

@@ -14,6 +14,9 @@ const Author = require('../models/author');
const tools = require('../tools/general');
const { MyPage } = require('../models/mypage');
const { MyElem } = require('../models/myelem');
const axios = require('axios');
router.post('/test-lungo', authenticate, (req, res) => {
@@ -195,19 +198,20 @@ router.delete('/mypage/:id', authenticate, async (req, res) => {
try {
const { id } = req.params;
// Trova il record di MyPage da cancellare
const pageToDelete = await MyPage.findByIdAndRemove(id);
const pageToDelete = await MyPage.findByIdAndDelete(id);
if (!pageToDelete) return res.status(404).json({ error: 'Pagina non trovata' });
if (!pageToDelete) {
return res.status(404).json({ error: 'Pagina non trovata' });
} else {
await MyElem.deleteAllFromThisPage(id);
}
res.json({ message: `Pagina eliminata con successo: ${pageToDelete.path}` });
} catch (err) {
console.error(err);
res.status(500).json({ error: 'Errore durante l\'eliminazione della pagina' });
res.status(500).json({ error: "Errore durante l'eliminazione della pagina" });
}
});
@@ -487,5 +491,4 @@ router.post('/chatbot', authenticate, async (req, res) => {
}
});
module.exports = router;