Skip to main content
StricJS 是一个用于构建高性能 Web 应用程序和 API 的 Bun 框架。
  • 快速 — Stric 是最快的 Bun 框架之一。详见基准测试了解更多信息。
  • 极简 — 像 @stricjs/router@stricjs/utils 这样的基本组件小于 50kB,且不需要外部依赖。
  • 可扩展 — Stric 包含插件系统、依赖注入,以及处理请求的可选优化。

使用 bun init 创建一个空项目。
terminal
mkdir myapp
cd myapp
bun init
bun add @stricjs/router @stricjs/utils

使用 StricJS 实现一个简单的 HTTP 服务器:
index.ts
import { Router } from "@stricjs/router";

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

/public 提供静态文件:
index.ts
import { dir } from "@stricjs/utils";

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

以监视模式运行文件以启动开发服务器。
terminal
bun --watch run index.ts

更多信息,请参见 Stric 的文档