Elysia 是一个以 Bun 为首要目标的 Web 框架,构建于 Bun 的 HTTP、文件系统和热重载 API 之上。使用 bun create 开始使用。
terminal
bun create elysia myappcd myappbun run dev
要定义一个 HTTP 路由并使用 Elysia 启动服务器:
server.ts
import { Elysia } from "elysia";const app = new Elysia().get("/", () => "Hello Elysia").listen(8080);console.log(`🦊 Elysia is running on port ${app.server?.port}...`);
Elysia 是一个具有类似 Express 的语法、类型推断、中间件、文件上传功能以及用于 JWT 身份验证和 OpenAPI 文档的插件的服务器框架。它是速度最快的 Bun Web 框架之一。请参阅 Elysia 的文档。
{"docsConfig":{"theme":"aspen","$schema":"https://mintlify.com/docs.json","name":"Bun 中文文档","colors":{"primary":"#ff73a8","light":"#ff73a8","dark":"#ff73a8"},"logo":{"light":"/logo/logo-with-wordmark-dark.svg","dark":"/logo/logo-with-wordmark-light.svg"},"favicon":"/logo/bun.png","appearance":{"default":"system"},"background":{"decoration":"gradient"},"navbar":{"links":[{"icon":"download","href":"/installation","label":"安装 Bun"}]},"footer":{"socials":{"x":"https://x.com/bunjavascript","github":"https://github.com/oven-sh/bun","discord":"https://bun.com/discord","youtube":"https://www.youtube.com/@bunjs"}},"seo":{"metatags":{"canonical":"https://bun.zhcndoc.com"}},"icons":{"library":"lucide"},"styling":{"codeblocks":{"theme":{"light":"github-light","dark":"dracula"}}},"contextual":{"options":["copy","view","claude","mcp","vscode"],"display":"header"},"integrations":{"telemetry":{"enabled":false}},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"hasAudioNarration":false,"customDomains":[],"gitSource":{"type":"github","owner":"local","repo":"local","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":"local","isBase":true},"buildId":"local","clientVersion":"0.0.4050"},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[],"googleFontsInlined":false,"isLoggedInCli":false,"mintExport":{}},"customCss":[{"filePath":"style.css","content":".steps{margin-top:0}div[data-component-part=card-icon]>svg{mask-size:80%}.font-mono{font-weight:700!important}.nav-tabs .nav-tabs-item{font-size:.8rem!important}.mdx-content>span[data-as=p]{margin-bottom:2rem!important}.dark\\:bg-white\\/5:is(.dark *){background-color:rgb(155 155 155/5%)}ul#sidebar-group>li>a{font-size:.825rem;line-height:1rem;font-weight:500}pre.shiki{line-height:1.4rem;font-size:.8rem}.dark\\:ring-white\\/\\[0\\.14\\]:is(.dark *){border:1px solid rgb(255 255 255/.14)!important;--tw-ring-color:transparent}.ring-transparent{border:1px solid transparent!important}.code-block:has([data-component-part=code-block-header]) div[data-component-part=code-block-root],.code-group:has([data-component-part=code-group-tab-bar]) div[data-component-part=code-block-root]{border-top-right-radius:0!important;border-top-left-radius:0!important}div[data-component-part=card-icon] img,img.code-block-icon{background:0 0!important}html.dark .card-group .card:not(:hover){border:1px solid rgb(255 255 255/.1)!important}html:not(.dark) .card-group .card{border:1px solid rgb(var(--gray-200))!important}.dark div[data-component-part=card-content-container]{background:rgb(255 255 255/.03)}.card:hover{border-color:rgb(var(--gray-400)/var(--tw-border-opacity))!important}html.dark .shiki,html.dark .shiki span{background-color:transparent!important}.prose :where(hr):not(:where([class~=\"not-prose\"], [class~=\"not-prose\"] *)){margin-top:2rem!important;margin-bottom:2rem!important}.nav-tabs{width:100%!important}a[href=\"/docs/guides\"],a[href=\"/guides\"]{margin-left:auto!important}div[data-component-part=card-content-container]{height:100%!important}div#guides-list div[data-component-part=card-content-container]>:nth-child(2){height:100%;display:flex;flex-direction:column;justify-content:space-between!important}.code-block+.code-block[language=text]{margin-top:-32px;z-index:-1;border-top-right-radius:0;border-top-left-radius:0;border-top:none}.code-block+.code-block[language=text],.code-block+.code-block[language=text] div[data-component-part=code-block-root]{background-color:rgb(var(--gray-50))!important}html.dark .code-block+.code-block[language=text],html.dark .code-block+.code-block[language=text] div[data-component-part=code-block-root]{background-color:#16171e!important}.code-block+.code-block[language=text] div.absolute.top-3{display:none}.code-block:has(+.code-block[language=text]),.code-block:has(+.code-block[language=text]) div[data-component-part=code-block-root]{border-bottom-right-radius:0;border-bottom-left-radius:0}div.callout .code-block{margin-bottom:0}[language=shellscript] code span.line:not(:empty):has(span)::before{content:\"$ \";color:#6272a4;user-select:none}[language=powershell] code span.line:has(>span:first-child[style*=\"#6272A4\"])::before,[language=powershell] code span.line:has(>span:first-child[style*=\"color: rgb(98, 114, 164)\"])::before,[language=shellscript] code span.line:has(>span:first-child[style*=\"#6272A4\"])::before,[language=shellscript] code span.line:has(>span:first-child[style*=\"color: rgb(98, 114, 164)\"])::before{content:\"\"}[language=powershell] code span.line:not(:empty):has(span)::before{content:\"> \";color:#6272a4;user-select:none}.dark [data-component-part=code-block-root]:not(.has-line-numbers) .line-highlight,.dark [data-component-part=code-block-root]:not(.has-line-numbers) .line-highlight:after,.dark [data-component-part=code-block-root]:not(.has-line-numbers) .line-highlight:before{background:rgb(219 219 219/20%)!important}.dark[data-component-part=code-block-root]:not(.has-line-numbers) .line-highlight:before{border-color:#fff}[data-component-part=code-block-root]:not(.has-line-numbers) .line-highlight,[data-component-part=code-block-root]:not(.has-line-numbers) .line-highlight:after,[data-component-part=code-block-root]:not(.has-line-numbers) .line-highlight:before{background:rgb(var(--gray-200)/.5)!important}[data-component-part=code-block-root]:not(.has-line-numbers) .line-highlight:before{border-color:#acacac}"}],"page":{"pagePath":"guides/ecosystem/elysia","slug":"/guides/ecosystem/elysia","pageMetadata":{"title":"使用 Elysia 和 Bun 构建 HTTP 服务器","sidebarTitle":"Elysia 与 Bun","mode":"center","href":"/guides/ecosystem/elysia"},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,hr:`hr`,p:`p`,pre:`pre`,span:`span`,..._provideComponents(),...props.components},{CodeBlock}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[_jsx(_components.a,{href:`https://elysiajs.com`,children:`Elysia`}),` 是一个以 Bun 为首要目标的 Web 框架,构建于 Bun 的 HTTP、文件系统和热重载 API 之上。使用 `,_jsx(_components.code,{children:`bun create`}),` 开始使用。`]}),`\n`,_jsx(CodeBlock,{filename:`terminal`,icon:`terminal`,numberOfLines:`3`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light dracula`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#282A36`,color:`#24292e`,\"--shiki-dark\":`#F8F8F2`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#50FA7B`},children:`bun`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#F1FA8C`},children:` create`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#F1FA8C`},children:` elysia`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#F1FA8C`},children:` myapp`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#8BE9FD`},children:`cd`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#F1FA8C`},children:` myapp`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#50FA7B`},children:`bun`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#F1FA8C`},children:` run`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#F1FA8C`},children:` dev`})]}),`\n`]})})}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(_components.p,{children:`要定义一个 HTTP 路由并使用 Elysia 启动服务器:`}),`\n`,_jsx(CodeBlock,{filename:`server.ts`,icon:`/icons/typescript.svg`,numberOfLines:`5`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light dracula`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#282A36`,color:`#24292e`,\"--shiki-dark\":`#F8F8F2`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#FF79C6`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F8F8F2`},children:` { Elysia } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#FF79C6`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#E9F284`},children:` \"`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#F1FA8C`},children:`elysia`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#E9F284`},children:`\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F8F8F2`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#FF79C6`},children:`const`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#F8F8F2`},children:` app`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#FF79C6`},children:` =`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-light-font-weight\":`inherit`,\"--shiki-dark\":`#FF79C6`,\"--shiki-dark-font-weight\":`bold`},children:` new`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#50FA7B`},children:` Elysia`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F8F8F2`},children:`().`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#50FA7B`},children:`get`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F8F8F2`},children:`(`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#E9F284`},children:`\"`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#F1FA8C`},children:`/`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#E9F284`},children:`\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F8F8F2`},children:`, () `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#FF79C6`},children:`=>`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#E9F284`},children:` \"`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#F1FA8C`},children:`Hello Elysia`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#E9F284`},children:`\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F8F8F2`},children:`).`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#50FA7B`},children:`listen`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F8F8F2`},children:`(`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#BD93F9`},children:`8080`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F8F8F2`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F8F8F2`},children:`console.`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#50FA7B`},children:`log`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F8F8F2`},children:`(`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#F1FA8C`},children:\"`🦊 Elysia is running on port \"}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#FF79C6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F8F8F2`},children:`app`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#F8F8F2`},children:`.`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F8F8F2`},children:`server`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#F8F8F2`},children:`?.`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F8F8F2`},children:`port`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#FF79C6`},children:`}`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#F1FA8C`},children:\"...`\"}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F8F8F2`},children:`);`})]}),`\n`]})})}),`\n`,_jsx(_components.hr,{}),`\n`,_jsxs(_components.p,{children:[`Elysia 是一个具有类似 Express 的语法、类型推断、中间件、文件上传功能以及用于 JWT 身份验证和 OpenAPI 文档的插件的服务器框架。它是`,_jsx(_components.a,{href:`https://github.com/SaltyAom/bun-http-framework-benchmark`,children:`速度最快的 Bun Web 框架`}),`之一。`]}),`\n`,_jsxs(_components.p,{children:[`请参阅 Elysia 的`,_jsx(_components.a,{href:`https://elysiajs.com/quick-start.html`,children:`文档`}),`。`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"codeStyling":{"theme":{"light":"github-light","dark":"dracula"}},"config":{},"pageMetadata":{"title":"使用 Elysia 和 Bun 构建 HTTP 服务器","sidebarTitle":"Elysia 与 Bun","mode":"center","href":"/guides/ecosystem/elysia"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[],"codeExamples":{}},"jsLinks":["/_mintlify/custom/localhost/71a8c2a91b354e86/normalize-internal-links.js","/_mintlify/custom/localhost/5b9ba7e549301f2f/zhcndoc.js"],"subdomain":"localhost","siteName":"Bun 中文文档","title":"使用 Elysia 和 Bun 构建 HTTP 服务器 - Bun 中文文档","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"originalFileLocation":"guides/ecosystem/elysia.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"application-name\" content=\"Bun 中文文档\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/favicons/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/favicons/favicon-32x32.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/favicons/favicon-16x16.png\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicons/favicon.ico\">\u003cmeta data-mint-head property=\"og:title\" content=\"使用 Elysia 和 Bun 构建 HTTP 服务器 - Bun 中文文档\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Bun 中文文档\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://bun.zhcndoc.com/guides/ecosystem/elysia\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"使用 Elysia 和 Bun 构建 HTTP 服务器 - Bun 中文文档\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/favicons/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Bun 中文文档\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#ff73a8\">\u003clink data-mint-head rel=\"canonical\" href=\"https://bun.zhcndoc.com/guides/ecosystem/elysia\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/guides/ecosystem/elysia.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Bun 中文文档\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"Bun 中文文档","nav":{"tabs":[{"tab":"运行时","icon":"cog","pages":[{"title":"运行时","href":""}]},{"tab":"包管理器","icon":"box","pages":[{"title":"包管理器","href":"/pm/cli/install"}]},{"tab":"打包器","icon":"combine","pages":[{"title":"打包器","href":"/bundler"}]},{"tab":"测试运行器","icon":"flask-conical","pages":[{"title":"测试运行器","href":"/test"}]},{"tab":"指南","icon":"map","groups":[{"group":"概述","icon":"globe","pages":[{"title":"指南","mode":"center","href":"/guides"}]},{"group":"部署","icon":"rocket","pages":[{"title":"在 Vercel 上部署 Bun 应用","sidebarTitle":"在 Vercel 上部署","mode":"center","href":"/guides/deployment/vercel"},{"title":"在 Railway 上部署 Bun 应用","sidebarTitle":"在 Railway 上部署","mode":"center","href":"/guides/deployment/railway"},{"title":"在 Render 上部署 Bun 应用","sidebarTitle":"在 Render 上部署","mode":"center","href":"/guides/deployment/render"},{"title":"在 AWS Lambda 上部署 Bun 应用","sidebarTitle":"在 AWS Lambda 上部署","mode":"center","href":"/guides/deployment/aws-lambda"},{"title":"在 DigitalOcean 上部署 Bun 应用","sidebarTitle":"在 DigitalOcean 上部署","mode":"center","href":"/guides/deployment/digital-ocean"},{"title":"在 Google Cloud Run 上部署 Bun 应用","sidebarTitle":"在 Google Cloud Run 上部署","mode":"center","href":"/guides/deployment/google-cloud-run"}]},{"group":"运行时与调试","icon":"bug","pages":[{"title":"为 Bun 安装 TypeScript 声明文件","sidebarTitle":"TypeScript 类型","mode":"center","href":"/guides/runtime/typescript"},{"title":"重新映射导入路径","sidebarTitle":"重新映射导入路径","mode":"center","href":"/guides/runtime/tsconfig-paths"},{"title":"使用 VS Code 扩展调试 Bun","sidebarTitle":"VS Code 调试器","mode":"center","href":"/guides/runtime/vscode-debugger"},{"title":"使用网页调试器调试 Bun","sidebarTitle":"网页调试器","mode":"center","href":"/guides/runtime/web-debugger"},{"title":"使用 V8 堆快照检查内存使用情况","sidebarTitle":"堆快照","mode":"center","href":"/guides/runtime/heap-snapshot"},{"title":"使用 --define 实现构建时常量","sidebarTitle":"构建时常量","mode":"center","href":"/guides/runtime/build-time-constants"},{"title":"定义并替换静态全局变量和常量","sidebarTitle":"定义常量","mode":"center","href":"/guides/runtime/define-constant"},{"title":"在 GitHub Actions 中安装并运行 Bun","sidebarTitle":"GitHub Actions","mode":"center","href":"/guides/runtime/cicd"},{"title":"在 macOS 上为单文件 JavaScript 可执行文件进行代码签名","sidebarTitle":"macOS 上的代码签名","mode":"center","href":"/guides/runtime/codesign-macos-executable"}]},{"group":"实用工具","icon":"wrench","pages":[{"title":"将 Bun 升级到最新版本","sidebarTitle":"升级 Bun","mode":"center","href":"/guides/util/upgrade"},{"title":"检测代码何时在 Bun 中执行","sidebarTitle":"检测 Bun","mode":"center","href":"/guides/util/detect-bun"},{"title":"获取当前 Bun 版本","sidebarTitle":"获取 Bun 版本","mode":"center","href":"/guides/util/version"},{"title":"密码哈希","sidebarTitle":"密码哈希","mode":"center","href":"/guides/util/hash-a-password"},{"title":"生成 UUID","sidebarTitle":"生成 UUID","mode":"center","href":"/guides/util/javascript-uuid"},{"title":"编码和解码 base64 数据","sidebarTitle":"Base64 编码","mode":"center","href":"/guides/util/base64"},{"title":"使用 gzip 压缩和解压数据","sidebarTitle":"Gzip 压缩","mode":"center","href":"/guides/util/gzip"},{"title":"使用 DEFLATE 进行数据压缩和解压","sidebarTitle":"DEFLATE 压缩","mode":"center","href":"/guides/util/deflate"},{"title":"转义 HTML 字符串","sidebarTitle":"转义 HTML","mode":"center","href":"/guides/util/escape-html"},{"title":"检查两个对象是否深度相等","sidebarTitle":"深度相等","mode":"center","href":"/guides/util/deep-equals"},{"title":"固定毫秒数的休眠","sidebarTitle":"休眠","mode":"center","href":"/guides/util/sleep"},{"title":"将文件 URL 转换为绝对路径","sidebarTitle":"文件 URL 转路径","mode":"center","href":"/guides/util/file-url-to-path"},{"title":"将绝对路径转换为文件 URL","sidebarTitle":"路径转文件 URL","mode":"center","href":"/guides/util/path-to-file-url"},{"title":"获取可执行二进制文件的路径","sidebarTitle":"查找可执行文件路径","mode":"center","href":"/guides/util/which-path-to-executable-bin"},{"title":"获取当前文件的目录","sidebarTitle":"import.meta.dir","mode":"center","href":"/guides/util/import-meta-dir"},{"title":"获取当前文件的文件名","sidebarTitle":"import.meta.file","mode":"center","href":"/guides/util/import-meta-file"},{"title":"获取当前文件的绝对路径","sidebarTitle":"import.meta.path","mode":"center","href":"/guides/util/import-meta-path"},{"title":"检查当前文件是否为入口点","sidebarTitle":"检查入口点","mode":"center","href":"/guides/util/entrypoint"},{"title":"获取当前入口文件的绝对路径","sidebarTitle":"获取入口文件路径","mode":"center","href":"/guides/util/main"}]},{"group":"生态系统与框架","icon":"puzzle","pages":[{"title":"使用 Astro 和 Bun 构建应用","sidebarTitle":"Astro 与 Bun","mode":"center","href":"/guides/ecosystem/astro"},{"title":"创建一个 Discord 机器人","sidebarTitle":"使用 Bun 的 Discord.js","mode":"center","href":"/guides/ecosystem/discordjs"},{"title":"使用 Docker 容器化 Bun 应用程序","sidebarTitle":"使用 Docker 的 Bun","mode":"center","href":"/guides/ecosystem/docker"},{"title":"在 Bun 中使用 Drizzle ORM","sidebarTitle":"Drizzle 与 Bun","mode":"center","href":"/guides/ecosystem/drizzle"},{"title":"在 Bun 中使用 Gel","sidebarTitle":"Gel 与 Bun","mode":"center","href":"/guides/ecosystem/gel"},{"title":"使用 Elysia 和 Bun 构建 HTTP 服务器","sidebarTitle":"Elysia 与 Bun","mode":"center","href":"/guides/ecosystem/elysia"},{"title":"使用 Express 和 Bun 构建 HTTP 服务器","sidebarTitle":"Express 与 Bun","mode":"center","href":"/guides/ecosystem/express"},{"title":"使用 Hono 和 Bun 构建 HTTP 服务器","sidebarTitle":"Hono 与 Bun","mode":"center","href":"/guides/ecosystem/hono"},{"title":"使用 Mongoose 和 Bun 读写 MongoDB 数据","sidebarTitle":"Mongoose 与 Bun","mode":"center","href":"/guides/ecosystem/mongoose"},{"title":"使用 Drizzle ORM 连接 Neon Postgres","sidebarTitle":"使用 Bun 的 Neon Drizzle","mode":"center","href":"/guides/ecosystem/neon-drizzle"},{"title":"使用 Neon 的无服务器 Postgres 结合 Bun","sidebarTitle":"Neon 无服务器 Postgres 与 Bun","mode":"center","href":"/guides/ecosystem/neon-serverless-postgres"},{"title":"使用 Next.js 和 Bun 构建应用","sidebarTitle":"Next.js 与 Bun","mode":"center","href":"/guides/ecosystem/nextjs"},{"title":"使用 Nuxt 和 Bun 构建应用","sidebarTitle":"Nuxt 搭配 Bun","mode":"center","href":"/guides/ecosystem/nuxt"},{"title":"使用 PM2 作为守护进程运行 Bun","sidebarTitle":"PM2 与 Bun","mode":"center","href":"/guides/ecosystem/pm2"},{"title":"在 Bun 中使用 Prisma","sidebarTitle":"Prisma ORM 与 Bun","mode":"center","href":"/guides/ecosystem/prisma"},{"title":"在 Bun 中使用 Prisma Postgres","sidebarTitle":"在 Bun 中使用 Prisma Postgres","mode":"center","href":"/guides/ecosystem/prisma-postgres"},{"title":"使用 Qwik 和 Bun 构建应用","sidebarTitle":"Qwik 与 Bun","mode":"center","href":"/guides/ecosystem/qwik"},{"title":"使用 Bun 构建 React 应用","sidebarTitle":"React 与 Bun","mode":"center","href":"/guides/ecosystem/react"},{"title":"使用 Remix 和 Bun 构建应用","sidebarTitle":"使用 Remix 和 Bun","mode":"center","href":"/guides/ecosystem/remix"},{"title":"使用 Bun 启动 TanStack Start","sidebarTitle":"使用 Bun 启动 TanStack Start","mode":"center","href":"/guides/ecosystem/tanstack-start"},{"title":"在 Bun 应用中添加 Sentry","sidebarTitle":"Bun 中使用 Sentry","mode":"center","href":"/guides/ecosystem/sentry"},{"title":"使用 SolidStart 和 Bun 构建应用","sidebarTitle":"SolidStart 与 Bun","mode":"center","href":"/guides/ecosystem/solidstart"},{"title":"服务器端渲染(SSR)React 组件","sidebarTitle":"使用 Bun 进行 SSR React","mode":"center","href":"/guides/ecosystem/ssr-react"},{"title":"使用 SvelteKit 和 Bun 构建应用","sidebarTitle":"SvelteKit 与 Bun","mode":"center","href":"/guides/ecosystem/sveltekit"},{"title":"使用 systemd 将 Bun 作为守护进程运行","sidebarTitle":"systemd 与 Bun","mode":"center","href":"/guides/ecosystem/systemd"},{"title":"使用 Vite 和 Bun 构建前端","sidebarTitle":"Vite 与 Bun","mode":"center","href":"/guides/ecosystem/vite"},{"title":"使用 Bun 连接 Upstash Redis","sidebarTitle":"Bun 配合 Upstash","mode":"center","href":"/guides/ecosystem/upstash"}]},{"group":"HTTP 与网络","icon":"globe","pages":[{"title":"常见的 HTTP 服务器用法","sidebarTitle":"使用 Bun 的 HTTP 服务器","mode":"center","href":"/guides/http/server"},{"title":"编写一个简单的 HTTP 服务器","sidebarTitle":"使用 Bun 创建简单 HTTP 服务器","mode":"center","href":"/guides/http/simple"},{"title":"使用 fetch 发送 HTTP 请求","sidebarTitle":"Bun 中的 Fetch","mode":"center","href":"/guides/http/fetch"},{"title":"热重载 HTTP 服务器","sidebarTitle":"热重载 HTTP 服务器","mode":"center","href":"/guides/http/hot"},{"title":"启动 HTTP 服务器集群","sidebarTitle":"启动 HTTP 服务器集群","mode":"center","href":"/guides/http/cluster"},{"title":"在 HTTP 服务器上配置 TLS","sidebarTitle":"配置 TLS","mode":"center","href":"/guides/http/tls"},{"title":"使用 fetch() 代理 HTTP 请求","sidebarTitle":"使用 fetch() 代理 HTTP 请求","mode":"center","href":"/guides/http/proxy"},{"title":"将文件作为 HTTP 响应流式传输","sidebarTitle":"流式文件响应","mode":"center","href":"/guides/http/stream-file"},{"title":"使用 FormData 通过 HTTP 上传文件","sidebarTitle":"使用 FormData 通过 HTTP 上传文件","mode":"center","href":"/guides/http/file-uploads"},{"title":"在 Bun 中通过 unix 域套接字进行 fetch","sidebarTitle":"使用 unix 域套接字的 Fetch","mode":"center","href":"/guides/http/fetch-unix"},{"title":"使用异步迭代器的流式 HTTP 服务器","sidebarTitle":"使用迭代器流式传输","mode":"center","href":"/guides/http/stream-iterator"},{"title":"使用 Bun 的服务器发送事件(SSE)","sidebarTitle":"服务器发送事件","mode":"center","href":"/guides/http/sse"},{"title":"使用 Node.js 流的流式 HTTP 服务器","sidebarTitle":"使用 Node.js 流","mode":"center","href":"/guides/http/stream-node-streams-in-bun"}]},{"group":"WebSocket","icon":"radio","pages":[{"title":"构建一个简单的 WebSocket 服务器","sidebarTitle":"简单服务器","mode":"center","href":"/guides/websocket/simple"},{"title":"构建一个发布-订阅 WebSocket 服务器","sidebarTitle":"发布-订阅服务器","mode":"center","href":"/guides/websocket/pubsub"},{"title":"在 WebSocket 上设置每个 socket 的上下文数据","sidebarTitle":"上下文数据","mode":"center","href":"/guides/websocket/context"},{"title":"启用 WebSocket 消息压缩","sidebarTitle":"启用压缩","mode":"center","href":"/guides/websocket/compression"}]},{"group":"进程与系统","icon":"cpu","pages":[{"title":"启动子进程","sidebarTitle":"启动子进程","mode":"center","href":"/guides/process/spawn"},{"title":"从子进程读取标准输出","sidebarTitle":"读取标准输出","mode":"center","href":"/guides/process/spawn-stdout"},{"title":"从子进程读取 stderr","sidebarTitle":"读取 stderr","mode":"center","href":"/guides/process/spawn-stderr"},{"title":"解析命令行参数","sidebarTitle":"解析命令行参数","mode":"center","href":"/guides/process/argv"},{"title":"从 stdin 读取","sidebarTitle":"从 stdin 读取","mode":"center","href":"/guides/process/stdin"},{"title":"派生子进程并使用 IPC 通信","sidebarTitle":"派生子进程并使用 IPC 通信","mode":"center","href":"/guides/process/ipc"},{"title":"监听 CTRL+C","sidebarTitle":"监听 CTRL+C","mode":"center","href":"/guides/process/ctrl-c"},{"title":"监听操作系统信号","sidebarTitle":"操作系统信号","mode":"center","href":"/guides/process/os-signals"},{"title":"以纳秒为单位获取进程运行时间","sidebarTitle":"进程运行时间","mode":"center","href":"/guides/process/nanoseconds"},{"title":"运行 Shell 命令","sidebarTitle":"运行 shell 命令","mode":"center","href":"/guides/runtime/shell"},{"title":"在 Bun 中设置时区","sidebarTitle":"设置时区","mode":"center","href":"/guides/runtime/timezone"},{"title":"设置环境变量","sidebarTitle":"设置环境变量","mode":"center","href":"/guides/runtime/set-env"},{"title":"读取环境变量","sidebarTitle":"读取环境变量","mode":"center","href":"/guides/runtime/read-env"}]},{"group":"包管理器","icon":"package","pages":[{"title":"添加依赖","sidebarTitle":"添加依赖","mode":"center","href":"/guides/install/add"},{"title":"添加开发依赖","sidebarTitle":"添加开发依赖","mode":"center","href":"/guides/install/add-dev"},{"title":"添加可选依赖","sidebarTitle":"添加可选依赖","mode":"center","href":"/guides/install/add-optional"},{"title":"添加一个 peer 依赖","sidebarTitle":"添加一个 peer 依赖","mode":"center","href":"/guides/install/add-peer"},{"title":"添加 Git 依赖","sidebarTitle":"添加 Git 依赖","mode":"center","href":"/guides/install/add-git"},{"title":"添加一个 tarball 依赖","sidebarTitle":"添加一个 tarball 依赖","mode":"center","href":"/guides/install/add-tarball"},{"title":"以不同名称安装包","sidebarTitle":"使用别名安装","mode":"center","href":"/guides/install/npm-alias"},{"title":"使用 workspaces 配置 monorepo","sidebarTitle":"Bun 的 Workspaces","mode":"center","href":"/guides/install/workspaces"},{"title":"覆盖 bun install 的默认 npm registry","sidebarTitle":"覆盖默认的 npm registry","mode":"center","href":"/guides/install/custom-registry"},{"title":"使用 bun install 为组织作用域配置私有注册表","sidebarTitle":"配置作用域注册表","mode":"center","href":"/guides/install/registry-scope"},{"title":"使用 bun install 配合 Azure Artifacts npm 注册表","sidebarTitle":"在 Bun 中使用 Azure Artifacts","mode":"center","href":"/guides/install/azure-artifacts"},{"title":"使用 bun install 配合 Artifactory","sidebarTitle":"使用 Bun 的 JFrog Artifactory","mode":"center","href":"/guides/install/jfrog-artifactory"},{"title":"添加受信任的依赖","sidebarTitle":"添加受信任的依赖","mode":"center","href":"/guides/install/trusted"},{"title":"生成兼容 yarn 的锁文件","sidebarTitle":"生成兼容 yarn 的锁文件","mode":"center","href":"/guides/install/yarnlock"},{"title":"从 npm install 迁移到 bun install","sidebarTitle":"从 npm 迁移到 bun","mode":"center","href":"/guides/install/from-npm-install-to-bun-install"},{"title":"配置 git 以比较 Bun 的 lockb 锁文件","sidebarTitle":"配置 git 比较 Bun 的锁文件","mode":"center","href":"/guides/install/git-diff-bun-lockfile"},{"title":"在 GitHub Actions 中使用 Bun 安装依赖","sidebarTitle":"在 GitHub Actions 中安装 Bun","mode":"center","href":"/guides/install/cicd"}]},{"group":"测试运行器","icon":"flask-conical","pages":[{"title":"使用 Bun 测试运行器运行测试","sidebarTitle":"运行测试","mode":"center","href":"/guides/test/run-tests"},{"title":"使用 Bun 的监听模式运行测试","sidebarTitle":"监听模式","mode":"center","href":"/guides/test/watch-mode"},{"title":"从 Jest 迁移到 Bun 的测试运行器","sidebarTitle":"从 Jest 迁移","mode":"center","href":"/guides/test/migrate-from-jest"},{"title":"在 `bun test` 中使用模拟函数","sidebarTitle":"模拟函数","mode":"center","href":"/guides/test/mock-functions"},{"title":"在 `bun test` 中监视方法","sidebarTitle":"监视方法","mode":"center","href":"/guides/test/spy-on"},{"title":"在 Bun 的测试运行器中设置系统时间","sidebarTitle":"模拟系统时间","mode":"center","href":"/guides/test/mock-clock"},{"title":"在 `bun test` 中使用快照测试","sidebarTitle":"快照测试","mode":"center","href":"/guides/test/snapshot"},{"title":"在 `bun test` 中更新快照","sidebarTitle":"更新快照","mode":"center","href":"/guides/test/update-snapshots"},{"title":"使用 Bun 测试运行器生成代码覆盖率报告","sidebarTitle":"覆盖率报告","mode":"center","href":"/guides/test/coverage"},{"title":"使用 Bun 测试运行器设置代码覆盖率阈值","sidebarTitle":"覆盖率阈值","mode":"center","href":"/guides/test/coverage-threshold"},{"title":"使用通配符模式有选择地并发运行测试","sidebarTitle":"并发测试通配符","mode":"center","href":"/guides/test/concurrent-test-glob"},{"title":"使用 Bun 测试运行器跳过测试","sidebarTitle":"跳过测试","mode":"center","href":"/guides/test/skip-tests"},{"title":"使用 Bun 测试运行器将测试标记为“todo”","sidebarTitle":"待办测试","mode":"center","href":"/guides/test/todo-tests"},{"title":"使用 Bun 测试运行器设置单个测试超时","sidebarTitle":"测试超时","mode":"center","href":"/guides/test/timeout"},{"title":"使用 Bun 测试运行器提前中止","sidebarTitle":"提前中止","mode":"center","href":"/guides/test/bail"},{"title":"使用 Bun 测试运行器多次重新运行测试","sidebarTitle":"重新运行测试","mode":"center","href":"/guides/test/rerun-each"},{"title":"在 Bun 中使用 Testing Library","sidebarTitle":"Testing Library","mode":"center","href":"/guides/test/testing-library"},{"title":"使用 Bun 和 happy-dom 编写浏览器 DOM 测试","sidebarTitle":"DOM 测试","mode":"center","href":"/guides/test/happy-dom"},{"title":"使用 bun test 导入、require 和测试 Svelte 组件","sidebarTitle":"测试 Svelte","mode":"center","href":"/guides/test/svelte-test"}]},{"group":"运行时与调试","icon":"bug","pages":[{"title":"使用 VS Code 扩展调试 Bun","sidebarTitle":"VS Code 调试器","mode":"center","href":"/guides/runtime/vscode-debugger"},{"title":"使用网页调试器调试 Bun","sidebarTitle":"网页调试器","mode":"center","href":"/guides/runtime/web-debugger"},{"title":"使用 V8 堆快照检查内存使用情况","sidebarTitle":"堆快照","mode":"center","href":"/guides/runtime/heap-snapshot"},{"title":"使用 --define 实现构建时常量","sidebarTitle":"构建时常量","mode":"center","href":"/guides/runtime/build-time-constants"},{"title":"定义并替换静态全局变量和常量","sidebarTitle":"定义常量","mode":"center","href":"/guides/runtime/define-constant"},{"title":"在 GitHub Actions 中安装并运行 Bun","sidebarTitle":"GitHub Actions","mode":"center","href":"/guides/runtime/cicd"},{"title":"在 macOS 上为单文件 JavaScript 可执行文件进行代码签名","sidebarTitle":"macOS 上的代码签名","mode":"center","href":"/guides/runtime/codesign-macos-executable"}]},{"group":"模块系统","icon":"box","pages":[{"title":"导入 JSON 文件","sidebarTitle":"导入 JSON","mode":"center","href":"/guides/runtime/import-json"},{"title":"导入 TOML 文件","sidebarTitle":"导入 TOML","mode":"center","href":"/guides/runtime/import-toml"},{"title":"导入 YAML 文件","sidebarTitle":"导入 YAML","mode":"center","href":"/guides/runtime/import-yaml"},{"title":"导入 JSON5 文件","sidebarTitle":"导入 JSON5","mode":"center","href":"/guides/runtime/import-json5"},{"title":"导入 XML 文件","sidebarTitle":"导入 XML","mode":"center","href":"/guides/runtime/import-xml"},{"title":"将 HTML 文件作为文本导入","sidebarTitle":"导入 HTML","mode":"center","href":"/guides/runtime/import-html"},{"title":"获取当前文件的目录","sidebarTitle":"import.meta.dir","mode":"center","href":"/guides/util/import-meta-dir"},{"title":"获取当前文件的文件名","sidebarTitle":"import.meta.file","mode":"center","href":"/guides/util/import-meta-file"},{"title":"获取当前文件的绝对路径","sidebarTitle":"import.meta.path","mode":"center","href":"/guides/util/import-meta-path"},{"title":"检查当前文件是否为入口点","sidebarTitle":"检查入口点","mode":"center","href":"/guides/util/entrypoint"},{"title":"获取当前入口文件的绝对路径","sidebarTitle":"获取入口文件路径","mode":"center","href":"/guides/util/main"}]},{"group":"文件系统","icon":"folder","pages":[{"title":"将文件作为字符串读取","sidebarTitle":"作为字符串读取","mode":"center","href":"/guides/read-file/string"},{"title":"将文件读取到 Buffer","sidebarTitle":"读取到 Buffer","mode":"center","href":"/guides/read-file/buffer"},{"title":"读取文件到 Uint8Array","sidebarTitle":"读取到 Uint8Array","mode":"center","href":"/guides/read-file/uint8array"},{"title":"读取文件到 ArrayBuffer","sidebarTitle":"读取到 ArrayBuffer","mode":"center","href":"/guides/read-file/arraybuffer"},{"title":"读取 JSON 文件","sidebarTitle":"读取 JSON 文件","mode":"center","href":"/guides/read-file/json"},{"title":"获取文件的 MIME 类型","sidebarTitle":"获取 MIME 类型","mode":"center","href":"/guides/read-file/mime"},{"title":"检查文件是否存在","sidebarTitle":"检查文件存在","mode":"center","href":"/guides/read-file/exists"},{"title":"监视目录变化","sidebarTitle":"监视目录","mode":"center","href":"/guides/read-file/watch"},{"title":"以 ReadableStream 读取文件","sidebarTitle":"以流读取","mode":"center","href":"/guides/read-file/stream"},{"title":"将字符串写入文件","sidebarTitle":"写字符串到文件","mode":"center","href":"/guides/write-file/basic"},{"title":"将 Blob 写入文件","sidebarTitle":"写入 Blob","mode":"center","href":"/guides/write-file/blob"},{"title":"将 Response 写入文件","sidebarTitle":"写入响应","mode":"center","href":"/guides/write-file/response"},{"title":"追加内容到文件","sidebarTitle":"追加到文件","mode":"center","href":"/guides/write-file/append"},{"title":"递增写入文件","sidebarTitle":"递增写入","mode":"center","href":"/guides/write-file/filesink"},{"title":"将 ReadableStream 写入文件","sidebarTitle":"写入流","mode":"center","href":"/guides/write-file/stream"},{"title":"写入到标准输出","sidebarTitle":"写入到标准输出","mode":"center","href":"/guides/write-file/stdout"},{"title":"写入文件到标准输出","sidebarTitle":"写文件到标准输出","mode":"center","href":"/guides/write-file/cat"},{"title":"将文件复制到另一个位置","sidebarTitle":"复制文件","mode":"center","href":"/guides/write-file/file-cp"},{"title":"删除文件","sidebarTitle":"删除文件","mode":"center","href":"/guides/write-file/unlink"},{"title":"删除文件","sidebarTitle":"删除文件","mode":"center","href":"/guides/runtime/delete-file"},{"title":"删除目录","sidebarTitle":"删除目录","mode":"center","href":"/guides/runtime/delete-directory"}]},{"group":"实用工具","icon":"wrench","pages":[{"title":"密码哈希","sidebarTitle":"密码哈希","mode":"center","href":"/guides/util/hash-a-password"},{"title":"生成 UUID","sidebarTitle":"生成 UUID","mode":"center","href":"/guides/util/javascript-uuid"},{"title":"编码和解码 base64 数据","sidebarTitle":"Base64 编码","mode":"center","href":"/guides/util/base64"},{"title":"使用 gzip 压缩和解压数据","sidebarTitle":"Gzip 压缩","mode":"center","href":"/guides/util/gzip"},{"title":"使用 DEFLATE 进行数据压缩和解压","sidebarTitle":"DEFLATE 压缩","mode":"center","href":"/guides/util/deflate"},{"title":"转义 HTML 字符串","sidebarTitle":"转义 HTML","mode":"center","href":"/guides/util/escape-html"},{"title":"检查两个对象是否深度相等","sidebarTitle":"深度相等","mode":"center","href":"/guides/util/deep-equals"},{"title":"固定毫秒数的休眠","sidebarTitle":"休眠","mode":"center","href":"/guides/util/sleep"},{"title":"将文件 URL 转换为绝对路径","sidebarTitle":"文件 URL 转路径","mode":"center","href":"/guides/util/file-url-to-path"},{"title":"将绝对路径转换为文件 URL","sidebarTitle":"路径转文件 URL","mode":"center","href":"/guides/util/path-to-file-url"},{"title":"获取可执行二进制文件的路径","sidebarTitle":"查找可执行文件路径","mode":"center","href":"/guides/util/which-path-to-executable-bin"}]},{"group":"HTML 处理","icon":"file-code","pages":[{"title":"使用 HTMLRewriter 提取网页中的链接","sidebarTitle":"使用 HTMLRewriter 提取链接","mode":"center","href":"/guides/html-rewriter/extract-links"},{"title":"提取社交分享图片和开放图谱标签","sidebarTitle":"OpenGraph 标签","mode":"center","href":"/guides/html-rewriter/extract-social-meta"}]},{"group":"二进制数据","icon":"binary","pages":[{"title":"将 ArrayBuffer 转换为字符串","sidebarTitle":"ArrayBuffer 到字符串","mode":"center","href":"/guides/binary/arraybuffer-to-string"},{"title":"将 ArrayBuffer 转换为 Buffer","sidebarTitle":"ArrayBuffer 转 Buffer","mode":"center","href":"/guides/binary/arraybuffer-to-buffer"},{"title":"将 ArrayBuffer 转换为 Blob","sidebarTitle":"ArrayBuffer 转 Blob","mode":"center","href":"/guides/binary/arraybuffer-to-blob"},{"title":"将 ArrayBuffer 转换为数字数组","sidebarTitle":"ArrayBuffer 转数组","mode":"center","href":"/guides/binary/arraybuffer-to-array"},{"title":"将 ArrayBuffer 转换为 Uint8Array","sidebarTitle":"ArrayBuffer 到 Uint8Array","mode":"center","href":"/guides/binary/arraybuffer-to-typedarray"},{"title":"将 Buffer 转换为字符串","sidebarTitle":"Buffer 转字符串","mode":"center","href":"/guides/binary/buffer-to-string"},{"title":"将 Buffer 转换为 ArrayBuffer","sidebarTitle":"Buffer 转 ArrayBuffer","mode":"center","href":"/guides/binary/buffer-to-arraybuffer"},{"title":"将 Buffer 转换为 Blob","sidebarTitle":"Buffer 转 Blob","mode":"center","href":"/guides/binary/buffer-to-blob"},{"title":"将 Buffer 转换为 Uint8Array","sidebarTitle":"Buffer 转 Uint8Array","mode":"center","href":"/guides/binary/buffer-to-typedarray"},{"title":"将 Buffer 转换为 ReadableStream","sidebarTitle":"Buffer 转 ReadableStream","mode":"center","href":"/guides/binary/buffer-to-readablestream"},{"title":"将 Blob 转换为字符串","sidebarTitle":"Blob 转字符串","mode":"center","href":"/guides/binary/blob-to-string"},{"title":"将 Blob 转换为 ArrayBuffer","sidebarTitle":"Blob 转 ArrayBuffer","mode":"center","href":"/guides/binary/blob-to-arraybuffer"},{"title":"将 Blob 转换为 Uint8Array","sidebarTitle":"Blob 转 Uint8Array","mode":"center","href":"/guides/binary/blob-to-typedarray"},{"title":"将 Blob 转换为 DataView","sidebarTitle":"Blob 转 DataView","mode":"center","href":"/guides/binary/blob-to-dataview"},{"title":"将 Blob 转换为 ReadableStream","sidebarTitle":"Blob 转 ReadableStream","mode":"center","href":"/guides/binary/blob-to-stream"},{"title":"将 Uint8Array 转换为字符串","sidebarTitle":"Uint8Array 转字符串","mode":"center","href":"/guides/binary/typedarray-to-string"},{"title":"将 Uint8Array 转换为 ArrayBuffer","sidebarTitle":"Uint8Array 到 ArrayBuffer","mode":"center","href":"/guides/binary/typedarray-to-arraybuffer"},{"title":"将 Uint8Array 转换为 Buffer","sidebarTitle":"Uint8Array 转 Buffer","mode":"center","href":"/guides/binary/typedarray-to-buffer"},{"title":"将 Uint8Array 转换为 Blob","sidebarTitle":"Uint8Array 转 Blob","mode":"center","href":"/guides/binary/typedarray-to-blob"},{"title":"将 Uint8Array 转换为 DataView","sidebarTitle":"Uint8Array 到 DataView","mode":"center","href":"/guides/binary/typedarray-to-dataview"},{"title":"将 Uint8Array 转换为 ReadableStream","sidebarTitle":"Uint8Array 转 ReadableStream","mode":"center","href":"/guides/binary/typedarray-to-readablestream"},{"title":"将 DataView 转换为字符串","sidebarTitle":"DataView 转字符串","mode":"center","href":"/guides/binary/dataview-to-string"}]},{"group":"Streams","icon":"waves","pages":[{"title":"将 ReadableStream 转换为字符串","sidebarTitle":"流转换为字符串","mode":"center","href":"/guides/streams/to-string"},{"title":"将 ReadableStream 转换为 JSON","sidebarTitle":"流转 JSON","mode":"center","href":"/guides/streams/to-json"},{"title":"将 ReadableStream 转换为 Blob","sidebarTitle":"流转换为 Blob","mode":"center","href":"/guides/streams/to-blob"},{"title":"将 ReadableStream 转换为 Buffer","sidebarTitle":"流转 Buffer","mode":"center","href":"/guides/streams/to-buffer"},{"title":"将 ReadableStream 转换为 ArrayBuffer","sidebarTitle":"流到 ArrayBuffer","mode":"center","href":"/guides/streams/to-arraybuffer"},{"title":"将 ReadableStream 转换为 Uint8Array","sidebarTitle":"Stream 转 Uint8Array","mode":"center","href":"/guides/streams/to-typedarray"},{"title":"将 ReadableStream 转换为块数组","sidebarTitle":"流转数组","mode":"center","href":"/guides/streams/to-array"},{"title":"将 Node.js Readable 转换为字符串","sidebarTitle":"Readable 转字符串","mode":"center","href":"/guides/streams/node-readable-to-string"},{"title":"将 Node.js Readable 转换为 JSON","sidebarTitle":"Readable 转 JSON","mode":"center","href":"/guides/streams/node-readable-to-json"},{"title":"将 Node.js Readable 转换为 Blob","sidebarTitle":"Readable 转 Blob","mode":"center","href":"/guides/streams/node-readable-to-blob"},{"title":"将 Node.js Readable 转换为 Uint8Array","sidebarTitle":"Readable 转 Uint8Array","mode":"center","href":"/guides/streams/node-readable-to-uint8array"},{"title":"将 Node.js Readable 转换为 ArrayBuffer","sidebarTitle":"Readable 到 ArrayBuffer","mode":"center","href":"/guides/streams/node-readable-to-arraybuffer"}]}]},{"tab":"参考","icon":"book","href":"https://bun.com/reference"},{"tab":"博客","icon":"newspaper","href":"https://bun.com/blog"},{"tab":"反馈","icon":"lightbulb","pages":[{"title":"反馈","href":"/feedback"}]}]},"basePath":"","title":"使用 Elysia 和 Bun 构建 HTTP 服务器 - Bun 中文文档","buildId":"ece5007f5547","dynamics":[],"chunks":[]}