PortalShell (sidebar + session bar via /api/auth/me + logout). Customer: /portal nav, /portal/subscriptions (create feed), /portal/settings (dev-login + DPA). Admin: /admin (metrics + order queue with inline status advance), /admin/sources. APIs: /api/admin/metrics, /api/subscriptions. tsc 0, build green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
17 lines
714 B
TypeScript
17 lines
714 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { createSubscription, listSubscriptions } from "@/lib/subscriptions-store";
|
|
|
|
// GET /api/subscriptions — feeds list. POST — convert an order to a recurring feed.
|
|
export async function GET() {
|
|
return NextResponse.json(await listSubscriptions());
|
|
}
|
|
|
|
export async function POST(req: NextRequest) {
|
|
const body = await req.json().catch(() => ({}));
|
|
if (!body.order_id) {
|
|
return NextResponse.json({ error: { code: "bad_request", message: "order_id krävs" } }, { status: 400 });
|
|
}
|
|
const sub = await createSubscription(body.order_id, body.cadence ?? "weekly", body.webhook_url ?? null);
|
|
return NextResponse.json(sub, { status: 201 });
|
|
}
|