編集

Bun v1.1.44

Bun v1.1.44 がリリースされた。

https://bun.sh/blog/bun-v1.1.44

HTML Imports が組み込まれフルスタックの開発サーバとして利用できるようになった。

js
import homepage from "./index.html";

Bun.serve({
  static: {
    "/": homepage,
  },
  development: true,
  async fetch(req) {
    if (req.url.endsWith("/api/users")) {
      const users = await Bun.sql`SELECT * FROM users`;
      return Response.json(users);
    }
    return new Response("Not Found", { status: 404 });
  },
});
編集