26 lines
677 B
TypeScript

import { Request, Response } from 'express';
import { prisma } from '../../../lib/prisma';
export async function sitemapArticles(req: Request, res: Response) {
try {
const articles = await prisma.article.findMany({
select: {
id: true,
publishedAt: true,
},
where: {
isActive: true,
},
take: 10000, // запасной лимит
});
// Формируем ответ
res.json({
articles,
});
} catch (error) {
console.error('Ошибка получения статей для карты сайта:', error);
res.status(500).json({ error: 'Серверная ошибка' });
}
}