style: update analyze API to use JSON body

This commit is contained in:
2026-05-14 08:12:37 +02:00
parent 503a1c8bde
commit 944a7280c9
2 changed files with 6 additions and 5 deletions
+5 -5
View File
@@ -2,9 +2,9 @@ import { OpenRouterClient } from "../../lib/openrouter";
import { TradingGraph } from "../../agents/tradingGraph";
export async function action({ request }: { request: Request }) {
const formData = await request.formData();
const ticker = formData.get("ticker") as string;
const date = formData.get("date") as string;
const body = await request.json();
const ticker = body.ticker?.toUpperCase();
const date = body.date || new Date().toISOString().split("T")[0];
if (!ticker) {
return Response.json({ error: "ticker is required" }, { status: 400 });
@@ -19,7 +19,7 @@ export async function action({ request }: { request: Request }) {
const graph = new TradingGraph(client);
const input = {
financialData: `Financial data for ${ticker} as of ${date || "latest"}`,
financialData: `Financial data for ${ticker} as of ${date}`,
technicalData: {
prices: [100, 102, 101, 103, 105],
sma: 102,
@@ -35,7 +35,7 @@ export async function action({ request }: { request: Request }) {
try {
const decision = await graph.propagate(ticker, input);
return Response.json({ decision, ticker, date });
return Response.json(decision);
} catch (error) {
const message = error instanceof Error ? error.message : "Unknown error";
return Response.json({ error: message }, { status: 500 });