> ## Documentation Index
> Fetch the complete documentation index at: https://bun.ll1025.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 使用 StricJS 和 Bun 构建 HTTP 服务器

[StricJS](https://github.com/bunsvr) 是一个用于构建高性能 Web 应用和 API 的 Bun 框架。

* **快速** — Stric 是最快的 Bun 框架之一。参见[基准测试](https://github.com/bunsvr/benchmark)。
* **极简** — 核心组件如 `@stricjs/router` 和 `@stricjs/utils` 体积小于 50kB，且无需外部依赖。
* **可扩展** — Stric 包含插件系统、依赖注入和用于处理请求的可选优化。

***

使用 `bun init` 创建一个空项目。

```bash terminal icon="terminal" theme={null}
mkdir myapp
cd myapp
bun init
bun add @stricjs/router @stricjs/utils
```

***

要使用 StricJS 实现 HTTP 服务器：

```ts index.ts icon="file-code" theme={null}
import { Router } from "@stricjs/router";

export default new Router().get("/", () => new Response("Hi"));
```

***

要从 `/public` 提供静态文件：

```ts index.ts icon="file-code" theme={null}
import { dir } from "@stricjs/utils";

export default new Router().get("/", () => new Response("Hi")).get("/*", dir("./public"));
```

***

使用监视模式运行文件以启动开发服务器。

```bash terminal icon="terminal" theme={null}
bun --watch run index.ts
```

***

更多信息，请参见 Stric 的[文档](https://stricjs.netlify.app)。
