diff --git a/infra/stats.ts b/infra/stats.ts index 28d50fe0e3..107e8b9f23 100644 --- a/infra/stats.ts +++ b/infra/stats.ts @@ -1,4 +1,5 @@ import { lakeAthenaWorkgroup, lakeCatalog, lakeCluster, lakeQueryPermissions, lakeRegion, tableBucket } from "./lake" +import { EMAILOCTOPUS_API_KEY } from "./app" const domain = (() => { if ($app.stage === "production") return "stats.opencode.ai" @@ -163,15 +164,15 @@ new sst.x.DevCommand("StatsStudio", { // APP //////////////// -// export const app = new sst.cloudflare.x.SolidStart("Stats", { -// path: "packages/stats/app", -// buildCommand: "bun run build", -// domain, -// link: [database], -// environment: { -// PUBLIC_URL: `https://${domain}`, -// }, -// }) +export const app = new sst.cloudflare.x.SolidStart("Stats", { + path: "packages/stats/app", + buildCommand: "bun run build", + domain, + link: [database, EMAILOCTOPUS_API_KEY], + environment: { + PUBLIC_URL: `https://${domain}/stats`, + }, +}) //////////////// // SERVICES diff --git a/packages/console/app/src/routes/stats/[...path].ts b/packages/console/app/src/routes/stats/[...path].ts new file mode 100644 index 0000000000..326ff2c117 --- /dev/null +++ b/packages/console/app/src/routes/stats/[...path].ts @@ -0,0 +1,22 @@ +import type { APIEvent } from "@solidjs/start/server" +import { Resource } from "@opencode-ai/console-resource" + +async function handler(evt: APIEvent) { + const req = evt.request.clone() + const url = new URL(req.url) + const host = Resource.App.stage === "production" ? "stats.opencode.ai" : "stats.dev.opencode.ai" + const targetUrl = `https://${host}${url.pathname}${url.search}` + + return fetch(targetUrl, { + method: req.method, + headers: req.headers, + body: req.body, + }) +} + +export const GET = handler +export const POST = handler +export const PUT = handler +export const DELETE = handler +export const OPTIONS = handler +export const PATCH = handler diff --git a/packages/console/app/src/routes/stats/index.ts b/packages/console/app/src/routes/stats/index.ts new file mode 100644 index 0000000000..326ff2c117 --- /dev/null +++ b/packages/console/app/src/routes/stats/index.ts @@ -0,0 +1,22 @@ +import type { APIEvent } from "@solidjs/start/server" +import { Resource } from "@opencode-ai/console-resource" + +async function handler(evt: APIEvent) { + const req = evt.request.clone() + const url = new URL(req.url) + const host = Resource.App.stage === "production" ? "stats.opencode.ai" : "stats.dev.opencode.ai" + const targetUrl = `https://${host}${url.pathname}${url.search}` + + return fetch(targetUrl, { + method: req.method, + headers: req.headers, + body: req.body, + }) +} + +export const GET = handler +export const POST = handler +export const PUT = handler +export const DELETE = handler +export const OPTIONS = handler +export const PATCH = handler diff --git a/packages/stats/app/src/app.tsx b/packages/stats/app/src/app.tsx index 3a356119b0..976633f295 100644 --- a/packages/stats/app/src/app.tsx +++ b/packages/stats/app/src/app.tsx @@ -16,6 +16,7 @@ function AppMeta() { export default function App() { return ( ( diff --git a/packages/stats/app/src/routes/index.tsx b/packages/stats/app/src/routes/index.tsx index 0b1a801e7c..5ee4f5f2ec 100644 --- a/packages/stats/app/src/routes/index.tsx +++ b/packages/stats/app/src/routes/index.tsx @@ -1213,7 +1213,7 @@ function Header() { return (
- +