fix: move drafts API routes to correct /app/api/admin/drafts/ path

This commit is contained in:
Nik (Claude)
2026-06-16 22:32:10 +03:00
parent 4ddff73218
commit d4b3650de3
5 changed files with 0 additions and 0 deletions
@@ -0,0 +1,13 @@
import { NextResponse } from 'next/server';
import { requireAdminAuth } from '@/lib/adminAuth';
import { engineFetch } from '@/lib/engine';
export async function PATCH(req, { params }) {
await requireAdminAuth();
try {
const data = await engineFetch(`/api/drafts/${params.id}/approve`, { method: 'PATCH' });
return NextResponse.json(data);
} catch (err) {
return NextResponse.json({ error: err.message }, { status: 500 });
}
}
@@ -0,0 +1,16 @@
import { NextResponse } from 'next/server';
import { requireAdminAuth } from '@/lib/adminAuth';
import { engineFetch } from '@/lib/engine';
export async function POST(req, { params }) {
await requireAdminAuth();
try {
const body = await req.json().catch(() => ({}));
const data = await engineFetch(`/api/drafts/${params.id}/regenerate-cover`, {
method: 'POST', body: JSON.stringify(body),
});
return NextResponse.json(data);
} catch (err) {
return NextResponse.json({ error: err.message }, { status: 500 });
}
}
+16
View File
@@ -0,0 +1,16 @@
import { NextResponse } from 'next/server';
import { requireAdminAuth } from '@/lib/adminAuth';
import { engineFetch } from '@/lib/engine';
export async function PATCH(req, { params }) {
await requireAdminAuth();
try {
const body = await req.json();
const data = await engineFetch(`/api/drafts/${params.id}`, {
method: 'PATCH', body: JSON.stringify(body),
});
return NextResponse.json(data);
} catch (err) {
return NextResponse.json({ error: err.message }, { status: 500 });
}
}
+13
View File
@@ -0,0 +1,13 @@
import { NextResponse } from 'next/server';
import { requireAdminAuth } from '@/lib/adminAuth';
import { engineFetch } from '@/lib/engine';
export async function POST() {
await requireAdminAuth();
try {
const data = await engineFetch('/api/drafts/approve-all', { method: 'POST' });
return NextResponse.json(data);
} catch (err) {
return NextResponse.json({ error: err.message }, { status: 500 });
}
}
+15
View File
@@ -0,0 +1,15 @@
import { NextResponse } from 'next/server';
import { requireAdminAuth } from '@/lib/adminAuth';
import { engineFetch } from '@/lib/engine';
export const dynamic = 'force-dynamic';
export async function GET() {
await requireAdminAuth();
try {
const data = await engineFetch('/api/drafts');
return NextResponse.json(data);
} catch (err) {
return NextResponse.json({ error: err.message }, { status: 500 });
}
}