Skip to content

これはポート 3000 でリッスンしている HTTP サーバーを起動します。すべてのリクエストにステータス 200 とボディ "Welcome to Bun!"Response でレスポンスします。

詳細については、Bun.serve を参照してください。

ts
const server = Bun.serve({
  port: 3000,
  fetch(request) {
    return new Response("Welcome to Bun!");
  },
});

console.log(`Listening on ${server.url}`);

Bun by www.bunjs.com.cn 編集