Vercel/app/feed.json/route.ts
2025-06-12 21:34:06 -05:00

20 lines
557 B
TypeScript

import { getPhotosCached } from '@/photo/cache';
import { SITE_FEEDS_ENABLED } from '@/app/config';
import { FEED_PHOTO_REQUEST_LIMIT } from '@/feed';
import { formatFeedJson } from '@/feed/json';
// Cache for 24 hours
export const revalidate = 86_400;
export async function GET() {
if (SITE_FEEDS_ENABLED) {
const photos = await getPhotosCached({
limit: FEED_PHOTO_REQUEST_LIMIT,
sortBy: 'createdAt',
});
return Response.json(formatFeedJson(photos));
} else {
return new Response('Feeds disabled', { status: 404 });
}
}