bun-types 1.3.2-canary.20251105T140650 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bun.d.ts +102 -6
- package/docs/README.md +28 -0
- package/docs/bundler/bytecode.mdx +465 -0
- package/docs/bundler/{css.md → css.mdx} +97 -101
- package/docs/bundler/esbuild.mdx +253 -0
- package/docs/bundler/{executables.md → executables.mdx} +130 -221
- package/docs/bundler/fullstack.mdx +1064 -0
- package/docs/bundler/{hmr.md → hot-reloading.mdx} +74 -79
- package/docs/bundler/{html.md → html-static.mdx} +148 -111
- package/docs/bundler/index.mdx +1499 -0
- package/docs/bundler/loaders.mdx +356 -0
- package/docs/bundler/{macros.md → macros.mdx} +83 -84
- package/docs/bundler/minifier.mdx +1306 -0
- package/docs/bundler/plugins.mdx +411 -0
- package/docs/feedback.mdx +85 -0
- package/docs/guides/binary/{arraybuffer-to-array.md → arraybuffer-to-array.mdx} +3 -1
- package/docs/guides/binary/{arraybuffer-to-blob.md → arraybuffer-to-blob.mdx} +3 -1
- package/docs/guides/binary/{arraybuffer-to-buffer.md → arraybuffer-to-buffer.mdx} +3 -1
- package/docs/guides/binary/{arraybuffer-to-string.md → arraybuffer-to-string.mdx} +3 -1
- package/docs/guides/binary/{arraybuffer-to-typedarray.md → arraybuffer-to-typedarray.mdx} +3 -1
- package/docs/guides/binary/{blob-to-arraybuffer.md → blob-to-arraybuffer.mdx} +3 -1
- package/docs/guides/binary/{blob-to-dataview.md → blob-to-dataview.mdx} +3 -1
- package/docs/guides/binary/{blob-to-stream.md → blob-to-stream.mdx} +3 -1
- package/docs/guides/binary/{blob-to-string.md → blob-to-string.mdx} +3 -1
- package/docs/guides/binary/{blob-to-typedarray.md → blob-to-typedarray.mdx} +3 -1
- package/docs/guides/binary/{buffer-to-arraybuffer.md → buffer-to-arraybuffer.mdx} +3 -1
- package/docs/guides/binary/{buffer-to-blob.md → buffer-to-blob.mdx} +3 -1
- package/docs/guides/binary/{buffer-to-readablestream.md → buffer-to-readablestream.mdx} +3 -1
- package/docs/guides/binary/{buffer-to-string.md → buffer-to-string.mdx} +3 -1
- package/docs/guides/binary/{buffer-to-typedarray.md → buffer-to-typedarray.mdx} +3 -1
- package/docs/guides/binary/{dataview-to-string.md → dataview-to-string.mdx} +3 -1
- package/docs/guides/binary/{typedarray-to-arraybuffer.md → typedarray-to-arraybuffer.mdx} +3 -1
- package/docs/guides/binary/{typedarray-to-blob.md → typedarray-to-blob.mdx} +3 -1
- package/docs/guides/binary/{typedarray-to-buffer.md → typedarray-to-buffer.mdx} +3 -1
- package/docs/guides/binary/{typedarray-to-dataview.md → typedarray-to-dataview.mdx} +3 -1
- package/docs/guides/binary/{typedarray-to-readablestream.md → typedarray-to-readablestream.mdx} +3 -1
- package/docs/guides/binary/{typedarray-to-string.md → typedarray-to-string.mdx} +3 -1
- package/docs/guides/deployment/aws-lambda.mdx +204 -0
- package/docs/guides/deployment/digital-ocean.mdx +161 -0
- package/docs/guides/deployment/google-cloud-run.mdx +197 -0
- package/docs/guides/deployment/{railway.md → railway.mdx} +42 -54
- package/docs/guides/deployment/render.mdx +82 -0
- package/docs/guides/deployment/vercel.mdx +99 -0
- package/docs/guides/ecosystem/{astro.md → astro.mdx} +16 -6
- package/docs/guides/ecosystem/{discordjs.md → discordjs.mdx} +21 -18
- package/docs/guides/ecosystem/{docker.md → docker.mdx} +25 -14
- package/docs/guides/ecosystem/{drizzle.md → drizzle.mdx} +32 -22
- package/docs/guides/ecosystem/{edgedb.md → edgedb.mdx} +63 -34
- package/docs/guides/ecosystem/{elysia.md → elysia.mdx} +11 -11
- package/docs/guides/ecosystem/{express.md → express.mdx} +12 -9
- package/docs/guides/ecosystem/{hono.md → hono.mdx} +16 -8
- package/docs/guides/ecosystem/{mongoose.md → mongoose.mdx} +26 -21
- package/docs/guides/ecosystem/{neon-drizzle.md → neon-drizzle.mdx} +49 -35
- package/docs/guides/ecosystem/{neon-serverless-postgres.md → neon-serverless-postgres.mdx} +16 -11
- package/docs/guides/ecosystem/{nextjs.md → nextjs.mdx} +18 -10
- package/docs/guides/ecosystem/{nuxt.md → nuxt.mdx} +45 -11
- package/docs/guides/ecosystem/{pm2.md → pm2.mdx} +7 -9
- package/docs/guides/ecosystem/prisma-postgres.mdx +169 -0
- package/docs/guides/ecosystem/prisma.mdx +164 -0
- package/docs/guides/ecosystem/{qwik.md → qwik.mdx} +18 -11
- package/docs/guides/ecosystem/{react.md → react.mdx} +9 -7
- package/docs/guides/ecosystem/{remix.md → remix.mdx} +45 -26
- package/docs/guides/ecosystem/{sentry.md → sentry.mdx} +7 -5
- package/docs/guides/ecosystem/{solidstart.md → solidstart.mdx} +21 -13
- package/docs/guides/ecosystem/{ssr-react.md → ssr-react.mdx} +9 -11
- package/docs/guides/ecosystem/{stric.md → stric.mdx} +16 -17
- package/docs/guides/ecosystem/{sveltekit.md → sveltekit.mdx} +42 -29
- package/docs/guides/ecosystem/{systemd.md → systemd.mdx} +27 -26
- package/docs/guides/ecosystem/upstash.mdx +87 -0
- package/docs/guides/ecosystem/{vite.md → vite.mdx} +20 -14
- package/docs/guides/html-rewriter/{extract-links.md → extract-links.mdx} +11 -7
- package/docs/guides/html-rewriter/{extract-social-meta.md → extract-social-meta.mdx} +6 -2
- package/docs/guides/http/{cluster.md → cluster.mdx} +10 -7
- package/docs/guides/http/{fetch-unix.md → fetch-unix.mdx} +5 -3
- package/docs/guides/http/{fetch.md → fetch.mdx} +5 -3
- package/docs/guides/http/{file-uploads.md → file-uploads.mdx} +18 -15
- package/docs/guides/http/{hot.md → hot.mdx} +9 -7
- package/docs/guides/http/{proxy.md → proxy.mdx} +7 -5
- package/docs/guides/http/{server.md → server.mdx} +4 -2
- package/docs/guides/http/{simple.md → simple.mdx} +4 -2
- package/docs/guides/http/{stream-file.md → stream-file.mdx} +6 -4
- package/docs/guides/http/{stream-iterator.md → stream-iterator.mdx} +5 -3
- package/docs/guides/http/{stream-node-streams-in-bun.md → stream-node-streams-in-bun.mdx} +4 -2
- package/docs/guides/http/{tls.md → tls.mdx} +5 -3
- package/docs/guides/index.mdx +10 -0
- package/docs/guides/install/{add-dev.md → add-dev.mdx} +8 -6
- package/docs/guides/install/add-git.mdx +38 -0
- package/docs/guides/install/{add-optional.md → add-optional.mdx} +7 -5
- package/docs/guides/install/{add-peer.md → add-peer.mdx} +13 -11
- package/docs/guides/install/{add-tarball.md → add-tarball.mdx} +7 -5
- package/docs/guides/install/{add.md → add.mdx} +12 -10
- package/docs/guides/install/{azure-artifacts.md → azure-artifacts.mdx} +15 -12
- package/docs/guides/{runtime/cicd.md → install/cicd.mdx} +13 -13
- package/docs/guides/install/{custom-registry.md → custom-registry.mdx} +6 -4
- package/docs/guides/install/{from-npm-install-to-bun-install.md → from-npm-install-to-bun-install.mdx} +50 -34
- package/docs/guides/install/{git-diff-bun-lockfile.md → git-diff-bun-lockfile.mdx} +14 -11
- package/docs/guides/install/{jfrog-artifactory.md → jfrog-artifactory.mdx} +4 -4
- package/docs/guides/install/{npm-alias.md → npm-alias.mdx} +6 -4
- package/docs/guides/install/{registry-scope.md → registry-scope.mdx} +6 -4
- package/docs/guides/install/{trusted.md → trusted.mdx} +22 -18
- package/docs/guides/install/{workspaces.md → workspaces.mdx} +13 -13
- package/docs/guides/install/{yarnlock.md → yarnlock.mdx} +15 -9
- package/docs/guides/process/{argv.md → argv.mdx} +17 -9
- package/docs/guides/process/{ctrl-c.md → ctrl-c.mdx} +4 -2
- package/docs/guides/process/{ipc.md → ipc.mdx} +13 -10
- package/docs/guides/process/{nanoseconds.md → nanoseconds.mdx} +3 -1
- package/docs/guides/process/{os-signals.md → os-signals.mdx} +3 -1
- package/docs/guides/process/{spawn-stderr.md → spawn-stderr.mdx} +4 -1
- package/docs/guides/process/{spawn-stdout.md → spawn-stdout.mdx} +3 -1
- package/docs/guides/process/{spawn.md → spawn.mdx} +3 -1
- package/docs/guides/process/{stdin.md → stdin.mdx} +15 -7
- package/docs/guides/read-file/{arraybuffer.md → arraybuffer.mdx} +5 -3
- package/docs/guides/read-file/{buffer.md → buffer.mdx} +4 -2
- package/docs/guides/read-file/{exists.md → exists.mdx} +4 -2
- package/docs/guides/read-file/{json.md → json.mdx} +4 -2
- package/docs/guides/read-file/{mime.md → mime.mdx} +3 -1
- package/docs/guides/read-file/{stream.md → stream.mdx} +3 -1
- package/docs/guides/read-file/{string.md → string.mdx} +3 -1
- package/docs/guides/read-file/{uint8array.md → uint8array.mdx} +3 -1
- package/docs/guides/read-file/{watch.md → watch.mdx} +6 -8
- package/docs/guides/runtime/{build-time-constants.md → build-time-constants.mdx} +24 -22
- package/docs/guides/{install/cicd.md → runtime/cicd.mdx} +11 -7
- package/docs/guides/runtime/{codesign-macos-executable.md → codesign-macos-executable.mdx} +14 -9
- package/docs/guides/runtime/{define-constant.md → define-constant.mdx} +20 -16
- package/docs/guides/runtime/{delete-directory.md → delete-directory.mdx} +5 -3
- package/docs/guides/runtime/{delete-file.md → delete-file.mdx} +4 -2
- package/docs/guides/runtime/{heap-snapshot.md → heap-snapshot.mdx} +5 -3
- package/docs/guides/runtime/{import-html.md → import-html.mdx} +4 -2
- package/docs/guides/runtime/{import-json.md → import-json.mdx} +6 -4
- package/docs/guides/runtime/{import-toml.md → import-toml.mdx} +5 -3
- package/docs/guides/runtime/{import-yaml.md → import-yaml.mdx} +9 -7
- package/docs/guides/runtime/{read-env.md → read-env.mdx} +10 -5
- package/docs/guides/runtime/{set-env.md → set-env.mdx} +14 -10
- package/docs/guides/runtime/{shell.md → shell.mdx} +6 -4
- package/docs/guides/runtime/{timezone.md → timezone.mdx} +10 -7
- package/docs/guides/runtime/{tsconfig-paths.md → tsconfig-paths.mdx} +5 -3
- package/docs/guides/runtime/{typescript.md → typescript.mdx} +8 -6
- package/docs/guides/runtime/{vscode-debugger.md → vscode-debugger.mdx} +12 -11
- package/docs/guides/runtime/{web-debugger.md → web-debugger.mdx} +39 -18
- package/docs/guides/streams/{node-readable-to-arraybuffer.md → node-readable-to-arraybuffer.mdx} +3 -1
- package/docs/guides/streams/{node-readable-to-blob.md → node-readable-to-blob.mdx} +3 -1
- package/docs/guides/streams/{node-readable-to-json.md → node-readable-to-json.mdx} +3 -1
- package/docs/guides/streams/{node-readable-to-string.md → node-readable-to-string.mdx} +3 -1
- package/docs/guides/streams/{node-readable-to-uint8array.md → node-readable-to-uint8array.mdx} +3 -1
- package/docs/guides/streams/{to-array.md → to-array.mdx} +3 -1
- package/docs/guides/streams/{to-arraybuffer.md → to-arraybuffer.mdx} +3 -1
- package/docs/guides/streams/{to-blob.md → to-blob.mdx} +3 -1
- package/docs/guides/streams/{to-buffer.md → to-buffer.mdx} +3 -1
- package/docs/guides/streams/{to-json.md → to-json.mdx} +4 -2
- package/docs/guides/streams/{to-string.md → to-string.mdx} +3 -1
- package/docs/guides/streams/{to-typedarray.md → to-typedarray.mdx} +3 -1
- package/docs/guides/test/{bail.md → bail.mdx} +7 -5
- package/docs/guides/test/{coverage-threshold.md → coverage-threshold.mdx} +14 -7
- package/docs/guides/test/{coverage.md → coverage.mdx} +9 -4
- package/docs/guides/test/{happy-dom.md → happy-dom.mdx} +13 -8
- package/docs/guides/test/{migrate-from-jest.md → migrate-from-jest.mdx} +19 -37
- package/docs/guides/test/{mock-clock.md → mock-clock.mdx} +3 -1
- package/docs/guides/test/{mock-functions.md → mock-functions.mdx} +7 -5
- package/docs/guides/test/{rerun-each.md → rerun-each.mdx} +5 -3
- package/docs/guides/test/{run-tests.md → run-tests.mdx} +16 -11
- package/docs/guides/test/{skip-tests.md → skip-tests.mdx} +8 -4
- package/docs/guides/test/{snapshot.md → snapshot.mdx} +20 -13
- package/docs/guides/test/spy-on.mdx +49 -0
- package/docs/guides/test/{svelte-test.md → svelte-test.mdx} +16 -23
- package/docs/guides/test/{testing-library.md → testing-library.mdx} +18 -17
- package/docs/guides/test/{timeout.md → timeout.mdx} +5 -3
- package/docs/guides/test/{todo-tests.md → todo-tests.mdx} +13 -6
- package/docs/guides/test/{update-snapshots.md → update-snapshots.mdx} +9 -6
- package/docs/guides/test/{watch-mode.md → watch-mode.mdx} +9 -4
- package/docs/guides/util/{base64.md → base64.mdx} +3 -1
- package/docs/guides/util/{deep-equals.md → deep-equals.mdx} +5 -3
- package/docs/guides/util/{deflate.md → deflate.mdx} +3 -1
- package/docs/guides/util/{detect-bun.md → detect-bun.mdx} +3 -1
- package/docs/guides/util/{entrypoint.md → entrypoint.mdx} +4 -2
- package/docs/guides/util/{escape-html.md → escape-html.mdx} +3 -1
- package/docs/guides/util/{file-url-to-path.md → file-url-to-path.mdx} +3 -1
- package/docs/guides/util/{gzip.md → gzip.mdx} +3 -1
- package/docs/guides/util/{hash-a-password.md → hash-a-password.mdx} +3 -1
- package/docs/guides/util/{import-meta-dir.md → import-meta-dir.mdx} +4 -2
- package/docs/guides/util/{import-meta-file.md → import-meta-file.mdx} +4 -2
- package/docs/guides/util/{import-meta-path.md → import-meta-path.mdx} +4 -2
- package/docs/guides/util/{javascript-uuid.md → javascript-uuid.mdx} +3 -1
- package/docs/guides/util/{main.md → main.mdx} +19 -8
- package/docs/guides/util/{path-to-file-url.md → path-to-file-url.mdx} +3 -1
- package/docs/guides/util/{sleep.md → sleep.mdx} +3 -1
- package/docs/guides/util/{version.md → version.mdx} +6 -4
- package/docs/guides/util/{which-path-to-executable-bin.md → which-path-to-executable-bin.mdx} +4 -2
- package/docs/guides/websocket/{compression.md → compression.mdx} +5 -3
- package/docs/guides/websocket/{context.md → context.mdx} +9 -12
- package/docs/guides/websocket/{pubsub.md → pubsub.mdx} +5 -6
- package/docs/guides/websocket/{simple.md → simple.mdx} +5 -3
- package/docs/guides/write-file/{append.md → append.mdx} +3 -1
- package/docs/guides/write-file/{basic.md → basic.mdx} +3 -1
- package/docs/guides/write-file/{blob.md → blob.mdx} +3 -1
- package/docs/guides/write-file/{cat.md → cat.mdx} +4 -2
- package/docs/guides/write-file/{file-cp.md → file-cp.mdx} +3 -1
- package/docs/guides/write-file/{filesink.md → filesink.mdx} +3 -1
- package/docs/guides/write-file/{response.md → response.mdx} +3 -1
- package/docs/guides/write-file/{stdout.md → stdout.mdx} +3 -1
- package/docs/guides/write-file/{stream.md → stream.mdx} +3 -1
- package/docs/guides/write-file/{unlink.md → unlink.mdx} +3 -1
- package/docs/{index.md → index.mdx} +97 -41
- package/docs/installation.mdx +365 -0
- package/docs/{cli/bunx.md → pm/bunx.mdx} +25 -31
- package/docs/{install/catalogs.md → pm/catalogs.mdx} +18 -24
- package/docs/{cli/add.md → pm/cli/add.mdx} +61 -55
- package/docs/{install/audit.md → pm/cli/audit.mdx} +11 -8
- package/docs/{cli/install.md → pm/cli/install.mdx} +208 -81
- package/docs/{cli/link.md → pm/cli/link.mdx} +27 -19
- package/docs/{cli/outdated.md → pm/cli/outdated.mdx} +119 -12
- package/docs/{install/patch.md → pm/cli/patch.mdx} +25 -15
- package/docs/{cli/pm.md → pm/cli/pm.mdx} +96 -62
- package/docs/{cli/publish.md → pm/cli/publish.mdx} +38 -35
- package/docs/pm/cli/remove.mdx +16 -0
- package/docs/{cli/update.md → pm/cli/update.mdx} +26 -15
- package/docs/{cli/why.md → pm/cli/why.mdx} +27 -10
- package/docs/{cli/filter.md → pm/filter.mdx} +26 -14
- package/docs/{install/cache.md → pm/global-cache.mdx} +25 -12
- package/docs/{install/isolated.md → pm/isolated-installs.mdx} +32 -24
- package/docs/{install/lifecycle.md → pm/lifecycle.mdx} +20 -9
- package/docs/{install/lockfile.md → pm/lockfile.mdx} +18 -12
- package/docs/{install/npmrc.md → pm/npmrc.mdx} +30 -24
- package/docs/{install/overrides.md → pm/overrides.mdx} +47 -37
- package/docs/{install/registries.md → pm/scopes-registries.mdx} +8 -3
- package/docs/{install/security-scanner-api.md → pm/security-scanner-api.mdx} +22 -8
- package/docs/{install/workspaces.md → pm/workspaces.mdx} +17 -22
- package/docs/project/{benchmarking.md → benchmarking.mdx} +26 -11
- package/docs/project/{bindgen.md → bindgen.mdx} +12 -14
- package/docs/project/{building-windows.md → building-windows.mdx} +18 -47
- package/docs/project/{contributing.md → contributing.mdx} +56 -60
- package/docs/project/feedback.mdx +20 -0
- package/docs/project/license.mdx +78 -0
- package/docs/project/roadmap.mdx +8 -0
- package/docs/quickstart.mdx +240 -0
- package/docs/runtime/{autoimport.md → auto-install.mdx} +34 -31
- package/docs/{api/binary-data.md → runtime/binary-data.mdx} +77 -269
- package/docs/runtime/bun-apis.mdx +59 -0
- package/docs/runtime/{bunfig.md → bunfig.mdx} +95 -225
- package/docs/{api/cc.md → runtime/c-compiler.mdx} +16 -9
- package/docs/{api/spawn.md → runtime/child-process.mdx} +69 -119
- package/docs/{api/color.md → runtime/color.mdx} +6 -1
- package/docs/{api/console.md → runtime/console.mdx} +17 -7
- package/docs/{api/cookie.md → runtime/cookies.mdx} +24 -19
- package/docs/runtime/{debugger.md → debugger.mdx} +61 -51
- package/docs/runtime/environment-variables.mdx +214 -0
- package/docs/{api/ffi.md → runtime/ffi.mdx} +53 -45
- package/docs/{api/file-io.md → runtime/file-io.mdx} +41 -101
- package/docs/{api/file-system-router.md → runtime/file-system-router.mdx} +8 -2
- package/docs/{bundler/loaders.md → runtime/file-types.mdx} +56 -112
- package/docs/{api/glob.md → runtime/glob.mdx} +4 -1
- package/docs/runtime/globals.mdx +72 -0
- package/docs/{api/hashing.md → runtime/hashing.mdx} +18 -22
- package/docs/{api/html-rewriter.md → runtime/html-rewriter.mdx} +36 -30
- package/docs/runtime/http/cookies.mdx +79 -0
- package/docs/runtime/http/error-handling.mdx +40 -0
- package/docs/runtime/http/metrics.mdx +36 -0
- package/docs/runtime/http/routing.mdx +289 -0
- package/docs/runtime/http/server.mdx +647 -0
- package/docs/runtime/http/tls.mdx +101 -0
- package/docs/{api/websockets.md → runtime/http/websockets.mdx} +62 -231
- package/docs/{cli/run.md → runtime/index.mdx} +70 -108
- package/docs/runtime/jsx.mdx +115 -0
- package/docs/runtime/{modules.md → module-resolution.mdx} +83 -61
- package/docs/{api/dns.md → runtime/networking/dns.mdx} +23 -22
- package/docs/{api/fetch.md → runtime/networking/fetch.mdx} +10 -5
- package/docs/{api/tcp.md → runtime/networking/tcp.mdx} +59 -41
- package/docs/{api/udp.md → runtime/networking/udp.mdx} +14 -8
- package/docs/{api/node-api.md → runtime/node-api.mdx} +5 -0
- package/docs/runtime/{nodejs-apis.md → nodejs-compat.mdx} +9 -4
- package/docs/{bundler/plugins.md → runtime/plugins.mdx} +17 -61
- package/docs/{api/redis.md → runtime/redis.mdx} +65 -80
- package/docs/{api/s3.md → runtime/s3.mdx} +79 -66
- package/docs/{api/secrets.md → runtime/secrets.mdx} +27 -10
- package/docs/{api/semver.md → runtime/semver.mdx} +9 -4
- package/docs/runtime/{shell.md → shell.mdx} +52 -20
- package/docs/{api/sql.md → runtime/sql.mdx} +129 -99
- package/docs/{api/sqlite.md → runtime/sqlite.mdx} +162 -157
- package/docs/{api/streams.md → runtime/streams.mdx} +33 -31
- package/docs/{cli/bun-create.md → runtime/templating/create.mdx} +74 -143
- package/docs/{cli/init.md → runtime/templating/init.mdx} +24 -51
- package/docs/{api/transpiler.md → runtime/transpiler.mdx} +50 -38
- package/docs/{typescript.md → runtime/typescript.mdx} +7 -2
- package/docs/{api/utils.md → runtime/utils.mdx} +81 -50
- package/docs/runtime/{hot.md → watch-mode.mdx} +53 -37
- package/docs/runtime/web-apis.mdx +29 -0
- package/docs/{api/workers.md → runtime/workers.mdx} +28 -22
- package/docs/{api/yaml.md → runtime/yaml.mdx} +33 -232
- package/docs/snippets/cli/add.mdx +166 -0
- package/docs/snippets/cli/build.mdx +196 -0
- package/docs/snippets/cli/feedback.mdx +17 -0
- package/docs/snippets/cli/init.mdx +84 -0
- package/docs/snippets/cli/install.mdx +173 -0
- package/docs/snippets/cli/link.mdx +163 -0
- package/docs/snippets/cli/outdated.mdx +140 -0
- package/docs/snippets/cli/patch.mdx +171 -0
- package/docs/snippets/cli/publish.mdx +198 -0
- package/docs/snippets/cli/remove.mdx +146 -0
- package/docs/snippets/cli/run.mdx +293 -0
- package/docs/snippets/cli/test.mdx +100 -0
- package/docs/snippets/cli/update.mdx +144 -0
- package/docs/snippets/product-card.mdx +32 -0
- package/docs/snippets/product-tiles.mdx +94 -0
- package/docs/test/code-coverage.mdx +409 -0
- package/docs/test/configuration.mdx +467 -0
- package/docs/test/{time.md → dates-times.mdx} +23 -20
- package/docs/test/{discovery.md → discovery.mdx} +15 -10
- package/docs/test/dom.mdx +226 -0
- package/docs/{cli/test.md → test/index.mdx} +77 -94
- package/docs/test/lifecycle.mdx +348 -0
- package/docs/test/mocks.mdx +637 -0
- package/docs/test/{reporters.md → reporters.mdx} +15 -15
- package/docs/test/runtime-behavior.mdx +342 -0
- package/docs/test/snapshots.mdx +434 -0
- package/docs/test/writing-tests.mdx +635 -0
- package/docs/typescript.mdx +54 -0
- package/package.json +8 -6
- package/test.d.ts +2 -2
- package/docs/api/file.md +0 -19
- package/docs/api/globals.md +0 -387
- package/docs/api/http.md +0 -1408
- package/docs/api/import-meta.md +0 -69
- package/docs/benchmarks.md +0 -120
- package/docs/bun-flavored-toml.md +0 -42
- package/docs/bundler/css_modules.md +0 -145
- package/docs/bundler/fullstack.md +0 -418
- package/docs/bundler/index.md +0 -1735
- package/docs/bundler/intro.md +0 -75
- package/docs/bundler/vs-esbuild.md +0 -1127
- package/docs/cli/bun-completions.md +0 -3
- package/docs/cli/bun-install.md +0 -349
- package/docs/cli/bun-upgrade.md +0 -39
- package/docs/cli/info.md +0 -65
- package/docs/cli/patch-commit.md +0 -11
- package/docs/cli/remove.md +0 -7
- package/docs/cli/unlink.md +0 -9
- package/docs/contributing/upgrading-webkit.md +0 -57
- package/docs/ecosystem/elysia.md +0 -24
- package/docs/ecosystem/express.md +0 -37
- package/docs/ecosystem/hono.md +0 -18
- package/docs/ecosystem/react.md +0 -65
- package/docs/ecosystem/stric.md +0 -38
- package/docs/guides/ecosystem/prisma.md +0 -141
- package/docs/guides/ecosystem/render.md +0 -79
- package/docs/guides/install/add-git.md +0 -36
- package/docs/guides/test/spy-on.md +0 -46
- package/docs/install/index.md +0 -248
- package/docs/installation.md +0 -327
- package/docs/project/asan.md +0 -124
- package/docs/project/internals/build-process-for-ci.md +0 -75
- package/docs/project/licensing.md +0 -73
- package/docs/project/roadmap.md +0 -87
- package/docs/quickstart.md +0 -157
- package/docs/runtime/bun-apis.md +0 -207
- package/docs/runtime/env.md +0 -253
- package/docs/runtime/index.md +0 -312
- package/docs/runtime/jsx.md +0 -385
- package/docs/runtime/loaders.md +0 -130
- package/docs/runtime/plugins.md +0 -561
- package/docs/runtime/typescript.md +0 -139
- package/docs/runtime/web-apis.md +0 -128
- package/docs/test/configuration.md +0 -154
- package/docs/test/coverage.md +0 -142
- package/docs/test/dom.md +0 -75
- package/docs/test/examples/concurrent-test-glob.md +0 -132
- package/docs/test/hot.md +0 -15
- package/docs/test/lifecycle.md +0 -81
- package/docs/test/mocks.md +0 -313
- package/docs/test/runtime-behavior.md +0 -95
- package/docs/test/snapshots.md +0 -68
- package/docs/test/writing.md +0 -825
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
title: S3
|
|
3
|
+
description: Bun provides fast, native bindings for interacting with S3-compatible object storage services.
|
|
4
|
+
---
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
Production servers often read, upload, and write files to S3-compatible object storage services instead of the local filesystem. Historically, that means local filesystem APIs you use in development can't be used in production. When you use Bun, things are different.
|
|
4
7
|
|
|
5
8
|
### Bun's S3 API is fast
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
<Frame caption="Left: Bun v1.1.44. Right: Node.js v23.6.0">
|
|
11
|
+
<img src="/images/bun-s3-node.gif" alt="Bun's S3 API is fast" />
|
|
12
|
+
</Frame>
|
|
10
13
|
|
|
11
14
|
Bun provides fast, native bindings for interacting with S3-compatible object storage services. Bun's S3 API is designed to be simple and feel similar to fetch's `Response` and `Blob` APIs (like Bun's local filesystem APIs).
|
|
12
15
|
|
|
13
|
-
```ts
|
|
16
|
+
```ts s3.ts icon="/icons/typescript.svg"
|
|
14
17
|
import { s3, write, S3Client } from "bun";
|
|
15
18
|
|
|
16
19
|
// Bun.s3 reads environment variables for credentials
|
|
@@ -52,7 +55,7 @@ There are several ways to interact with Bun's S3 API.
|
|
|
52
55
|
|
|
53
56
|
To explicitly set credentials, pass them to the `Bun.S3Client` constructor.
|
|
54
57
|
|
|
55
|
-
```ts
|
|
58
|
+
```ts s3.ts icon="/icons/typescript.svg"
|
|
56
59
|
import { S3Client } from "bun";
|
|
57
60
|
|
|
58
61
|
const client = new S3Client({
|
|
@@ -74,7 +77,7 @@ const client = new S3Client({
|
|
|
74
77
|
|
|
75
78
|
The **`file`** method in `S3Client` returns a **lazy reference to a file on S3**.
|
|
76
79
|
|
|
77
|
-
```ts
|
|
80
|
+
```ts s3.ts icon="/icons/typescript.svg"
|
|
78
81
|
// A lazy reference to a file on S3
|
|
79
82
|
const s3file: S3File = client.file("123.json");
|
|
80
83
|
```
|
|
@@ -85,7 +88,7 @@ Like `Bun.file(path)`, the `S3Client`'s `file` method is synchronous. It does ze
|
|
|
85
88
|
|
|
86
89
|
If you've used the `fetch` API, you're familiar with the `Response` and `Blob` APIs. `S3File` extends `Blob`. The same methods that work on `Blob` also work on `S3File`.
|
|
87
90
|
|
|
88
|
-
```ts
|
|
91
|
+
```ts s3.ts icon="/icons/typescript.svg"
|
|
89
92
|
// Read an S3File as text
|
|
90
93
|
const text = await s3file.text();
|
|
91
94
|
|
|
@@ -117,7 +120,7 @@ These helper methods not only simplify the API, they also make it faster.
|
|
|
117
120
|
|
|
118
121
|
Writing to S3 is just as simple.
|
|
119
122
|
|
|
120
|
-
```ts
|
|
123
|
+
```ts s3.ts icon="/icons/typescript.svg"
|
|
121
124
|
// Write a string (replacing the file)
|
|
122
125
|
await s3file.write("Hello World!");
|
|
123
126
|
|
|
@@ -146,7 +149,7 @@ await Bun.write(s3file, "Hello World!");
|
|
|
146
149
|
|
|
147
150
|
Bun automatically handles multipart uploads for large files and provides streaming capabilities. The same API that works for local files also works for S3 files.
|
|
148
151
|
|
|
149
|
-
```ts
|
|
152
|
+
```ts s3.ts icon="/icons/typescript.svg"
|
|
150
153
|
// Write a large file
|
|
151
154
|
const bigFile = Buffer.alloc(10 * 1024 * 1024); // 10MB
|
|
152
155
|
const writer = s3file.writer({
|
|
@@ -166,6 +169,8 @@ for (let i = 0; i < 10; i++) {
|
|
|
166
169
|
await writer.end();
|
|
167
170
|
```
|
|
168
171
|
|
|
172
|
+
---
|
|
173
|
+
|
|
169
174
|
## Presigning URLs
|
|
170
175
|
|
|
171
176
|
When your production service needs to let users upload files to your server, it's often more reliable for the user to upload directly to S3 instead of your server acting as an intermediary.
|
|
@@ -174,7 +179,7 @@ To facilitate this, you can presign URLs for S3 files. This generates a URL with
|
|
|
174
179
|
|
|
175
180
|
The default behaviour is to generate a `GET` URL that expires in 24 hours. Bun attempts to infer the content type from the file extension. If inference is not possible, it will default to `application/octet-stream`.
|
|
176
181
|
|
|
177
|
-
```ts
|
|
182
|
+
```ts s3.ts icon="/icons/typescript.svg"
|
|
178
183
|
import { s3 } from "bun";
|
|
179
184
|
|
|
180
185
|
// Generate a presigned URL that expires in 24 hours (default)
|
|
@@ -198,7 +203,7 @@ const presignedFile = myFile.presign({
|
|
|
198
203
|
|
|
199
204
|
To set an ACL (access control list) on a presigned URL, pass the `acl` option:
|
|
200
205
|
|
|
201
|
-
```ts
|
|
206
|
+
```ts s3.ts icon="/icons/typescript.svg"
|
|
202
207
|
const url = s3file.presign({
|
|
203
208
|
acl: "public-read",
|
|
204
209
|
expiresIn: 3600,
|
|
@@ -222,7 +227,7 @@ You can pass any of the following ACLs:
|
|
|
222
227
|
|
|
223
228
|
To set an expiration time for a presigned URL, pass the `expiresIn` option.
|
|
224
229
|
|
|
225
|
-
```ts
|
|
230
|
+
```ts s3.ts icon="/icons/typescript.svg"
|
|
226
231
|
const url = s3file.presign({
|
|
227
232
|
// Seconds
|
|
228
233
|
expiresIn: 3600, // 1 hour
|
|
@@ -239,7 +244,7 @@ const url = s3file.presign({
|
|
|
239
244
|
|
|
240
245
|
To set the HTTP method for a presigned URL, pass the `method` option.
|
|
241
246
|
|
|
242
|
-
```ts
|
|
247
|
+
```ts s3.ts icon="/icons/typescript.svg"
|
|
243
248
|
const url = s3file.presign({
|
|
244
249
|
method: "PUT",
|
|
245
250
|
// method: "DELETE",
|
|
@@ -254,14 +259,14 @@ const url = s3file.presign({
|
|
|
254
259
|
|
|
255
260
|
To quickly redirect users to a presigned URL for an S3 file, pass an `S3File` instance to a `Response` object as the body.
|
|
256
261
|
|
|
257
|
-
|
|
262
|
+
This will automatically redirect the user to the presigned URL for the S3 file, saving you the memory, time, and bandwidth cost of downloading the file to your server and sending it back to the user.
|
|
263
|
+
|
|
264
|
+
```ts s3.ts icon="/icons/typescript.svg"
|
|
258
265
|
const response = new Response(s3file);
|
|
259
266
|
console.log(response);
|
|
260
267
|
```
|
|
261
268
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
```ts
|
|
269
|
+
```txt
|
|
265
270
|
Response (0 KB) {
|
|
266
271
|
ok: false,
|
|
267
272
|
url: "",
|
|
@@ -275,6 +280,8 @@ Response (0 KB) {
|
|
|
275
280
|
}
|
|
276
281
|
```
|
|
277
282
|
|
|
283
|
+
---
|
|
284
|
+
|
|
278
285
|
## Support for S3-Compatible Services
|
|
279
286
|
|
|
280
287
|
Bun's S3 implementation works with any S3-compatible storage service. Just specify the appropriate endpoint:
|
|
@@ -283,7 +290,7 @@ Bun's S3 implementation works with any S3-compatible storage service. Just speci
|
|
|
283
290
|
|
|
284
291
|
AWS S3 is the default. You can also pass a `region` option instead of an `endpoint` option for AWS S3.
|
|
285
292
|
|
|
286
|
-
```ts
|
|
293
|
+
```ts s3.ts icon="/icons/typescript.svg"
|
|
287
294
|
import { S3Client } from "bun";
|
|
288
295
|
|
|
289
296
|
// AWS S3
|
|
@@ -300,7 +307,7 @@ const s3 = new S3Client({
|
|
|
300
307
|
|
|
301
308
|
To use Bun's S3 client with [Google Cloud Storage](https://cloud.google.com/storage), set `endpoint` to `"https://storage.googleapis.com"` in the `S3Client` constructor.
|
|
302
309
|
|
|
303
|
-
```ts
|
|
310
|
+
```ts s3.ts icon="/icons/typescript.svg" highlight={8}
|
|
304
311
|
import { S3Client } from "bun";
|
|
305
312
|
|
|
306
313
|
// Google Cloud Storage
|
|
@@ -316,7 +323,7 @@ const gcs = new S3Client({
|
|
|
316
323
|
|
|
317
324
|
To use Bun's S3 client with [Cloudflare R2](https://developers.cloudflare.com/r2/), set `endpoint` to the R2 endpoint in the `S3Client` constructor. The R2 endpoint includes your account ID.
|
|
318
325
|
|
|
319
|
-
```ts
|
|
326
|
+
```ts s3.ts icon="/icons/typescript.svg" highlight={8}
|
|
320
327
|
import { S3Client } from "bun";
|
|
321
328
|
|
|
322
329
|
// CloudFlare R2
|
|
@@ -332,7 +339,7 @@ const r2 = new S3Client({
|
|
|
332
339
|
|
|
333
340
|
To use Bun's S3 client with [DigitalOcean Spaces](https://www.digitalocean.com/products/spaces/), set `endpoint` to the DigitalOcean Spaces endpoint in the `S3Client` constructor.
|
|
334
341
|
|
|
335
|
-
```ts
|
|
342
|
+
```ts s3.ts icon="/icons/typescript.svg" highlight={8}
|
|
336
343
|
import { S3Client } from "bun";
|
|
337
344
|
|
|
338
345
|
const spaces = new S3Client({
|
|
@@ -348,7 +355,7 @@ const spaces = new S3Client({
|
|
|
348
355
|
|
|
349
356
|
To use Bun's S3 client with [MinIO](https://min.io/), set `endpoint` to the URL that MinIO is running on in the `S3Client` constructor.
|
|
350
357
|
|
|
351
|
-
```ts
|
|
358
|
+
```ts s3.ts icon="/icons/typescript.svg" highlight={10}
|
|
352
359
|
import { S3Client } from "bun";
|
|
353
360
|
|
|
354
361
|
const minio = new S3Client({
|
|
@@ -364,9 +371,9 @@ const minio = new S3Client({
|
|
|
364
371
|
|
|
365
372
|
### Using Bun's S3Client with supabase
|
|
366
373
|
|
|
367
|
-
To use Bun's S3 client with [supabase](https://supabase.com/), set `endpoint` to the supabase endpoint in the `S3Client` constructor. The supabase endpoint includes your account ID and /storage/v1/s3 path. Make sure to set Enable connection via S3 protocol on in the supabase dashboard in https://supabase.com/dashboard/project/<account-id>/settings/storage and to set the region informed in the same section.
|
|
374
|
+
To use Bun's S3 client with [supabase](https://supabase.com/), set `endpoint` to the supabase endpoint in the `S3Client` constructor. The supabase endpoint includes your account ID and /storage/v1/s3 path. Make sure to set Enable connection via S3 protocol on in the supabase dashboard in `https://supabase.com/dashboard/project/<account-id>/settings/storage` and to set the region informed in the same section.
|
|
368
375
|
|
|
369
|
-
```ts
|
|
376
|
+
```ts s3.ts icon="/icons/typescript.svg" highlight={3-10}
|
|
370
377
|
import { S3Client } from "bun";
|
|
371
378
|
|
|
372
379
|
const supabase = new S3Client({
|
|
@@ -380,9 +387,15 @@ const supabase = new S3Client({
|
|
|
380
387
|
|
|
381
388
|
### Using Bun's S3Client with S3 Virtual Hosted-Style endpoints
|
|
382
389
|
|
|
383
|
-
When using a S3 Virtual Hosted-Style endpoint, you need to set the `virtualHostedStyle` option to `true
|
|
390
|
+
When using a S3 Virtual Hosted-Style endpoint, you need to set the `virtualHostedStyle` option to `true`.
|
|
384
391
|
|
|
385
|
-
|
|
392
|
+
<Note>
|
|
393
|
+
- If you don’t specify an endpoint, Bun will automatically determine the AWS S3 endpoint using the provided region and
|
|
394
|
+
bucket. - If no region is specified, Bun defaults to us-east-1. - If you explicitly provide an endpoint, you don’t
|
|
395
|
+
need to specify a bucket name.
|
|
396
|
+
</Note>
|
|
397
|
+
|
|
398
|
+
```ts s3.ts icon="/icons/typescript.svg" highlight={17, 25}
|
|
386
399
|
import { S3Client } from "bun";
|
|
387
400
|
|
|
388
401
|
// AWS S3 endpoint inferred from region and bucket
|
|
@@ -390,7 +403,7 @@ const s3 = new S3Client({
|
|
|
390
403
|
accessKeyId: "access-key",
|
|
391
404
|
secretAccessKey: "secret-key",
|
|
392
405
|
bucket: "my-bucket",
|
|
393
|
-
virtualHostedStyle: true,
|
|
406
|
+
virtualHostedStyle: true, // [!code ++]
|
|
394
407
|
// endpoint: "https://my-bucket.s3.us-east-1.amazonaws.com",
|
|
395
408
|
// region: "us-east-1",
|
|
396
409
|
});
|
|
@@ -400,7 +413,7 @@ const s3WithEndpoint = new S3Client({
|
|
|
400
413
|
accessKeyId: "access-key",
|
|
401
414
|
secretAccessKey: "secret-key",
|
|
402
415
|
endpoint: "https://<bucket-name>.s3.<region>.amazonaws.com",
|
|
403
|
-
virtualHostedStyle: true,
|
|
416
|
+
virtualHostedStyle: true, // [!code ++]
|
|
404
417
|
});
|
|
405
418
|
|
|
406
419
|
// Cloudflare R2
|
|
@@ -408,10 +421,12 @@ const r2WithEndpoint = new S3Client({
|
|
|
408
421
|
accessKeyId: "access-key",
|
|
409
422
|
secretAccessKey: "secret-key",
|
|
410
423
|
endpoint: "https://<bucket-name>.<account-id>.r2.cloudflarestorage.com",
|
|
411
|
-
virtualHostedStyle: true,
|
|
424
|
+
virtualHostedStyle: true, // [!code ++]
|
|
412
425
|
});
|
|
413
426
|
```
|
|
414
427
|
|
|
428
|
+
---
|
|
429
|
+
|
|
415
430
|
## Credentials
|
|
416
431
|
|
|
417
432
|
Credentials are one of the hardest parts of using S3, and we've tried to make it as easy as possible. By default, Bun reads the following environment variables for credentials.
|
|
@@ -436,7 +451,7 @@ If the `S3_*` environment variable is not set, Bun will also check for the `AWS_
|
|
|
436
451
|
| `bucket` | `AWS_BUCKET` |
|
|
437
452
|
| `sessionToken` | `AWS_SESSION_TOKEN` |
|
|
438
453
|
|
|
439
|
-
These environment variables are read from [`.env` files](/
|
|
454
|
+
These environment variables are read from [`.env` files](/runtime/environment-variables) or from the process environment at initialization time (`process.env` is not used for this).
|
|
440
455
|
|
|
441
456
|
These defaults are overridden by the options you pass to `s3.file(credentials)`, `new Bun.S3Client(credentials)`, or any of the methods that accept credentials. So if, for example, you use the same credentials for different buckets, you can set the credentials once in your `.env` file and then pass `bucket: "my-bucket"` to the `s3.file()` function without having to specify all the credentials again.
|
|
442
457
|
|
|
@@ -444,7 +459,7 @@ These defaults are overridden by the options you pass to `s3.file(credentials)`,
|
|
|
444
459
|
|
|
445
460
|
When you're not using environment variables or using multiple buckets, you can create a `S3Client` object to explicitly set credentials.
|
|
446
461
|
|
|
447
|
-
```ts
|
|
462
|
+
```ts s3.ts icon="/icons/typescript.svg" highlight={3-11}
|
|
448
463
|
import { S3Client } from "bun";
|
|
449
464
|
|
|
450
465
|
const client = new S3Client({
|
|
@@ -474,13 +489,14 @@ await file.delete();
|
|
|
474
489
|
|
|
475
490
|
To upload or write a file to S3, call `write` on the `S3Client` instance.
|
|
476
491
|
|
|
477
|
-
```ts
|
|
492
|
+
```ts s3.ts icon="/icons/typescript.svg" highlight={8, 9}
|
|
478
493
|
const client = new Bun.S3Client({
|
|
479
494
|
accessKeyId: "your-access-key",
|
|
480
495
|
secretAccessKey: "your-secret-key",
|
|
481
496
|
endpoint: "https://s3.us-east-1.amazonaws.com",
|
|
482
497
|
bucket: "my-bucket",
|
|
483
498
|
});
|
|
499
|
+
|
|
484
500
|
await client.write("my-file.txt", "Hello World!");
|
|
485
501
|
await client.write("my-file.txt", new Response("Hello World!"));
|
|
486
502
|
|
|
@@ -492,7 +508,7 @@ await client.write("my-file.txt", new Response("Hello World!"));
|
|
|
492
508
|
|
|
493
509
|
To delete a file from S3, call `delete` on the `S3Client` instance.
|
|
494
510
|
|
|
495
|
-
```ts
|
|
511
|
+
```ts s3.ts icon="/icons/typescript.svg" highlight={7}
|
|
496
512
|
const client = new Bun.S3Client({
|
|
497
513
|
accessKeyId: "your-access-key",
|
|
498
514
|
secretAccessKey: "your-secret-key",
|
|
@@ -508,7 +524,7 @@ await client.delete("my-file.txt");
|
|
|
508
524
|
|
|
509
525
|
To check if a file exists in S3, call `exists` on the `S3Client` instance.
|
|
510
526
|
|
|
511
|
-
```ts
|
|
527
|
+
```ts s3.ts icon="/icons/typescript.svg" highlight={7}
|
|
512
528
|
const client = new Bun.S3Client({
|
|
513
529
|
accessKeyId: "your-access-key",
|
|
514
530
|
secretAccessKey: "your-secret-key",
|
|
@@ -524,7 +540,7 @@ const exists = await client.exists("my-file.txt");
|
|
|
524
540
|
|
|
525
541
|
`S3File` instances are created by calling the `S3Client` instance method or the `s3.file()` function. Like `Bun.file()`, `S3File` instances are lazy. They don't refer to something that necessarily exists at the time of creation. That's why all the methods that don't involve network requests are fully synchronous.
|
|
526
542
|
|
|
527
|
-
```ts
|
|
543
|
+
```ts Type Reference icon="/icons/typescript.svg" expandable
|
|
528
544
|
interface S3File extends Blob {
|
|
529
545
|
slice(start: number, end?: number): S3File;
|
|
530
546
|
exists(): Promise<boolean>;
|
|
@@ -536,14 +552,7 @@ interface S3File extends Blob {
|
|
|
536
552
|
arrayBuffer(): Promise<ArrayBuffer>;
|
|
537
553
|
stream(options: S3Options): ReadableStream;
|
|
538
554
|
write(
|
|
539
|
-
data:
|
|
540
|
-
| string
|
|
541
|
-
| Uint8Array
|
|
542
|
-
| ArrayBuffer
|
|
543
|
-
| Blob
|
|
544
|
-
| ReadableStream
|
|
545
|
-
| Response
|
|
546
|
-
| Request,
|
|
555
|
+
data: string | Uint8Array | ArrayBuffer | Blob | ReadableStream | Response | Request,
|
|
547
556
|
options?: BlobPropertyBag,
|
|
548
557
|
): Promise<number>;
|
|
549
558
|
|
|
@@ -580,7 +589,7 @@ That means using `S3File` instances with `fetch()`, `Response`, and other web AP
|
|
|
580
589
|
|
|
581
590
|
To read a partial range of a file, you can use the `slice` method.
|
|
582
591
|
|
|
583
|
-
```ts
|
|
592
|
+
```ts s3.ts icon="/icons/typescript.svg" highlight={1}
|
|
584
593
|
const partial = s3file.slice(0, 1024);
|
|
585
594
|
|
|
586
595
|
// Read the partial range as a Uint8Array
|
|
@@ -596,7 +605,7 @@ Internally, this works by using the HTTP `Range` header to request only the byte
|
|
|
596
605
|
|
|
597
606
|
To delete a file from S3, you can use the `delete` method.
|
|
598
607
|
|
|
599
|
-
```ts
|
|
608
|
+
```ts s3.ts icon="/icons/typescript.svg" highlight={1}
|
|
600
609
|
await s3file.delete();
|
|
601
610
|
// await s3File.unlink();
|
|
602
611
|
```
|
|
@@ -624,7 +633,7 @@ The `S3Client` class provides several static methods for interacting with S3.
|
|
|
624
633
|
|
|
625
634
|
To write data directly to a path in the bucket, you can use the `S3Client.write` static method.
|
|
626
635
|
|
|
627
|
-
```ts
|
|
636
|
+
```ts s3.ts icon="/icons/typescript.svg" highlight={12, 15-18, 22, 25-29}
|
|
628
637
|
import { S3Client } from "bun";
|
|
629
638
|
|
|
630
639
|
const credentials = {
|
|
@@ -662,7 +671,7 @@ This is equivalent to calling `new S3Client(credentials).write("my-file.txt", "H
|
|
|
662
671
|
|
|
663
672
|
To generate a presigned URL for an S3 file, you can use the `S3Client.presign` static method.
|
|
664
673
|
|
|
665
|
-
```ts
|
|
674
|
+
```ts s3.ts icon="/icons/typescript.svg" highlight={11-14}
|
|
666
675
|
import { S3Client } from "bun";
|
|
667
676
|
|
|
668
677
|
const credentials = {
|
|
@@ -685,10 +694,10 @@ This is equivalent to calling `new S3Client(credentials).presign("my-file.txt",
|
|
|
685
694
|
|
|
686
695
|
To list some or all (up to 1,000) objects in a bucket, you can use the `S3Client.list` static method.
|
|
687
696
|
|
|
688
|
-
```ts
|
|
697
|
+
```ts s3.ts icon="/icons/typescript.svg" highlight={12, 15-20, 24-29}
|
|
689
698
|
import { S3Client } from "bun";
|
|
690
699
|
|
|
691
|
-
const credentials = {
|
|
700
|
+
const credentials = { ... }
|
|
692
701
|
accessKeyId: "your-access-key",
|
|
693
702
|
secretAccessKey: "your-secret-key",
|
|
694
703
|
bucket: "my-bucket",
|
|
@@ -724,7 +733,7 @@ This is equivalent to calling `new S3Client(credentials).list()`.
|
|
|
724
733
|
|
|
725
734
|
To check if an S3 file exists, you can use the `S3Client.exists` static method.
|
|
726
735
|
|
|
727
|
-
```ts
|
|
736
|
+
```ts s3.ts icon="/icons/typescript.svg" highlight={11}
|
|
728
737
|
import { S3Client } from "bun";
|
|
729
738
|
|
|
730
739
|
const credentials = {
|
|
@@ -740,12 +749,13 @@ const exists = await S3Client.exists("my-file.txt", credentials);
|
|
|
740
749
|
|
|
741
750
|
The same method also works on `S3File` instances.
|
|
742
751
|
|
|
743
|
-
```ts
|
|
752
|
+
```ts s3.ts icon="/icons/typescript.svg" highlight=7}
|
|
744
753
|
import { s3 } from "bun";
|
|
745
754
|
|
|
746
755
|
const s3file = s3.file("my-file.txt", {
|
|
747
|
-
...credentials,
|
|
756
|
+
// ...credentials,
|
|
748
757
|
});
|
|
758
|
+
|
|
749
759
|
const exists = await s3file.exists();
|
|
750
760
|
```
|
|
751
761
|
|
|
@@ -753,7 +763,7 @@ const exists = await s3file.exists();
|
|
|
753
763
|
|
|
754
764
|
To quickly check the size of S3 file without downloading it, you can use the `S3Client.size` static method.
|
|
755
765
|
|
|
756
|
-
```ts
|
|
766
|
+
```ts s3.ts icon="/icons/typescript.svg" highlight={11}
|
|
757
767
|
import { S3Client } from "bun";
|
|
758
768
|
|
|
759
769
|
const credentials = {
|
|
@@ -773,7 +783,7 @@ This is equivalent to calling `new S3Client(credentials).size("my-file.txt")`.
|
|
|
773
783
|
|
|
774
784
|
To get the size, etag, and other metadata of an S3 file, you can use the `S3Client.stat` static method.
|
|
775
785
|
|
|
776
|
-
```ts
|
|
786
|
+
```ts s3.ts icon="/icons/typescript.svg"
|
|
777
787
|
import { S3Client } from "bun";
|
|
778
788
|
|
|
779
789
|
const credentials = {
|
|
@@ -785,19 +795,22 @@ const credentials = {
|
|
|
785
795
|
};
|
|
786
796
|
|
|
787
797
|
const stat = await S3Client.stat("my-file.txt", credentials);
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
798
|
+
```
|
|
799
|
+
|
|
800
|
+
```txt
|
|
801
|
+
{
|
|
802
|
+
etag: "\"7a30b741503c0b461cc14157e2df4ad8\"",
|
|
803
|
+
lastModified: 2025-01-07T00:19:10.000Z,
|
|
804
|
+
size: 1024,
|
|
805
|
+
type: "text/plain;charset=utf-8",
|
|
806
|
+
}
|
|
794
807
|
```
|
|
795
808
|
|
|
796
809
|
### `S3Client.delete` (static)
|
|
797
810
|
|
|
798
811
|
To delete an S3 file, you can use the `S3Client.delete` static method.
|
|
799
812
|
|
|
800
|
-
```ts
|
|
813
|
+
```ts s3.ts icon="/icons/typescript.svg" highlight={10, 15}
|
|
801
814
|
import { S3Client } from "bun";
|
|
802
815
|
|
|
803
816
|
const credentials = {
|
|
@@ -819,14 +832,14 @@ await S3Client.unlink("my-file.txt", credentials);
|
|
|
819
832
|
|
|
820
833
|
To make it easier to use the same code for local files and S3 files, the `s3://` protocol is supported in `fetch` and `Bun.file()`.
|
|
821
834
|
|
|
822
|
-
```ts
|
|
835
|
+
```ts s3.ts icon="/icons/typescript.svg"
|
|
823
836
|
const response = await fetch("s3://my-bucket/my-file.txt");
|
|
824
837
|
const file = Bun.file("s3://my-bucket/my-file.txt");
|
|
825
838
|
```
|
|
826
839
|
|
|
827
840
|
You can additionally pass `s3` options to the `fetch` and `Bun.file` functions.
|
|
828
841
|
|
|
829
|
-
```ts
|
|
842
|
+
```ts s3.ts icon="/icons/typescript.svg" highlight={2-6}
|
|
830
843
|
const response = await fetch("s3://my-bucket/my-file.txt", {
|
|
831
844
|
s3: {
|
|
832
845
|
accessKeyId: "your-access-key",
|
|
@@ -834,7 +847,7 @@ const response = await fetch("s3://my-bucket/my-file.txt", {
|
|
|
834
847
|
endpoint: "https://s3.us-east-1.amazonaws.com",
|
|
835
848
|
},
|
|
836
849
|
headers: {
|
|
837
|
-
|
|
850
|
+
range: "bytes=0-1023",
|
|
838
851
|
},
|
|
839
852
|
});
|
|
840
853
|
```
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Secrets
|
|
3
|
+
description: Use Bun's Secrets API to store and retrieve sensitive credentials securely
|
|
4
|
+
---
|
|
5
|
+
|
|
1
6
|
Store and retrieve sensitive credentials securely using the operating system's native credential storage APIs.
|
|
2
7
|
|
|
3
|
-
|
|
8
|
+
<Warning>This API is new and experimental. It may change in the future.</Warning>
|
|
4
9
|
|
|
5
|
-
```typescript
|
|
10
|
+
```typescript index.ts icon="/icons/typescript.svg"
|
|
6
11
|
import { secrets } from "bun";
|
|
7
12
|
|
|
8
13
|
const githubToken = await secrets.get({
|
|
@@ -12,7 +17,7 @@ const githubToken = await secrets.get({
|
|
|
12
17
|
|
|
13
18
|
if (!githubToken) {
|
|
14
19
|
const response = await fetch("https://api.github.com/name", {
|
|
15
|
-
headers: {
|
|
20
|
+
headers: { Authorization: `token ${githubToken}` },
|
|
16
21
|
});
|
|
17
22
|
console.log("Please enter your GitHub token");
|
|
18
23
|
} else {
|
|
@@ -25,6 +30,8 @@ if (!githubToken) {
|
|
|
25
30
|
}
|
|
26
31
|
```
|
|
27
32
|
|
|
33
|
+
---
|
|
34
|
+
|
|
28
35
|
## Overview
|
|
29
36
|
|
|
30
37
|
`Bun.secrets` provides a cross-platform API for managing sensitive credentials that CLI tools and development applications typically store in plaintext files like `~/.npmrc`, `~/.aws/credentials`, or `.env` files. It uses:
|
|
@@ -35,7 +42,12 @@ if (!githubToken) {
|
|
|
35
42
|
|
|
36
43
|
All operations are asynchronous and non-blocking, running on Bun's threadpool.
|
|
37
44
|
|
|
38
|
-
Note
|
|
45
|
+
<Note>
|
|
46
|
+
In the future, we may add an additional `provider` option to make this better for production deployment secrets, but
|
|
47
|
+
today this API is mostly useful for local development tools.
|
|
48
|
+
</Note>
|
|
49
|
+
|
|
50
|
+
---
|
|
39
51
|
|
|
40
52
|
## API
|
|
41
53
|
|
|
@@ -112,6 +124,8 @@ const deleted = await Bun.secrets.delete({
|
|
|
112
124
|
|
|
113
125
|
- `Promise<boolean>` - `true` if a credential was deleted, `false` if not found
|
|
114
126
|
|
|
127
|
+
---
|
|
128
|
+
|
|
115
129
|
## Examples
|
|
116
130
|
|
|
117
131
|
### Storing CLI Tool Credentials
|
|
@@ -143,7 +157,7 @@ const token = await Bun.secrets.get({
|
|
|
143
157
|
if (token) {
|
|
144
158
|
const response = await fetch("https://api.github.com/name", {
|
|
145
159
|
headers: {
|
|
146
|
-
|
|
160
|
+
Authorization: `token ${token}`,
|
|
147
161
|
},
|
|
148
162
|
});
|
|
149
163
|
}
|
|
@@ -218,6 +232,8 @@ await Bun.secrets.set({
|
|
|
218
232
|
// The old password is replaced
|
|
219
233
|
```
|
|
220
234
|
|
|
235
|
+
---
|
|
236
|
+
|
|
221
237
|
## Platform Behavior
|
|
222
238
|
|
|
223
239
|
### macOS (Keychain)
|
|
@@ -259,6 +275,8 @@ await Bun.secrets.set({
|
|
|
259
275
|
- macOS: Keychain Access must be available
|
|
260
276
|
- Windows: Credential Manager service must be enabled
|
|
261
277
|
|
|
278
|
+
---
|
|
279
|
+
|
|
262
280
|
## Comparison with Environment Variables
|
|
263
281
|
|
|
264
282
|
Unlike environment variables, `Bun.secrets`:
|
|
@@ -271,6 +289,8 @@ Unlike environment variables, `Bun.secrets`:
|
|
|
271
289
|
- ❌ Requires OS credential service
|
|
272
290
|
- ❌ Not very useful for deployment secrets (use environment variables in production)
|
|
273
291
|
|
|
292
|
+
---
|
|
293
|
+
|
|
274
294
|
## Best Practices
|
|
275
295
|
|
|
276
296
|
1. **Use descriptive service names**: Match the tool or application name
|
|
@@ -294,6 +314,8 @@ Unlike environment variables, `Bun.secrets`:
|
|
|
294
314
|
- ✅ Personal API keys for testing
|
|
295
315
|
- ❌ Production servers (use proper secret management)
|
|
296
316
|
|
|
317
|
+
---
|
|
318
|
+
|
|
297
319
|
## TypeScript
|
|
298
320
|
|
|
299
321
|
```typescript
|
|
@@ -312,8 +334,3 @@ namespace Bun {
|
|
|
312
334
|
const secrets: Secrets;
|
|
313
335
|
}
|
|
314
336
|
```
|
|
315
|
-
|
|
316
|
-
## See Also
|
|
317
|
-
|
|
318
|
-
- [Environment Variables](./env.md) - For deployment configuration
|
|
319
|
-
- [Bun.password](./password.md) - For password hashing and verification
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Semver
|
|
3
|
+
description: Use Bun's semantic versioning API
|
|
4
|
+
---
|
|
5
|
+
|
|
1
6
|
Bun implements a semantic versioning API which can be used to compare versions and determine if a version is compatible with another range of versions. The versions and ranges are designed to be compatible with `node-semver`, which is used by npm clients.
|
|
2
7
|
|
|
3
8
|
It's about 20x faster than `node-semver`.
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
<Frame></Frame>
|
|
6
11
|
|
|
7
|
-
Currently, this API provides two functions
|
|
12
|
+
Currently, this API provides two functions:
|
|
8
13
|
|
|
9
|
-
|
|
14
|
+
## `Bun.semver.satisfies(version: string, range: string): boolean`
|
|
10
15
|
|
|
11
16
|
Returns `true` if `version` satisfies `range`, otherwise `false`.
|
|
12
17
|
|
|
@@ -31,7 +36,7 @@ semver.satisfies("1.0.0", "1.0.0 - 1.0.1"); // true
|
|
|
31
36
|
|
|
32
37
|
If `range` is invalid, it returns false. If `version` is invalid, it returns false.
|
|
33
38
|
|
|
34
|
-
|
|
39
|
+
## `Bun.semver.order(versionA: string, versionB: string): 0 | 1 | -1`
|
|
35
40
|
|
|
36
41
|
Returns `0` if `versionA` and `versionB` are equal, `1` if `versionA` is greater than `versionB`, and `-1` if `versionA` is less than `versionB`.
|
|
37
42
|
|