feat: P4 metrics collector + /api/metrics; P5 from-url generator (cheerio)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user