forked from admin/zeropost-tool
a5f6c080bd
Header: убрана кнопка Система (дубль Админ), убраны устаревшие импорты AdminPanel: 6 разделов (AI-провайдеры, Движок, ЮKassa, Расходы AI, Тарифы, Пользователи) Тарифы: редактор планов (цена/кредиты/каналы) + стоимость операций Движок: ENGINE_PUBLIC_URL, APP_PUBLIC_URL, TELEGRAM_API_BASE, AUTO_DRAFT_* PlansSection: inline-редактирование тарифов и credit_costs API routes: /api/admin/plans/[id], /api/admin/credit-costs/[operation]
18 lines
741 B
JavaScript
18 lines
741 B
JavaScript
import { NextResponse } from 'next/server';
|
|
import { requireUser } from '@/lib/session';
|
|
|
|
const ENGINE_URL = process.env.ENGINE_URL || 'http://127.0.0.1:3030';
|
|
const ENGINE_SECRET = process.env.ENGINE_SECRET || '';
|
|
|
|
export async function PATCH(req, { params }) {
|
|
const user = await requireUser();
|
|
if (!user?.isAdmin) return NextResponse.json({ error: 'Forbidden' }, { status: 403 });
|
|
const body = await req.json();
|
|
const res = await fetch(`${ENGINE_URL}/api/admin/credit-costs/${params.operation}`, {
|
|
method: 'PATCH',
|
|
headers: { 'Content-Type': 'application/json', 'x-internal-secret': ENGINE_SECRET, 'x-user-id': String(user.id) },
|
|
body: JSON.stringify(body),
|
|
});
|
|
return NextResponse.json(await res.json());
|
|
}
|