bun-types 1.3.3 → 1.3.4-canary.20251125T140733
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/CLAUDE.md +3 -3
- package/docs/bundler/css.mdx +1 -1
- package/docs/bundler/executables.mdx +33 -4
- package/docs/bundler/fullstack.mdx +3 -3
- package/docs/bundler/hot-reloading.mdx +2 -2
- package/docs/bundler/html-static.mdx +10 -9
- package/docs/bundler/index.mdx +27 -18
- package/docs/bundler/loaders.mdx +2 -2
- package/docs/bundler/macros.mdx +1 -1
- package/docs/feedback.mdx +2 -12
- package/docs/guides/binary/arraybuffer-to-array.mdx +1 -1
- package/docs/guides/binary/arraybuffer-to-blob.mdx +1 -1
- package/docs/guides/binary/arraybuffer-to-buffer.mdx +1 -1
- package/docs/guides/binary/arraybuffer-to-string.mdx +1 -1
- package/docs/guides/binary/arraybuffer-to-typedarray.mdx +1 -1
- package/docs/guides/binary/blob-to-arraybuffer.mdx +1 -1
- package/docs/guides/binary/blob-to-dataview.mdx +1 -1
- package/docs/guides/binary/blob-to-stream.mdx +1 -1
- package/docs/guides/binary/blob-to-string.mdx +1 -1
- package/docs/guides/binary/blob-to-typedarray.mdx +1 -1
- package/docs/guides/binary/buffer-to-arraybuffer.mdx +1 -1
- package/docs/guides/binary/buffer-to-blob.mdx +1 -1
- package/docs/guides/binary/buffer-to-readablestream.mdx +1 -1
- package/docs/guides/binary/buffer-to-string.mdx +1 -1
- package/docs/guides/binary/buffer-to-typedarray.mdx +1 -1
- package/docs/guides/binary/dataview-to-string.mdx +1 -1
- package/docs/guides/binary/typedarray-to-arraybuffer.mdx +1 -1
- package/docs/guides/binary/typedarray-to-blob.mdx +1 -1
- package/docs/guides/binary/typedarray-to-buffer.mdx +1 -1
- package/docs/guides/binary/typedarray-to-dataview.mdx +1 -1
- package/docs/guides/binary/typedarray-to-readablestream.mdx +1 -1
- package/docs/guides/binary/typedarray-to-string.mdx +1 -1
- package/docs/guides/deployment/aws-lambda.mdx +6 -6
- package/docs/guides/deployment/digital-ocean.mdx +7 -7
- package/docs/guides/deployment/vercel.mdx +1 -3
- package/docs/guides/ecosystem/discordjs.mdx +2 -2
- package/docs/guides/ecosystem/express.mdx +2 -2
- package/docs/guides/ecosystem/mongoose.mdx +1 -1
- package/docs/guides/ecosystem/neon-drizzle.mdx +2 -2
- package/docs/guides/ecosystem/neon-serverless-postgres.mdx +2 -2
- package/docs/guides/ecosystem/nuxt.mdx +1 -1
- package/docs/guides/ecosystem/prisma-postgres.mdx +1 -1
- package/docs/guides/ecosystem/prisma.mdx +1 -1
- package/docs/guides/ecosystem/qwik.mdx +4 -4
- package/docs/guides/ecosystem/sentry.mdx +2 -2
- package/docs/guides/ecosystem/sveltekit.mdx +1 -1
- package/docs/guides/ecosystem/tanstack-start.mdx +0 -1
- package/docs/guides/ecosystem/upstash.mdx +2 -2
- package/docs/guides/ecosystem/vite.mdx +2 -2
- package/docs/guides/html-rewriter/extract-links.mdx +2 -2
- package/docs/guides/html-rewriter/extract-social-meta.mdx +1 -1
- package/docs/guides/http/file-uploads.mdx +1 -1
- package/docs/guides/http/hot.mdx +1 -1
- package/docs/guides/http/server.mdx +1 -1
- package/docs/guides/http/simple.mdx +1 -1
- package/docs/guides/http/stream-file.mdx +3 -3
- package/docs/guides/http/tls.mdx +1 -1
- package/docs/guides/install/add-dev.mdx +1 -1
- package/docs/guides/install/add-git.mdx +1 -1
- package/docs/guides/install/add-optional.mdx +1 -1
- package/docs/guides/install/add-peer.mdx +3 -3
- package/docs/guides/install/add-tarball.mdx +1 -1
- package/docs/guides/install/add.mdx +1 -1
- package/docs/guides/install/azure-artifacts.mdx +3 -3
- package/docs/guides/install/custom-registry.mdx +2 -2
- package/docs/guides/install/from-npm-install-to-bun-install.mdx +1 -1
- package/docs/guides/install/git-diff-bun-lockfile.mdx +2 -1
- package/docs/guides/install/npm-alias.mdx +1 -1
- package/docs/guides/install/registry-scope.mdx +3 -3
- package/docs/guides/install/trusted.mdx +1 -1
- package/docs/guides/install/workspaces.mdx +1 -1
- package/docs/guides/install/yarnlock.mdx +4 -3
- package/docs/guides/process/ctrl-c.mdx +1 -1
- package/docs/guides/process/ipc.mdx +2 -2
- package/docs/guides/process/nanoseconds.mdx +1 -1
- package/docs/guides/process/os-signals.mdx +1 -1
- package/docs/guides/process/spawn-stderr.mdx +2 -2
- package/docs/guides/process/spawn-stdout.mdx +2 -2
- package/docs/guides/process/spawn.mdx +2 -2
- package/docs/guides/process/stdin.mdx +1 -1
- package/docs/guides/read-file/arraybuffer.mdx +2 -2
- package/docs/guides/read-file/buffer.mdx +1 -1
- package/docs/guides/read-file/exists.mdx +1 -1
- package/docs/guides/read-file/mime.mdx +1 -1
- package/docs/guides/read-file/stream.mdx +1 -1
- package/docs/guides/read-file/uint8array.mdx +1 -1
- package/docs/guides/read-file/watch.mdx +1 -1
- package/docs/guides/runtime/build-time-constants.mdx +3 -3
- package/docs/guides/runtime/cicd.mdx +1 -1
- package/docs/guides/runtime/codesign-macos-executable.mdx +1 -1
- package/docs/guides/runtime/delete-directory.mdx +1 -1
- package/docs/guides/runtime/delete-file.mdx +1 -1
- package/docs/guides/runtime/heap-snapshot.mdx +1 -1
- package/docs/guides/runtime/import-json.mdx +1 -1
- package/docs/guides/runtime/import-toml.mdx +1 -1
- package/docs/guides/runtime/import-yaml.mdx +1 -1
- package/docs/guides/runtime/read-env.mdx +1 -1
- package/docs/guides/runtime/set-env.mdx +2 -2
- package/docs/guides/runtime/shell.mdx +1 -1
- package/docs/guides/runtime/tsconfig-paths.mdx +1 -1
- package/docs/guides/runtime/typescript.mdx +1 -1
- package/docs/guides/runtime/vscode-debugger.mdx +1 -2
- package/docs/guides/runtime/web-debugger.mdx +1 -1
- package/docs/guides/streams/to-array.mdx +1 -1
- package/docs/guides/streams/to-arraybuffer.mdx +1 -1
- package/docs/guides/streams/to-blob.mdx +1 -1
- package/docs/guides/streams/to-buffer.mdx +1 -1
- package/docs/guides/streams/to-json.mdx +1 -1
- package/docs/guides/streams/to-string.mdx +1 -1
- package/docs/guides/streams/to-typedarray.mdx +1 -1
- package/docs/guides/test/bail.mdx +1 -1
- package/docs/guides/test/concurrent-test-glob.mdx +5 -2
- package/docs/guides/test/coverage-threshold.mdx +1 -1
- package/docs/guides/test/coverage.mdx +1 -1
- package/docs/guides/test/happy-dom.mdx +1 -1
- package/docs/guides/test/migrate-from-jest.mdx +7 -7
- package/docs/guides/test/mock-clock.mdx +2 -2
- package/docs/guides/test/mock-functions.mdx +1 -1
- package/docs/guides/test/rerun-each.mdx +1 -1
- package/docs/guides/test/run-tests.mdx +2 -2
- package/docs/guides/test/skip-tests.mdx +2 -2
- package/docs/guides/test/snapshot.mdx +4 -4
- package/docs/guides/test/spy-on.mdx +1 -1
- package/docs/guides/test/svelte-test.mdx +4 -4
- package/docs/guides/test/testing-library.mdx +3 -3
- package/docs/guides/test/timeout.mdx +1 -1
- package/docs/guides/test/todo-tests.mdx +2 -2
- package/docs/guides/test/update-snapshots.mdx +1 -1
- package/docs/guides/test/watch-mode.mdx +1 -1
- package/docs/guides/util/base64.mdx +1 -1
- package/docs/guides/util/deep-equals.mdx +3 -3
- package/docs/guides/util/deflate.mdx +1 -1
- package/docs/guides/util/entrypoint.mdx +2 -2
- package/docs/guides/util/escape-html.mdx +1 -1
- package/docs/guides/util/file-url-to-path.mdx +1 -1
- package/docs/guides/util/gzip.mdx +1 -1
- package/docs/guides/util/hash-a-password.mdx +1 -1
- package/docs/guides/util/import-meta-dir.mdx +2 -2
- package/docs/guides/util/import-meta-file.mdx +2 -2
- package/docs/guides/util/import-meta-path.mdx +2 -2
- package/docs/guides/util/javascript-uuid.mdx +2 -2
- package/docs/guides/util/main.mdx +1 -1
- package/docs/guides/util/path-to-file-url.mdx +1 -1
- package/docs/guides/util/sleep.mdx +1 -1
- package/docs/guides/util/version.mdx +2 -2
- package/docs/guides/util/which-path-to-executable-bin.mdx +1 -1
- package/docs/guides/websocket/context.mdx +1 -1
- package/docs/guides/websocket/simple.mdx +1 -1
- package/docs/guides/write-file/basic.mdx +2 -2
- package/docs/guides/write-file/blob.mdx +2 -2
- package/docs/guides/write-file/cat.mdx +2 -2
- package/docs/guides/write-file/file-cp.mdx +2 -2
- package/docs/guides/write-file/filesink.mdx +1 -1
- package/docs/guides/write-file/response.mdx +2 -2
- package/docs/guides/write-file/stdout.mdx +2 -2
- package/docs/guides/write-file/stream.mdx +2 -2
- package/docs/guides/write-file/unlink.mdx +1 -1
- package/docs/index.mdx +2 -2
- package/docs/installation.mdx +3 -3
- package/docs/pm/bunx.mdx +2 -2
- package/docs/pm/cli/install.mdx +8 -8
- package/docs/pm/cli/link.mdx +2 -2
- package/docs/pm/cli/outdated.mdx +3 -3
- package/docs/pm/cli/patch.mdx +2 -2
- package/docs/pm/cli/pm.mdx +1 -1
- package/docs/pm/cli/publish.mdx +1 -1
- package/docs/pm/filter.mdx +2 -2
- package/docs/pm/isolated-installs.mdx +3 -3
- package/docs/pm/npmrc.mdx +6 -6
- package/docs/pm/scopes-registries.mdx +1 -1
- package/docs/pm/security-scanner-api.mdx +2 -2
- package/docs/pm/workspaces.mdx +3 -4
- package/docs/project/benchmarking.mdx +1 -1
- package/docs/project/building-windows.mdx +1 -1
- package/docs/project/contributing.mdx +1 -1
- package/docs/project/license.mdx +1 -1
- package/docs/quickstart.mdx +3 -3
- package/docs/runtime/auto-install.mdx +1 -1
- package/docs/runtime/binary-data.mdx +1 -1
- package/docs/runtime/bun-apis.mdx +35 -35
- package/docs/runtime/bunfig.mdx +29 -3
- package/docs/runtime/c-compiler.mdx +3 -3
- package/docs/runtime/child-process.mdx +2 -2
- package/docs/runtime/cookies.mdx +19 -19
- package/docs/runtime/debugger.mdx +4 -4
- package/docs/runtime/environment-variables.mdx +24 -7
- package/docs/runtime/ffi.mdx +2 -2
- package/docs/runtime/file-io.mdx +2 -2
- package/docs/runtime/file-types.mdx +5 -5
- package/docs/runtime/globals.mdx +4 -4
- package/docs/runtime/http/error-handling.mdx +2 -2
- package/docs/runtime/http/routing.mdx +1 -1
- package/docs/runtime/http/server.mdx +5 -9
- package/docs/runtime/http/websockets.mdx +1 -1
- package/docs/runtime/index.mdx +2 -2
- package/docs/runtime/jsx.mdx +1 -1
- package/docs/runtime/module-resolution.mdx +2 -2
- package/docs/runtime/networking/fetch.mdx +4 -4
- package/docs/runtime/nodejs-compat.mdx +3 -3
- package/docs/runtime/plugins.mdx +1 -1
- package/docs/runtime/s3.mdx +4 -4
- package/docs/runtime/secrets.mdx +10 -7
- package/docs/runtime/sql.mdx +10 -10
- package/docs/runtime/sqlite.mdx +15 -4
- package/docs/runtime/templating/create.mdx +4 -4
- package/docs/runtime/transpiler.mdx +1 -1
- package/docs/runtime/utils.mdx +3 -3
- package/docs/runtime/watch-mode.mdx +1 -1
- package/docs/runtime/workers.mdx +5 -17
- package/docs/snippets/cli/publish.mdx +2 -2
- package/docs/test/configuration.mdx +1 -1
- package/docs/test/dom.mdx +1 -1
- package/docs/test/index.mdx +8 -8
- package/docs/test/reporters.mdx +1 -1
- package/docs/test/snapshots.mdx +3 -3
- package/docs/test/writing-tests.mdx +37 -0
- package/docs/typescript.mdx +2 -2
- package/package.json +3 -4
- package/docs/snippets/product-card.mdx +0 -32
- package/docs/snippets/product-tiles.mdx +0 -94
|
@@ -148,7 +148,7 @@ In this guide, we will deploy a Bun HTTP server to AWS Lambda using a `Dockerfil
|
|
|
148
148
|
<Warning>Make sure you've selected the right region, this URL defaults to `us-east-1`.</Warning>
|
|
149
149
|
|
|
150
150
|
<Frame>
|
|
151
|
-

|
|
151
|
+

|
|
152
152
|
</Frame>
|
|
153
153
|
|
|
154
154
|
Give the function a name, like `my-bun-function`.
|
|
@@ -157,13 +157,13 @@ In this guide, we will deploy a Bun HTTP server to AWS Lambda using a `Dockerfil
|
|
|
157
157
|
Then, go to the **Container image URI** section, click on **Browse images**. Select the image we just pushed to the ECR repository.
|
|
158
158
|
|
|
159
159
|
<Frame>
|
|
160
|
-

