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

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

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

* **快速** — Stric 是最快的 Bun 框架之一。详情请参见 [benchmark](https://github.com/bunsvr/benchmark)。
* **极简** — 基础组件如 `@stricjs/router` 和 `@stricjs/utils` 小于 50kB，并且不依赖外部库。
* **可扩展** — Stric 内置插件系统、依赖注入及可选的请求处理优化。

***

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

```bash terminal icon="terminal" theme={"theme":{"light":"github-light","dark":"dracula"}}
mkdir myapp
cd myapp
bun init
bun add @stricjs/router @stricjs/utils
```

***

使用 StricJS 实现一个 HTTP 服务器：

```ts index.ts icon="file-code" theme={"theme":{"light":"github-light","dark":"dracula"}}
import { Router } from "@stricjs/router";

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

***

从 `/public` 目录提供静态文件：

```ts index.ts icon="file-code" theme={"theme":{"light":"github-light","dark":"dracula"}}
import { dir } from "@stricjs/utils";

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

***

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

```bash terminal icon="terminal" theme={"theme":{"light":"github-light","dark":"dracula"}}
bun --watch run index.ts
```

***

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