28 lines
839 B
TypeScript
28 lines
839 B
TypeScript
export async function POST(req: Request) {
|
|
try {
|
|
const baseUrl = process.env.LEDGERONE_API_URL ?? "http://localhost:3051";
|
|
const payload = await req.text();
|
|
const res = await fetch(`${baseUrl}/api/transactions/manual`, {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: payload
|
|
});
|
|
const body = await res.text();
|
|
return new Response(body, {
|
|
status: res.status,
|
|
headers: {
|
|
"Content-Type": res.headers.get("content-type") ?? "application/json"
|
|
}
|
|
});
|
|
} catch {
|
|
return new Response(
|
|
JSON.stringify({
|
|
data: null,
|
|
meta: { timestamp: new Date().toISOString(), version: "v1" },
|
|
error: { message: "Backend unavailable." }
|
|
}),
|
|
{ status: 503, headers: { "Content-Type": "application/json" } }
|
|
);
|
|
}
|
|
}
|