Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions web/bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"devDependencies": {
"@jest/globals": "^30.2.0",
"@jest/types": "^30.2.0",
"@types/bun": "^1.2.23",
"@types/bun": "^1.3.1",
"@types/jest": "^30.0.0",
"@types/sigmajs": "^1.0.32",
"eslint-config-prettier": "^10.1.8",
Expand Down Expand Up @@ -169,7 +169,7 @@

"@sinonjs/fake-timers": ["@sinonjs/[email protected]", "", { "dependencies": { "@sinonjs/commons": "^3.0.1" } }, "sha512-36/hTbH2uaWuGVERyC6da9YwGWnzUZXuPro/F2LfsdOsLnCojz/iSH8MxUt/FD2S5XBSVPhmArFUXcpCQ2Hkiw=="],

"@types/bun": ["@types/bun@1.2.23", "", { "dependencies": { "bun-types": "1.2.23" } }, "sha512-le8ueOY5b6VKYf19xT3McVbXqLqmxzPXHsQT/q9JHgikJ2X22wyTW3g3ohz2ZMnp7dod6aduIiq8A14Xyimm0A=="],
"@types/bun": ["@types/bun@1.3.1", "", { "dependencies": { "bun-types": "1.3.1" } }, "sha512-4jNMk2/K9YJtfqwoAa28c8wK+T7nvJFOjxI4h/7sORWcypRNxBpr+TPNaCfVWq70tLCJsqoFwcf0oI0JU/fvMQ=="],

"@types/estree": ["@types/[email protected]", "", {}, "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw=="],

Expand Down Expand Up @@ -245,7 +245,7 @@

"bser": ["[email protected]", "", { "dependencies": { "node-int64": "^0.4.0" } }, "sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ=="],

"bun-types": ["bun-types@1.2.23", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-R9f0hKAZXgFU3mlrA0YpE/fiDvwV0FT9rORApt2aQVWSuJDzZOyB5QLc0N/4HF57CS8IXJ6+L5E4W1bW6NS2Aw=="],
"bun-types": ["bun-types@1.3.1", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-NMrcy7smratanWJ2mMXdpatalovtxVggkj11bScuWuiOoXTiKIu2eVS1/7qbyI/4yHedtsn175n4Sm4JcdHLXw=="],

"callsites": ["[email protected]", "", {}, "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ=="],

Expand Down
2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"devDependencies": {
"@jest/globals": "^30.2.0",
"@jest/types": "^30.2.0",
"@types/bun": "^1.2.23",
"@types/bun": "^1.3.1",
"@types/jest": "^30.0.0",
"@types/sigmajs": "^1.0.32",
"eslint-config-prettier": "^10.1.8",
Expand Down
2 changes: 1 addition & 1 deletion web/src/bun/develop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ serve({
port: PORT,
development: { hmr: false },

static: {
routes: {
"/": index,
"/chat": chat,
},
Comment on lines +34 to 37
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

While renaming static to routes is correct for the updated @types/bun dependency, the overall routing logic is split between this routes object and the fetch handler that follows. This can be confusing to maintain.

Furthermore, the current fetch handler appears to have a bug where it doesn't serve static assets like enola.css (referenced in index.html), which will result in a 404 error and cause pages to render incorrectly.

To improve clarity and fix this bug, I recommend consolidating all routing logic within an async fetch handler. This centralizes routing and makes it easier to manage static assets.

Here's an example of how you could refactor the serve call:

serve({
  port: PORT,
  development: { hmr: false },

  async fetch(req) {
    const path = new URL(req.url).pathname;

    if (IGNORE.includes(path)) {
      return new Response("🪹 No Content ", { status: 204 });
    }

    switch (path) {
      case "/":
        return new Response(index);
      case "/chat":
        return new Response(chat);
    }

    // Serve other static files from the public directory
    const publicPath = `./public${path}`;
    const publicFile = file(publicPath);
    if (await publicFile.exists()) {
      return new Response(publicFile);
    }

    return new Response("🙅🏽‍♀️ Not Found", { status: 404 });
  },
});

This approach removes the routes object and handles all paths within fetch, including serving any existing file from the ./public directory, which would fix the issue with missing static assets.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CSS actually works just fine (I've tested it).

Expand Down
Loading