feat: P4 metrics collector + /api/metrics; P5 from-url generator (cheerio)

This commit is contained in:
Nik (Claude)
2026-06-08 11:08:59 +03:00
parent 008323fa74
commit 771f964370
7 changed files with 837 additions and 0 deletions
+19
View File
@@ -111,4 +111,23 @@ router.post('/topics-ideas', async (req, res) => {
}
});
// POST /api/generate/from-url — прочитать URL и написать пост в стиле канала
router.post('/from-url', async (req, res) => {
try {
const { channelId, url } = req.body;
const userId = parseInt(req.headers['x-user-id']) || null;
if (!channelId || !url) return res.status(400).json({ error: 'channelId and url required' });
const channel = await channelsSvc.getChannel(userId, channelId);
if (!channel) return res.status(404).json({ error: 'Channel not found' });
const { generateFromUrl } = require('../services/fromUrl');
const result = await generateFromUrl({ url, channelId, channel });
res.json(result);
} catch (err) {
console.error('[Route] POST /generate/from-url', err);
res.status(500).json({ error: err.message });
}
});
module.exports = router;