GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(stats): route stats app · flcs/opencode@58da1ea

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • infra
    • stats.ts
  • packages
    • console/app/src/routes/stats
      • [...path].ts
      • index.ts
    • stats/app
      • src
        • app.tsx
        • routes
          • index.tsx
          • stats/api
            • health.ts
            • newsletter.ts
      • vite.config.ts
  • sst.config.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎infra/stats.ts‎

Copy file name to clipboardExpand all lines: infra/stats.ts
+10-9Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { lakeAthenaWorkgroup, lakeCatalog, lakeCluster, lakeQueryPermissions, lakeRegion, tableBucket } from "./lake"
2+
import { EMAILOCTOPUS_API_KEY } from "./app"
23

34
const domain = (() => {
45
if ($app.stage === "production") return "stats.opencode.ai"
@@ -163,15 +164,15 @@ new sst.x.DevCommand("StatsStudio", {
163164
// APP
164165
////////////////
165166

166-
// export const app = new sst.cloudflare.x.SolidStart("Stats", {
167-
// path: "packages/stats/app",
168-
// buildCommand: "bun run build",
169-
// domain,
170-
// link: [database],
171-
// environment: {
172-
// PUBLIC_URL: `https://${domain}`,
173-
// },
174-
// })
167+
export const app = new sst.cloudflare.x.SolidStart("Stats", {
168+
path: "packages/stats/app",
169+
buildCommand: "bun run build",
170+
domain,
171+
link: [database, EMAILOCTOPUS_API_KEY],
172+
environment: {
173+
PUBLIC_URL: `https://${domain}/stats`,
174+
},
175+
})
175176

176177
////////////////
177178
// SERVICES
Collapse file

‎packages/console/app/src/routes/stats/[...path].ts‎

Copy file name to clipboard
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import type { APIEvent } from "@solidjs/start/server"
2+
import { Resource } from "@opencode-ai/console-resource"
3+
4+
async function handler(evt: APIEvent) {
5+
const req = evt.request.clone()
6+
const url = new URL(req.url)
7+
const host = Resource.App.stage === "production" ? "stats.opencode.ai" : "stats.dev.opencode.ai"
8+
const targetUrl = `https://${host}${url.pathname}${url.search}`
9+
10+
return fetch(targetUrl, {
11+
method: req.method,
12+
headers: req.headers,
13+
body: req.body,
14+
})
15+
}
16+
17+
export const GET = handler
18+
export const POST = handler
19+
export const PUT = handler
20+
export const DELETE = handler
21+
export const OPTIONS = handler
22+
export const PATCH = handler
Collapse file

‎packages/console/app/src/routes/stats/index.ts‎

Copy file name to clipboard
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import type { APIEvent } from "@solidjs/start/server"
2+
import { Resource } from "@opencode-ai/console-resource"
3+
4+
async function handler(evt: APIEvent) {
5+
const req = evt.request.clone()
6+
const url = new URL(req.url)
7+
const host = Resource.App.stage === "production" ? "stats.opencode.ai" : "stats.dev.opencode.ai"
8+
const targetUrl = `https://${host}${url.pathname}${url.search}`
9+
10+
return fetch(targetUrl, {
11+
method: req.method,
12+
headers: req.headers,
13+
body: req.body,
14+
})
15+
}
16+
17+
export const GET = handler
18+
export const POST = handler
19+
export const PUT = handler
20+
export const DELETE = handler
21+
export const OPTIONS = handler
22+
export const PATCH = handler
Collapse file

‎packages/stats/app/src/app.tsx‎

Copy file name to clipboardExpand all lines: packages/stats/app/src/app.tsx
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ function AppMeta() {
1616
export default function App() {
1717
return (
1818
<Router
19+
base={import.meta.env.BASE_URL.replace(/\/$/, "")}
1920
explicitLinks={true}
2021
root={(props) => (
2122
<MetaProvider>
Collapse file

‎packages/stats/app/src/routes/index.tsx‎

Copy file name to clipboardExpand all lines: packages/stats/app/src/routes/index.tsx
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,7 @@ function Header() {
12131213
return (
12141214
<header data-component="top" data-menu-open={menuOpen() ? "true" : undefined}>
12151215
<div data-slot="header-bar">
1216-
<a data-slot="brand" href="/" aria-label="OpenCode home">
1216+
<a data-slot="brand" href={import.meta.env.BASE_URL} aria-label="Stats home">
12171217
<StatsWordmark />
12181218
</a>
12191219
<nav data-component="section-nav" aria-label="Stats sections">
@@ -1436,7 +1436,7 @@ function SubscribeModal(props: { onClose: () => void }) {
14361436
event.preventDefault()
14371437
setStatus("pending")
14381438
setMessage("")
1439-
fetch("/api/newsletter", {
1439+
fetch(`${import.meta.env.BASE_URL}api/newsletter`, {
14401440
method: "POST",
14411441
body: new FormData(event.currentTarget),
14421442
}).then(
Collapse file

‎packages/stats/app/src/routes/stats/api/health.ts‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { GET } from "../../api/health"
Collapse file

‎packages/stats/app/src/routes/stats/api/newsletter.ts‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { POST } from "../../api/newsletter"
Collapse file

‎packages/stats/app/vite.config.ts‎

Copy file name to clipboardExpand all lines: packages/stats/app/vite.config.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { nitro } from "nitro/vite"
33
import { defineConfig, type PluginOption } from "vite"
44

55
export default defineConfig({
6+
base: "/stats/",
67
plugins: [
78
solidStart() as PluginOption,
89
nitro({
Collapse file

‎sst.config.ts‎

Copy file name to clipboardExpand all lines: sst.config.ts
+2-5Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ export default $config({
3030
async run() {
3131
const stage = await import("./infra/stage.js")
3232
await import("./infra/app.js")
33-
if (stage.deployAws) {
34-
await import("./infra/lake.js")
35-
await import("./infra/stats.js")
36-
}
33+
const stats = stage.deployAws ? await import("./infra/lake.js").then(() => import("./infra/stats.js")) : undefined
3734
const { stat } = await import("./infra/console.js")
3835
await import("./infra/enterprise.js")
3936
if ($app.stage === "production" || $app.stage === "vimtor") {
@@ -42,7 +39,7 @@ export default $config({
4239

4340
return {
4441
StatWorkerUrl: stat.url,
45-
// StatsUrl: stats.app.url,
42+
...(stats ? { StatsUrl: stats.app.url } : {}),
4643
AwsStage: stage.awsStage,
4744
}
4845
},

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.