Files
videoreg.ru/web-front/legacy/api-videos.ts
T
huncode 53e4f06486
Production container deploy / production (push) Failing after 2m34s
Restore videoreg public guide site with static isolated deployment
2026-10-26 14:26:13 +03:00

30 lines
1021 B
TypeScript

import { NextResponse } from 'next/server';
import { revalidatePath, revalidateTag } from 'next/cache';
import { getCachedVideoDashboard, VIDEO_COLLECTION_TAG } from '@/entities/video/api/videoCache';
import { addVideo } from '@/entities/video/api/videoRepository';
import { normalizeVideoDraft } from '@/entities/video/model/video';
export const revalidate = 3600;
export async function GET() {
const dashboard = await getCachedVideoDashboard();
return NextResponse.json(dashboard, {
headers: {
'cache-control': 'public, max-age=60, s-maxage=3600, stale-while-revalidate=86400',
},
});
}
export async function POST(request: Request) {
const body = (await request.json().catch(() => undefined)) as
| { title?: string; owner?: string; sourceUrl?: string; status?: string }
| undefined;
const video = await addVideo(normalizeVideoDraft(body ?? {}));
revalidateTag(VIDEO_COLLECTION_TAG, { expire: 0 });
revalidatePath('/');
return NextResponse.json({ video }, { status: 201 });
}