|
|
160
|
+

|
|
161
161
|
</Frame>
|
|
162
162
|
|
|
163
163
|
Then, select the `latest` image, and click on **Select image**.
|
|
164
164
|
|
|
165
165
|
<Frame>
|
|
166
|
-

|
|
166
|
+

|
|
167
167
|
</Frame>
|
|
168
168
|
</Step>
|
|
169
169
|
<Step title="Configure the function">
|
|
@@ -172,14 +172,14 @@ In this guide, we will deploy a Bun HTTP server to AWS Lambda using a `Dockerfil
|
|
|
172
172
|
Set this to **Enable**, with Auth Type **NONE**.
|
|
173
173
|
|
|
174
174
|
<Frame>
|
|
175
|
-

|
|
175
|
+

|
|
176
176
|
</Frame>
|
|
177
177
|
</Step>
|
|
178
178
|
<Step title="Create the function">
|
|
179
179
|
Click on **Create function** at the bottom of the page, this will create the function.
|
|
180
180
|
|
|
181
181
|
<Frame>
|
|
182
|
-

|
|
182
|
+

|
|
183
183
|
</Frame>
|
|
184
184
|
|
|
185
185
|
</Step>
|
|
@@ -187,7 +187,7 @@ In this guide, we will deploy a Bun HTTP server to AWS Lambda using a `Dockerfil
|
|
|
187
187
|
Once the function has been created you'll be redirected to the function's page, where you can see the function URL in the **"Function URL"** section.
|
|
188
188
|
|
|
189
189
|
<Frame>
|
|
190
|
-

