From 49cce47f4cfed28a11e1c30594ff8a8f1e6a03a6 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Mon, 16 Jun 2025 10:34:19 -0700 Subject: [PATCH] fix startup --- main.ts | 2 +- package.json | 2 +- packages/http/package.json | 3 ++- packages/http/src/server.tsx | 4 +++- packages/shared/src/kv.ts | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/main.ts b/main.ts index c3156d7..c214fdc 100644 --- a/main.ts +++ b/main.ts @@ -3,4 +3,4 @@ import { spawn } from "bun" const run = (cmd: string[]) => spawn(cmd, { stdout: "inherit", stderr: "inherit" }).exited -await Promise.all([run(["bun", "http"]), run(["bun", "bot:discord"])]) +await Promise.all([run(["bun", "bot:discord"]), run(["bun", "http"])]) diff --git a/package.json b/package.json index 01750b7..73d167f 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "semi": false }, "scripts": { - "http": "bun run --filter=@the-rabbit-hole/http dev", + "http": "bun run --filter=@the-rabbit-hole/http start", "bot:cli": "bun run --filter=@the-rabbit-hole/spike bot:cli", "bot:discord": "bun run --filter=@the-rabbit-hole/spike bot:discord", "start": "bun run main.ts" diff --git a/packages/http/package.json b/packages/http/package.json index 86f6dd3..0c97ccc 100644 --- a/packages/http/package.json +++ b/packages/http/package.json @@ -4,7 +4,8 @@ "type": "module", "private": true, "scripts": { - "dev": "bun run --hot src/server" + "dev": "bun run --hot src/server", + "start": "bun run src/server" }, "prettier": { "printWidth": 110, diff --git a/packages/http/src/server.tsx b/packages/http/src/server.tsx index c43f55d..c14fec1 100644 --- a/packages/http/src/server.tsx +++ b/packages/http/src/server.tsx @@ -2,7 +2,7 @@ import { serve } from "bun" import { nanoRemix } from "@the-rabbit-hole/nano-remix" import { join } from "node:path" -serve({ +const server = serve({ routes: { "/*": (req) => nanoRemix(req, { routesDir: join(import.meta.dir, "routes") }), }, @@ -12,3 +12,5 @@ serve({ console: true, }, }) + +console.log(`🤖 Server running at ${server.url}`) diff --git a/packages/shared/src/kv.ts b/packages/shared/src/kv.ts index f043ba5..beb88e7 100644 --- a/packages/shared/src/kv.ts +++ b/packages/shared/src/kv.ts @@ -82,7 +82,7 @@ const writeStore = (store: Record): void => { } const getStorePath = (): string => { - const rootDir = join(import.meta.dir, "..") + const rootDir = process.env.DATA_DIR ?? join(import.meta.dir, "..") const store = join(rootDir, "data/kv.json") return store }