bun-http-server

仓库创建 2025年11月8日最近提交 29 天前SkillHot 收录 22 天前
▸ 精选理由

适合用 Bun 作为运行时的开发者,示例直接可用。

这个 Skill 做什么

介绍如何使用 Bun.serve 快速构建高性能 HTTP 服务。

用 Bun.serve 能以极少代码起一个高性能的 HTTP 服务,适合做路由、REST API 或 fetch 处理器的快速原型和生产服务。API 简单、延迟低,写个几行 TypeScript 就能跑起来,方便在本地开发或作为轻量后端部署。性能是亮点,路由和请求处理逻辑可灵活扩展。

▸ 展开 SKILL.md 英文原文

Use when building HTTP servers with Bun.serve, handling requests/responses, implementing routing, creating REST APIs, or configuring fetch handlers.

开发编程BunHTTP路由服务通用
180
Stars
28
Forks
40
仓库内 Skill
+0
7 日增星
安装 / 使用
给你的 Agent 一句话(通用)
帮我安装这个 skill:https://raw.githubusercontent.com/secondsky/claude-skills/main/plugins/bun/skills/bun-http-server/SKILL.md
或 curl 直取 SKILL.md
curl -fsSL "https://raw.githubusercontent.com/secondsky/claude-skills/main/plugins/bun/skills/bun-http-server/SKILL.md"
SKILL.MD 节选查看完整文件 ↗
# Bun HTTP Server

Bun has a built-in high-performance HTTP server via `Bun.serve()`.

## Quick Start

```typescript
const server = Bun.serve({
  port: 3000,
  fetch(req) {
    return new Response("Hello World!");
  },
});

console.log(`Server running at http://localhost:${server.port}`);
```

## Request Handling

```typescript
Bun.serve({
  fetch(req) {
    const url = new URL(req.url);

    // Method
    console.log(req.method); // GET, POST, etc.

    // Path
    console.log(url.pathname); // /api/users

    // Query params
    console.log(url.searchParams.get("id")); // ?id=123

    // Headers
    console.log(req.headers.get("Content-Type"));

    return new Response("OK");
  },
});
```
via SKILL·HOT · 数据来自 GitHub 公开信息 · 原文版权归作者所有