nomadro/app/api/admin/orders/route.ts
eric 9f8fec1723 Ship portal PC/H5 acceptance, VIP ScrollReader, admin analytics and ops anchors.
Adds /api/health, ntfy notify on config save, /admin/analytics charts, and deploy smoke for miniprogram config/API.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-28 23:52:00 -05:00

42 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { NextResponse } from "next/server";
import { requireAdminSession } from "~/lib/admin-auth";
import { PAY_DEFAULTS } from "@nomadro/pay";
/** Aggregate recent orders from payjsapi when available; otherwise return matrix stubs. */
export async function GET() {
if (!(await requireAdminSession())) {
return NextResponse.json({ ok: false, error: "unauthorized" }, { status: 401 });
}
const apiBase = (
process.env.NEXT_PUBLIC_PAYJSAPI_URL ||
process.env.PAYJSAPI_URL ||
PAY_DEFAULTS.payjsapiPublic
).replace(/\/$/, "");
const channels = [
{ id: "zpay", region: "cn", note: "国内 PC/H5" },
{ id: "xorpay", region: "cn", note: "微信内 H5 (xpay)" },
{ id: "creem", region: "overseas", note: "海外卡支付" },
{ id: "nowpayments", region: "overseas", note: "加密货币" },
{ id: "wx_virtual", region: "cn", note: "微信小程序虚拟支付" },
];
let upstream: { ok: boolean; detail?: string } = { ok: false };
try {
const res = await fetch(`${apiBase}/health`, { cache: "no-store" });
upstream = { ok: res.ok, detail: `HTTP ${res.status}` };
} catch (e) {
upstream = { ok: false, detail: e instanceof Error ? e.message : String(e) };
}
return NextResponse.json({
ok: true,
apiBase,
upstream,
channels,
items: [],
note: "订单明细来自各垂直 + payjsapi;此处先给渠道矩阵与网关探活。电子书订单见 /book/admin。",
});
}