Replace reverse-proxy/iframe approach with @ebook/@community/@navmini imports under /nav /book /community so localhost:3000 serves all three products directly. Co-authored-by: Cursor <cursoragent@cursor.com>
28 lines
966 B
TypeScript
28 lines
966 B
TypeScript
import { NextResponse } from 'next/server';
|
|
import {
|
|
createSupportInvoice,
|
|
isAllowedSupportAmount,
|
|
isNowPaymentsConfigured,
|
|
} from '@ebook/lib/nowpayments';
|
|
|
|
export async function POST(req: Request) {
|
|
if (!isNowPaymentsConfigured()) {
|
|
return NextResponse.json({ ok: false, error: 'payments not configured' }, { status: 503 });
|
|
}
|
|
|
|
try {
|
|
const body = (await req.json()) as { amount?: number };
|
|
const amount = Number(body.amount);
|
|
if (!isAllowedSupportAmount(amount)) {
|
|
return NextResponse.json({ ok: false, error: 'invalid amount' }, { status: 400 });
|
|
}
|
|
|
|
const invoice = await createSupportInvoice(amount);
|
|
return NextResponse.json({ ok: true, invoiceUrl: invoice.invoiceUrl });
|
|
} catch (error) {
|
|
const message = error instanceof Error ? error.message : 'invoice failed';
|
|
console.error('NOWPayments invoice', message);
|
|
return NextResponse.json({ ok: false, error: 'invoice failed' }, { status: 502 });
|
|
}
|
|
}
|