|
|
190
|
+

|
|
191
191
|
</Frame>
|
|
192
192
|
</Step>
|
|
193
193
|
<Step title="Test the function">
|
|
@@ -29,7 +29,7 @@ In this guide, we will deploy a Bun HTTP server to DigitalOcean using a `Dockerf
|
|
|
29
29
|
In the DigitalOcean dashboard, go to [**Container Registry**](https://cloud.digitalocean.com/registry), and enter the details for the new registry.
|
|
30
30
|
|
|
31
31
|
<Frame>
|
|
32
|
-

|
|
32
|
+

|
|
33
33
|
</Frame>
|
|
34
34
|
|
|
35
35
|
Make sure the details are correct, then click **Create Registry**.
|
|
@@ -50,7 +50,7 @@ In this guide, we will deploy a Bun HTTP server to DigitalOcean using a `Dockerf
|
|
|
50
50
|
You should see the new registry in the [**DigitalOcean registry dashboard**](https://cloud.digitalocean.com/registry):
|
|
51
51
|
|
|
52
52
|
<Frame>
|
|
53
|
-

|
|
53
|
+

|
|
54
54
|
</Frame>
|
|
55
55
|
</Step>
|
|
56
56
|
<Step title="Create a new Dockerfile">
|
|
@@ -128,33 +128,33 @@ In this guide, we will deploy a Bun HTTP server to DigitalOcean using a `Dockerf
|
|
|
128
128
|
Once the image is pushed, you should see it in the [**DigitalOcean registry dashboard**](https://cloud.digitalocean.com/registry):
|
|
129
129
|
|
|
130
130
|
<Frame>
|
|
131
|
-

|
|
131
|
+

|
|
132
132
|
</Frame>
|
|
133
133
|
</Step>
|
|
134
134
|
<Step title="Create a new DigitalOcean App Platform project">
|
|
135
135
|
In the DigitalOcean dashboard, go to [**App Platform**](https://cloud.digitalocean.com/apps) > **Create App**. We can create a project directly from the container image.
|
|
136
136
|
|
|
137
137
|
<Frame>
|
|
138
|
-

|
|
138
|
+

|
|
139
139
|
</Frame>
|
|
140
140
|
|
|
141
141
|
Make sure the details are correct, then click **Next**.
|
|
142
142
|
|
|
143
143
|
<Frame>
|
|
144
|
-

|
|
144
|
+

|
|
145
145
|
</Frame>
|
|
146
146
|
|
|
147
147
|
Review and configure resource settings, then click **Create app**.
|
|
148
148
|
|
|
149
149
|
<Frame>
|
|
150
|
-

|
|
150
|
+

|
|
151
151
|
</Frame>
|
|
152
152
|
</Step>
|
|
153
153
|
<Step title="Visit your live application">
|
|
154
154
|
🥳 Your app is now live! Once the app is created, you should see it in the App Platform dashboard with the public URL.
|
|
155
155
|
|
|
156
156
|
<Frame>
|
|
157
|
-

|
|
157
|
+

|
|
158
158
|
</Frame>
|
|
159
159
|
</Step>
|
|
160
160
|
|
|
@@ -4,8 +4,6 @@ sidebarTitle: Deploy on Vercel
|
|
|
4
4
|
mode: center
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
import { ProductCard } from "/snippets/product-card.mdx";
|
|
8
|
-
|
|
9
7
|
[Vercel](https://vercel.com/) is a cloud platform that lets you build, deploy, and scale your apps.
|
|
10
8
|
|
|
11
9
|
<Warning>
|
|
@@ -81,7 +79,7 @@ import { ProductCard } from "/snippets/product-card.mdx";
|
|
|
81
79
|
console.log("runtime", process.versions.bun);
|
|
82
80
|
```
|
|
83
81
|
```txt
|
|
84
|
-
runtime 1.3.
|
|
82
|
+
runtime 1.3.3
|
|
85
83
|
```
|
|
86
84
|
|
|
87
85
|
[See the Vercel Bun Runtime documentation for feature support →](https://vercel.com/docs/functions/runtimes/bun#feature-support)
|
|
@@ -22,7 +22,7 @@ bun add discord.js
|
|
|
22
22
|
|
|
23
23
|
---
|
|
24
24
|
|
|
25
|
-
Before we go further, we need to go to the [Discord developer portal](https://discord.com/developers/applications), login/signup, create a new _Application_, then create a new _Bot_ within that application. Follow the [official guide](https://discordjs.guide/preparations/
|
|
25
|
+
Before we go further, we need to go to the [Discord developer portal](https://discord.com/developers/applications), login/signup, create a new _Application_, then create a new _Bot_ within that application. Follow the [official guide](https://discordjs.guide/legacy/preparations/app-setup#creating-your-bot) for step-by-step instructions.
|
|
26
26
|
|
|
27
27
|
---
|
|
28
28
|
|
|
@@ -30,7 +30,7 @@ Once complete, you'll be presented with your bot's _private key_. Let's add this
|
|
|
30
30
|
|
|
31
31
|
<Note>This is an example token that has already been invalidated.</Note>
|
|
32
32
|
|
|
33
|
-
```
|
|
33
|
+
```ini .env.local icon="settings"
|
|
34
34
|
DISCORD_TOKEN=NzkyNzE1NDU0MTk2MDg4ODQy.X-hvzA.Ovy4MCQywSkoMRRclStW4xAYK7I
|
|
35
35
|
```
|
|
36
36
|
|
|
@@ -7,8 +7,8 @@ mode: center
|
|
|
7
7
|
Express and other major Node.js HTTP libraries should work out of the box. Bun implements the [`node:http`](https://nodejs.org/api/http.html) and [`node:https`](https://nodejs.org/api/https.html) modules that these libraries rely on.
|
|
8
8
|
|
|
9
9
|
<Note>
|
|
10
|
-
Refer to the [Runtime > Node.js APIs](
|
|
11
|
-
|
|
10
|
+
Refer to the [Runtime > Node.js APIs](/docs/runtime/nodejs-compat#node-http) page for more detailed compatibility
|
|
11
|
+
information.
|
|
12
12
|
</Note>
|
|
13
13
|
|
|
14
14
|
```sh terminal icon="terminal"
|
|
@@ -89,4 +89,4 @@ Moo!
|
|
|
89
89
|
|
|
90
90
|
---
|
|
91
91
|
|
|
92
|
-
This is a simple introduction to using Mongoose with TypeScript and Bun. As you build your application, refer to the official [MongoDB](https://
|
|
92
|
+
This is a simple introduction to using Mongoose with TypeScript and Bun. As you build your application, refer to the official [MongoDB](https://www.mongodb.com/docs) and [Mongoose](https://mongoosejs.com/docs/) sites for complete documentation.
|
|
@@ -20,7 +20,7 @@ bun add -D drizzle-kit
|
|
|
20
20
|
|
|
21
21
|
Create a `.env.local` file and add your [Neon Postgres connection string](https://neon.tech/docs/connect/connect-from-any-app) to it.
|
|
22
22
|
|
|
23
|
-
```
|
|
23
|
+
```ini .env.local icon="settings"
|
|
24
24
|
DATABASE_URL=postgresql://usertitle:password@ep-adj-noun-guid.us-east-1.aws.neon.tech/neondb?sslmode=require
|
|
25
25
|
```
|
|
26
26
|
|
|
@@ -33,7 +33,7 @@ import { neon } from "@neondatabase/serverless";
|
|
|
33
33
|
import { drizzle } from "drizzle-orm/neon-http";
|
|
34
34
|
|
|
35
35
|
// Bun automatically loads the DATABASE_URL from .env.local
|
|
36
|
-
// Refer to: https://bun.com/docs/runtime/
|
|
36
|
+
// Refer to: https://bun.com/docs/runtime/environment-variables for more information
|
|
37
37
|
const sql = neon(process.env.DATABASE_URL!);
|
|
38
38
|
|
|
39
39
|
export const db = drizzle(sql);
|
|
@@ -21,7 +21,7 @@ bun add @neondatabase/serverless
|
|
|
21
21
|
|
|
22
22
|
Create a `.env.local` file and add your [Neon Postgres connection string](https://neon.tech/docs/connect/connect-from-any-app) to it.
|
|
23
23
|
|
|
24
|
-
```
|
|
24
|
+
```ini .env.local icon="settings"
|
|
25
25
|
DATABASE_URL=postgresql://usertitle:password@ep-adj-noun-guid.us-east-1.aws.neon.tech/neondb?sslmode=require
|
|
26
26
|
```
|
|
27
27
|
|
|
@@ -33,7 +33,7 @@ Paste the following code into your project's `index.ts` file.
|
|
|
33
33
|
import { neon } from "@neondatabase/serverless";
|
|
34
34
|
|
|
35
35
|
// Bun automatically loads the DATABASE_URL from .env.local
|
|
36
|
-
// Refer to: https://bun.com/docs/runtime/
|
|
36
|
+
// Refer to: https://bun.com/docs/runtime/environment-variables for more information
|
|
37
37
|
const sql = neon(process.env.DATABASE_URL);
|
|
38
38
|
|
|
39
39
|
const rows = await sql`SELECT version()`;
|
|
@@ -62,7 +62,7 @@ mode: center
|
|
|
62
62
|
<Step title="Configure database connection">
|
|
63
63
|
Set up your Postgres database URL in the `.env` file.
|
|
64
64
|
|
|
65
|
-
```
|
|
65
|
+
```ini .env icon="settings"
|
|
66
66
|
DATABASE_URL="postgresql://username:password@localhost:5432/mydb?schema=public"
|
|
67
67
|
```
|
|
68
68
|
</Step>
|
|
@@ -161,4 +161,4 @@ mode: center
|
|
|
161
161
|
|
|
162
162
|
---
|
|
163
163
|
|
|
164
|
-
That's it! Now that you've set up Prisma using Bun, we recommend referring to the [official Prisma docs](https://www.prisma.io/docs/
|
|
164
|
+
That's it! Now that you've set up Prisma using Bun, we recommend referring to the [official Prisma docs](https://www.prisma.io/docs/orm/prisma-client) as you continue to develop your application.
|
|
@@ -65,14 +65,14 @@ bun create qwik
|
|
|
65
65
|
│ bun qwik add │
|
|
66
66
|
│ │
|
|
67
67
|
│ Relevant docs: │
|
|
68
|
-
│ https://qwik.
|
|
68
|
+
│ https://qwik.dev/docs/getting-started/ │
|
|
69
69
|
│ │
|
|
70
70
|
│ Questions? Start the conversation at: │
|
|
71
|
-
│ https://qwik.
|
|
71
|
+
│ https://qwik.dev/chat │
|
|
72
72
|
│ https://twitter.com/QwikDev │
|
|
73
73
|
│ │
|
|
74
74
|
│ Presentations, Podcasts and Videos: │
|
|
75
|
-
│ https://qwik.
|
|
75
|
+
│ https://qwik.dev/media/ │
|
|
76
76
|
│ │
|
|
77
77
|
│ Next steps: │
|
|
78
78
|
│ cd my-app │
|
|
@@ -111,4 +111,4 @@ Open [http://localhost:5173](http://localhost:5173) with your browser to see the
|
|
|
111
111
|
|
|
112
112
|
---
|
|
113
113
|
|
|
114
|
-
Refer to the [Qwik docs](https://qwik.
|
|
114
|
+
Refer to the [Qwik docs](https://qwik.dev/docs/getting-started/) for complete documentation.
|
|
@@ -20,7 +20,7 @@ bun add @sentry/bun
|
|
|
20
20
|
|
|
21
21
|
Then, initialize the Sentry SDK with your Sentry DSN in your app's entry file. You can find your DSN in your Sentry project settings.
|
|
22
22
|
|
|
23
|
-
```
|
|
23
|
+
```ts sentry.ts icon="/icons/typescript.svg"
|
|
24
24
|
import * as Sentry from "@sentry/bun";
|
|
25
25
|
|
|
26
26
|
// Ensure to call this before importing any other modules!
|
|
@@ -37,7 +37,7 @@ Sentry.init({
|
|
|
37
37
|
|
|
38
38
|
You can verify that Sentry is working by capturing a test error:
|
|
39
39
|
|
|
40
|
-
```
|
|
40
|
+
```ts sentry.ts icon="/icons/typescript.svg"
|
|
41
41
|
setTimeout(() => {
|
|
42
42
|
try {
|
|
43
43
|
foo();
|
|
@@ -88,7 +88,7 @@ To build for production, you'll need to add the right SvelteKit adapter. Current
|
|
|
88
88
|
|
|
89
89
|
Now, make the following changes to your `svelte.config.js`.
|
|
90
90
|
|
|
91
|
-
```
|
|
91
|
+
```js svelte.config.js icon="file-code"
|
|
92
92
|
import adapter from "@sveltejs/adapter-auto"; // [!code --]
|
|
93
93
|
import adapter from "svelte-adapter-bun"; // [!code ++]
|
|
94
94
|
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
|
|
@@ -25,7 +25,7 @@ mode: center
|
|
|
25
25
|
The database page displays two connection methods; HTTP and TLS. For Bun's Redis client, you need the **TLS** connection details. This URL starts with `rediss://`.
|
|
26
26
|
|
|
27
27
|
<Frame>
|
|
28
|
-

|
|
28
|
+

|
|
29
29
|
</Frame>
|
|
30
30
|
|
|
31
31
|
</Step>
|
|
@@ -34,7 +34,7 @@ mode: center
|
|
|
34
34
|
|
|
35
35
|
Set the `REDIS_URL` environment variable in your `.env` file using the Redis endpoint (not the REST URL):
|
|
36
36
|
|
|
37
|
-
```
|
|
37
|
+
```ini .env icon="settings"
|
|
38
38
|
REDIS_URL=rediss://********@********.upstash.io:6379
|
|
39
39
|
```
|
|
40
40
|
|
|
@@ -6,7 +6,7 @@ mode: center
|
|
|
6
6
|
|
|
7
7
|
<Note>
|
|
8
8
|
You can use Vite with Bun, but many projects get faster builds & drop hundreds of dependencies by switching to [HTML
|
|
9
|
-
imports](/bundler/html-static).
|
|
9
|
+
imports](/docs/bundler/html-static).
|
|
10
10
|
</Note>
|
|
11
11
|
|
|
12
12
|
---
|
|
@@ -74,4 +74,4 @@ bunx --bun vite build
|
|
|
74
74
|
|
|
75
75
|
---
|
|
76
76
|
|
|
77
|
-
This is a stripped down guide to get you started with Vite + Bun. For more information, see the [Vite documentation](https://
|
|
77
|
+
This is a stripped down guide to get you started with Vite + Bun. For more information, see the [Vite documentation](https://vite.dev/guide/).
|
|
@@ -6,7 +6,7 @@ mode: center
|
|
|
6
6
|
|
|
7
7
|
## Extract links from a webpage
|
|
8
8
|
|
|
9
|
-
Bun's [HTMLRewriter](
|
|
9
|
+
Bun's [HTMLRewriter](/docs/runtime/html-rewriter) API can be used to efficiently extract links from HTML content. It works by chaining together CSS selectors to match the elements, text, and attributes you want to process. This is a simple example of how to extract links from a webpage. You can pass `.transform` a `Response`, `Blob`, or `string`.
|
|
10
10
|
|
|
11
11
|
```ts extract-links.ts icon="/icons/typescript.svg"
|
|
12
12
|
async function extractLinks(url: string) {
|
|
@@ -68,4 +68,4 @@ const websiteLinks = await extractLinksFromURL("https://example.com");
|
|
|
68
68
|
|
|
69
69
|
---
|
|
70
70
|
|
|
71
|
-
See [Docs > API > HTMLRewriter](
|
|
71
|
+
See [Docs > API > HTMLRewriter](/docs/runtime/html-rewriter) for complete documentation on HTML transformation with Bun.
|
|
@@ -6,7 +6,7 @@ mode: center
|
|
|
6
6
|
|
|
7
7
|
## Extract social share images and Open Graph tags
|
|
8
8
|
|
|
9
|
-
Bun's [HTMLRewriter](
|
|
9
|
+
Bun's [HTMLRewriter](/docs/runtime/html-rewriter) API can be used to efficiently extract social share images and Open Graph metadata from HTML content. This is particularly useful for building link preview features, social media cards, or web scrapers. We can use HTMLRewriter to match CSS selectors to HTML elements, text, and attributes we want to process.
|
|
10
10
|
|
|
11
11
|
```ts extract-social-meta.ts icon="/icons/typescript.svg"
|
|
12
12
|
interface SocialMetadata {
|
|
@@ -63,7 +63,7 @@ Our form will send a `POST` request to the `/action` endpoint with the form data
|
|
|
63
63
|
|
|
64
64
|
First we use the [`.formData()`](https://developer.mozilla.org/en-US/docs/Web/API/Request/formData) method on the incoming `Request` to asynchronously parse its contents to a `FormData` instance. Then we can use the [`.get()`](https://developer.mozilla.org/en-US/docs/Web/API/FormData/get) method to extract the value of the `name` and `profilePicture` fields. Here `name` corresponds to a `string` and `profilePicture` is a `Blob`.
|
|
65
65
|
|
|
66
|
-
Finally, we write the `Blob` to disk using [`Bun.write()`](
|
|
66
|
+
Finally, we write the `Blob` to disk using [`Bun.write()`](/docs/runtime/file-io#writing-files-bun-write).
|
|
67
67
|
|
|
68
68
|
{/* prettier-ignore */}
|
|
69
69
|
```ts index.ts icon="/icons/typescript.svg"
|
package/docs/guides/http/hot.mdx
CHANGED
|
@@ -4,7 +4,7 @@ sidebarTitle: Hot reload an HTTP server
|
|
|
4
4
|
mode: center
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
Bun supports the [`--hot`](
|
|
7
|
+
Bun supports the [`--hot`](/docs/runtime/watch-mode#hot-mode) flag to run a file with hot reloading enabled. When any module or file changes, Bun re-runs the file.
|
|
8
8
|
|
|
9
9
|
```sh terminal icon="terminal"
|
|
10
10
|
bun --hot run index.ts
|
|
@@ -6,7 +6,7 @@ mode: center
|
|
|
6
6
|
|
|
7
7
|
This starts an HTTP server listening on port `3000`. It demonstrates basic routing with a number of common responses and also handles POST data from standard forms or as JSON.
|
|
8
8
|
|
|
9
|
-
See [`Bun.serve`](
|
|
9
|
+
See [`Bun.serve`](/docs/runtime/http/server) for details.
|
|
10
10
|
|
|
11
11
|
```ts server.ts icon="/icons/typescript.svg"
|
|
12
12
|
const server = Bun.serve({
|
|
@@ -6,7 +6,7 @@ mode: center
|
|
|
6
6
|
|
|
7
7
|
This starts an HTTP server listening on port `3000`. It responds to all requests with a `Response` with status `200` and body `"Welcome to Bun!"`.
|
|
8
8
|
|
|
9
|
-
See [`Bun.serve`](
|
|
9
|
+
See [`Bun.serve`](/docs/runtime/http/server) for details.
|
|
10
10
|
|
|
11
11
|
```ts server.ts icon="/icons/typescript.svg"
|
|
12
12
|
const server = Bun.serve({
|
|
@@ -4,7 +4,7 @@ sidebarTitle: Stream file response
|
|
|
4
4
|
mode: center
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
This snippet reads a file from disk using [`Bun.file()`](
|
|
7
|
+
This snippet reads a file from disk using [`Bun.file()`](/docs/runtime/file-io#reading-files-bun-file). This returns a `BunFile` instance, which can be passed directly into the `new Response` constructor.
|
|
8
8
|
|
|
9
9
|
```ts server.ts icon="/icons/typescript.svg"
|
|
10
10
|
const path = "/path/to/file.txt";
|
|
@@ -32,7 +32,7 @@ new Response(Bun.file("./img.png")).headers.get("Content-Type");
|
|
|
32
32
|
|
|
33
33
|
---
|
|
34
34
|
|
|
35
|
-
Putting it all together with [`Bun.serve()`](
|
|
35
|
+
Putting it all together with [`Bun.serve()`](/docs/runtime/http/server).
|
|
36
36
|
|
|
37
37
|
```ts server.ts icon="/icons/typescript.svg"
|
|
38
38
|
// static file server
|
|
@@ -47,4 +47,4 @@ Bun.serve({
|
|
|
47
47
|
|
|
48
48
|
---
|
|
49
49
|
|
|
50
|
-
See [Docs > API > File I/O](
|
|
50
|
+
See [Docs > API > File I/O](/docs/runtime/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`.
|
package/docs/guides/http/tls.mdx
CHANGED
|
@@ -4,7 +4,7 @@ sidebarTitle: Configure TLS
|
|
|
4
4
|
mode: center
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
Set the `tls` key to configure TLS. Both `key` and `cert` are required. The `key` should be the contents of your private key; `cert` should be the contents of your issued certificate. Use [`Bun.file()`](
|
|
7
|
+
Set the `tls` key to configure TLS. Both `key` and `cert` are required. The `key` should be the contents of your private key; `cert` should be the contents of your issued certificate. Use [`Bun.file()`](/docs/runtime/file-io#reading-files-bun-file) to read the contents.
|
|
8
8
|
|
|
9
9
|
```ts server.ts icon="/icons/typescript.svg"
|
|
10
10
|
const server = Bun.serve({
|
|
@@ -25,4 +25,4 @@ This will add the package to `devDependencies` in `package.json`.
|
|
|
25
25
|
|
|
26
26
|
---
|
|
27
27
|
|
|
28
|
-
See [Docs > Package manager](
|
|
28
|
+
See [Docs > Package manager](/docs/pm/cli/install) for complete documentation of Bun's package manager.
|
|
@@ -24,4 +24,4 @@ This will add the package to `optionalDependencies` in `package.json`.
|
|
|
24
24
|
|
|
25
25
|
---
|
|
26
26
|
|
|
27
|
-
See [Docs > Package manager](
|
|
27
|
+
See [Docs > Package manager](/docs/pm/cli/install) for complete documentation of Bun's package manager.
|
|
@@ -17,7 +17,7 @@ This will add the package to `peerDependencies` in `package.json`.
|
|
|
17
17
|
```json package.json icon="file-json"
|
|
18
18
|
{
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@types/bun": "^1.3.
|
|
20
|
+
"@types/bun": "^1.3.3" // [!code ++]
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
```
|
|
@@ -30,7 +30,7 @@ Running `bun install` will install peer dependencies by default, unless marked o
|
|
|
30
30
|
```json package.json icon="file-json"
|
|
31
31
|
{
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@types/bun": "^1.3.
|
|
33
|
+
"@types/bun": "^1.3.3"
|
|
34
34
|
},
|
|
35
35
|
"peerDependenciesMeta": {
|
|
36
36
|
"@types/bun": { // [!code ++]
|
|
@@ -42,4 +42,4 @@ Running `bun install` will install peer dependencies by default, unless marked o
|
|
|
42
42
|
|
|
43
43
|
---
|
|
44
44
|
|
|
45
|
-
See [Docs > Package manager](
|
|
45
|
+
See [Docs > Package manager](/docs/pm/cli/install) for complete documentation of Bun's package manager.
|
|
@@ -31,9 +31,9 @@ password = "$NPM_PASSWORD"
|
|
|
31
31
|
|
|
32
32
|
---
|
|
33
33
|
|
|
34
|
-
Then assign your Azure Personal Access Token to the `NPM_PASSWORD` environment variable. Bun [automatically reads](
|
|
34
|
+
Then assign your Azure Personal Access Token to the `NPM_PASSWORD` environment variable. Bun [automatically reads](/docs/runtime/environment-variables) `.env` files, so create a file called `.env` in your project root. There is no need to base-64 encode this token! Bun will do this for you.
|
|
35
35
|
|
|
36
|
-
```
|
|
36
|
+
```ini .env icon="settings"
|
|
37
37
|
NPM_PASSWORD=<paste token here>
|
|
38
38
|
```
|
|
39
39
|
|
|
@@ -43,7 +43,7 @@ NPM_PASSWORD=<paste token here>
|
|
|
43
43
|
|
|
44
44
|
---
|
|
45
45
|
|
|
46
|
-
To configure Azure Artifacts without `bunfig.toml`, you can set the `NPM_CONFIG_REGISTRY` environment variable. The URL should include `:username` and `:_password` as query parameters. Replace `<USERNAME>` and `<PASSWORD>` with the
|
|
46
|
+
To configure Azure Artifacts without `bunfig.toml`, you can set the `NPM_CONFIG_REGISTRY` environment variable. The URL should include `:username` and `:_password` as query parameters. Replace `<USERNAME>` and `<PASSWORD>` with the appropriate values.
|
|
47
47
|
|
|
48
48
|
```bash terminal icon="terminal"
|
|
49
49
|
NPM_CONFIG_REGISTRY=https://pkgs.dev.azure.com/my-azure-artifacts-user/_packaging/my-azure-artifacts-user/npm/registry/:username=<USERNAME>:_password=<PASSWORD>
|
|
@@ -20,7 +20,7 @@ registry = "https://usertitle:password@registry.npmjs.org"
|
|
|
20
20
|
|
|
21
21
|
---
|
|
22
22
|
|
|
23
|
-
Your `bunfig.toml` can reference environment variables. Bun automatically loads environment variables from `.env.local`, `.env.[NODE_ENV]`, and `.env`. See [Docs > Environment variables](
|
|
23
|
+
Your `bunfig.toml` can reference environment variables. Bun automatically loads environment variables from `.env.local`, `.env.[NODE_ENV]`, and `.env`. See [Docs > Environment variables](/docs/runtime/environment-variables) for more information.
|
|
24
24
|
|
|
25
25
|
```toml bunfig.toml icon="settings"
|
|
26
26
|
[install]
|
|
@@ -29,4 +29,4 @@ registry = { url = "https://registry.npmjs.org", token = "$npm_token" }
|
|
|
29
29
|
|
|
30
30
|
---
|
|
31
31
|
|
|
32
|
-
See [Docs > Package manager](
|
|
32
|
+
See [Docs > Package manager](/docs/pm/cli/install) for complete documentation of Bun's package manager.
|
|
@@ -6,7 +6,8 @@ mode: center
|
|
|
6
6
|
|
|
7
7
|
<Note>
|
|
8
8
|
Bun v1.1.39 introduced `bun.lock`, a JSONC formatted lockfile. `bun.lock` is human-readable and git-diffable without
|
|
9
|
-
configuration, at no cost to performance. [**Learn
|
|
9
|
+
configuration, at no cost to performance. In 1.2.0+ it is the default format used for new projects. [**Learn
|
|
10
|
+
more.**](/docs/pm/lockfile#text-based-lockfile)
|
|
10
11
|
</Note>
|
|
11
12
|
|
|
12
13
|
---
|
|
@@ -4,7 +4,7 @@ sidebarTitle: Configure a scoped registry
|
|
|
4
4
|
mode: center
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
Private registries can be configured using either [`.npmrc`](
|
|
7
|
+
Private registries can be configured using either [`.npmrc`](/docs/pm/npmrc) or [`bunfig.toml`](/docs/runtime/bunfig#install-registry). While both are supported, we recommend using **bunfig.toml** for enhanced flexibility and Bun-specific options.
|
|
8
8
|
|
|
9
9
|
To configure a registry for a particular npm scope:
|
|
10
10
|
|
|
@@ -28,7 +28,7 @@ To configure a registry for a particular npm scope:
|
|
|
28
28
|
|
|
29
29
|
---
|
|
30
30
|
|
|
31
|
-
Your `bunfig.toml` can reference environment variables. Bun automatically loads environment variables from `.env.local`, `.env.[NODE_ENV]`, and `.env`. See [Docs > Environment variables](
|
|
31
|
+
Your `bunfig.toml` can reference environment variables. Bun automatically loads environment variables from `.env.local`, `.env.[NODE_ENV]`, and `.env`. See [Docs > Environment variables](/docs/runtime/environment-variables) for more information.
|
|
32
32
|
|
|
33
33
|
```toml bunfig.toml icon="settings"
|
|
34
34
|
[install.scopes]
|
|
@@ -37,4 +37,4 @@ Your `bunfig.toml` can reference environment variables. Bun automatically loads
|
|
|
37
37
|
|
|
38
38
|
---
|
|
39
39
|
|
|
40
|
-
See [Docs > Package manager](
|
|
40
|
+
See [Docs > Package manager](/docs/pm/cli/install) for complete documentation of Bun's package manager.
|
|
@@ -47,4 +47,4 @@ bun install
|
|
|
47
47
|
|
|
48
48
|
---
|
|
49
49
|
|
|
50
|
-
See [Docs > Package manager > Trusted dependencies](
|
|
50
|
+
See [Docs > Package manager > Trusted dependencies](/docs/pm/lifecycle) for complete documentation of trusted dependencies.
|
|
@@ -6,12 +6,13 @@ mode: center
|
|
|
6
6
|
|
|
7
7
|
<Note>
|
|
8
8
|
Bun v1.1.39 introduced `bun.lock`, a JSONC formatted lockfile. `bun.lock` is human-readable and git-diffable without
|
|
9
|
-
configuration, at no cost to performance. [**Learn
|
|
9
|
+
configuration, at no cost to performance. In 1.2.0+ it is the default format used for new projects. [**Learn
|
|
10
|
+
more.**](/docs/pm/lockfile#text-based-lockfile)
|
|
10
11
|
</Note>
|
|
11
12
|
|
|
12
13
|
---
|
|
13
14
|
|
|
14
|
-
Use the `--yarn` flag to generate a Yarn-compatible `yarn.lock` file (in addition to `bun.lock`).
|
|
15
|
+
Use the `--yarn` flag to generate a Yarn-compatible `yarn.lock` file (in addition to `bun.lock{b}`).
|
|
15
16
|
|
|
16
17
|
```sh terminal icon="terminal"
|
|
17
18
|
bun install --yarn
|
|
@@ -47,4 +48,4 @@ abab@^2.0.6:
|
|
|
47
48
|
|
|
48
49
|
---
|
|
49
50
|
|
|
50
|
-
See [Docs > Package manager](
|
|
51
|
+
See [Docs > Package manager](/docs/pm/cli/install) for complete documentation of Bun's package manager.
|