fix: move drafts API routes to correct /app/api/admin/drafts/ path
This commit is contained in:
@@ -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 });
|
||||
}
|
||||
}
|
||||
@@ -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 });
|
||||
}
|
||||
}
|
||||
@@ -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 });
|
||||
}
|
||||
}
|
||||
@@ -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 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user