Env-guarded so build stays green: /api/payments/[order_id]/deposit+release + /api/webhooks/stripe (lazy Stripe, 50/50 escrow, 501 until keys); /api/auth login|me|logout (HMAC signed-session scaffold, guarded dev login); lib/engine bridges edge->FastAPI (estimates defers to ENGINE_URL when set); components/embed for NocoDB/Metabase signed URLs; .env.example full inventory. tsc 0, build green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
25 lines
782 B
TypeScript
25 lines
782 B
TypeScript
// Bridge from the Vercel edge (Next route handlers) to the FastAPI data engine
|
|
// (services/api) running on the VPS. When ENGINE_URL is set, the edge defers to
|
|
// the engine as the single source of truth; otherwise it computes locally.
|
|
export function hasEngine(): boolean {
|
|
return Boolean(process.env.ENGINE_URL);
|
|
}
|
|
|
|
export async function engineFetch(path: string, init?: RequestInit): Promise<Response | null> {
|
|
const base = process.env.ENGINE_URL;
|
|
if (!base) return null;
|
|
try {
|
|
return await fetch(`${base}${path}`, {
|
|
...init,
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
"X-Internal-Token": process.env.INTERNAL_TOKEN ?? "",
|
|
...(init?.headers ?? {}),
|
|
},
|
|
cache: "no-store",
|
|
});
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|