bun-types 1.3.2-canary.20251104T140728 → 1.3.2-canary.20251106T140813
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 +4 -4
- package/docs/README.md +28 -0
- package/globals.d.ts +0 -1
- package/overrides.d.ts +45 -15
- package/package.json +1 -1
- package/test.d.ts +1 -1
- package/docs/api/binary-data.md +0 -1038
- package/docs/api/cc.md +0 -197
- package/docs/api/color.md +0 -262
- package/docs/api/console.md +0 -57
- package/docs/api/cookie.md +0 -449
- package/docs/api/dns.md +0 -110
- package/docs/api/fetch.md +0 -463
- package/docs/api/ffi.md +0 -557
- package/docs/api/file-io.md +0 -366
- package/docs/api/file-system-router.md +0 -112
- package/docs/api/file.md +0 -19
- package/docs/api/glob.md +0 -178
- package/docs/api/globals.md +0 -387
- package/docs/api/hashing.md +0 -319
- package/docs/api/html-rewriter.md +0 -334
- package/docs/api/http.md +0 -1408
- package/docs/api/import-meta.md +0 -69
- package/docs/api/node-api.md +0 -14
- package/docs/api/redis.md +0 -597
- package/docs/api/s3.md +0 -850
- package/docs/api/secrets.md +0 -319
- package/docs/api/semver.md +0 -52
- package/docs/api/spawn.md +0 -582
- package/docs/api/sql.md +0 -1374
- package/docs/api/sqlite.md +0 -694
- package/docs/api/streams.md +0 -230
- package/docs/api/tcp.md +0 -221
- package/docs/api/transpiler.md +0 -276
- package/docs/api/udp.md +0 -123
- package/docs/api/utils.md +0 -891
- package/docs/api/websockets.md +0 -573
- package/docs/api/workers.md +0 -322
- package/docs/api/yaml.md +0 -668
- package/docs/benchmarks.md +0 -120
- package/docs/bun-flavored-toml.md +0 -42
- package/docs/bundler/css.md +0 -1028
- package/docs/bundler/css_modules.md +0 -145
- package/docs/bundler/executables.md +0 -626
- package/docs/bundler/fullstack.md +0 -418
- package/docs/bundler/hmr.md +0 -234
- package/docs/bundler/html.md +0 -349
- package/docs/bundler/index.md +0 -1735
- package/docs/bundler/intro.md +0 -75
- package/docs/bundler/loaders.md +0 -410
- package/docs/bundler/macros.md +0 -329
- package/docs/bundler/plugins.md +0 -449
- package/docs/bundler/vs-esbuild.md +0 -1127
- package/docs/cli/add.md +0 -173
- package/docs/cli/bun-completions.md +0 -3
- package/docs/cli/bun-create.md +0 -338
- package/docs/cli/bun-install.md +0 -349
- package/docs/cli/bun-upgrade.md +0 -39
- package/docs/cli/bunx.md +0 -89
- package/docs/cli/filter.md +0 -90
- package/docs/cli/info.md +0 -65
- package/docs/cli/init.md +0 -85
- package/docs/cli/install.md +0 -344
- package/docs/cli/link.md +0 -40
- package/docs/cli/outdated.md +0 -90
- package/docs/cli/patch-commit.md +0 -11
- package/docs/cli/pm.md +0 -285
- package/docs/cli/publish.md +0 -120
- package/docs/cli/remove.md +0 -7
- package/docs/cli/run.md +0 -261
- package/docs/cli/test.md +0 -397
- package/docs/cli/unlink.md +0 -9
- package/docs/cli/update.md +0 -129
- package/docs/cli/why.md +0 -67
- 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/binary/arraybuffer-to-array.md +0 -27
- package/docs/guides/binary/arraybuffer-to-blob.md +0 -24
- package/docs/guides/binary/arraybuffer-to-buffer.md +0 -25
- package/docs/guides/binary/arraybuffer-to-string.md +0 -15
- package/docs/guides/binary/arraybuffer-to-typedarray.md +0 -39
- package/docs/guides/binary/blob-to-arraybuffer.md +0 -14
- package/docs/guides/binary/blob-to-dataview.md +0 -14
- package/docs/guides/binary/blob-to-stream.md +0 -14
- package/docs/guides/binary/blob-to-string.md +0 -15
- package/docs/guides/binary/blob-to-typedarray.md +0 -14
- package/docs/guides/binary/buffer-to-arraybuffer.md +0 -14
- package/docs/guides/binary/buffer-to-blob.md +0 -14
- package/docs/guides/binary/buffer-to-readablestream.md +0 -41
- package/docs/guides/binary/buffer-to-string.md +0 -25
- package/docs/guides/binary/buffer-to-typedarray.md +0 -14
- package/docs/guides/binary/dataview-to-string.md +0 -15
- package/docs/guides/binary/typedarray-to-arraybuffer.md +0 -25
- package/docs/guides/binary/typedarray-to-blob.md +0 -16
- package/docs/guides/binary/typedarray-to-buffer.md +0 -14
- package/docs/guides/binary/typedarray-to-dataview.md +0 -14
- package/docs/guides/binary/typedarray-to-readablestream.md +0 -41
- package/docs/guides/binary/typedarray-to-string.md +0 -16
- package/docs/guides/deployment/railway.md +0 -157
- package/docs/guides/ecosystem/astro.md +0 -72
- package/docs/guides/ecosystem/discordjs.md +0 -77
- package/docs/guides/ecosystem/docker.md +0 -140
- package/docs/guides/ecosystem/drizzle.md +0 -185
- package/docs/guides/ecosystem/edgedb.md +0 -228
- package/docs/guides/ecosystem/elysia.md +0 -31
- package/docs/guides/ecosystem/express.md +0 -40
- package/docs/guides/ecosystem/hono.md +0 -39
- package/docs/guides/ecosystem/mongoose.md +0 -87
- package/docs/guides/ecosystem/neon-drizzle.md +0 -220
- package/docs/guides/ecosystem/neon-serverless-postgres.md +0 -55
- package/docs/guides/ecosystem/nextjs.md +0 -49
- package/docs/guides/ecosystem/nuxt.md +0 -56
- package/docs/guides/ecosystem/pm2.md +0 -57
- package/docs/guides/ecosystem/prisma.md +0 -141
- package/docs/guides/ecosystem/qwik.md +0 -107
- package/docs/guides/ecosystem/react.md +0 -50
- package/docs/guides/ecosystem/remix.md +0 -78
- package/docs/guides/ecosystem/render.md +0 -79
- package/docs/guides/ecosystem/sentry.md +0 -52
- package/docs/guides/ecosystem/solidstart.md +0 -58
- package/docs/guides/ecosystem/ssr-react.md +0 -51
- package/docs/guides/ecosystem/stric.md +0 -55
- package/docs/guides/ecosystem/sveltekit.md +0 -125
- package/docs/guides/ecosystem/systemd.md +0 -113
- package/docs/guides/ecosystem/vite.md +0 -71
- package/docs/guides/html-rewriter/extract-links.md +0 -68
- package/docs/guides/html-rewriter/extract-social-meta.md +0 -93
- package/docs/guides/http/cluster.md +0 -66
- package/docs/guides/http/fetch-unix.md +0 -33
- package/docs/guides/http/fetch.md +0 -24
- package/docs/guides/http/file-uploads.md +0 -94
- package/docs/guides/http/hot.md +0 -26
- package/docs/guides/http/proxy.md +0 -24
- package/docs/guides/http/server.md +0 -46
- package/docs/guides/http/simple.md +0 -18
- package/docs/guides/http/stream-file.md +0 -48
- package/docs/guides/http/stream-iterator.md +0 -47
- package/docs/guides/http/stream-node-streams-in-bun.md +0 -20
- package/docs/guides/http/tls.md +0 -30
- package/docs/guides/install/add-dev.md +0 -26
- package/docs/guides/install/add-git.md +0 -36
- package/docs/guides/install/add-optional.md +0 -25
- package/docs/guides/install/add-peer.md +0 -43
- package/docs/guides/install/add-tarball.md +0 -33
- package/docs/guides/install/add.md +0 -42
- package/docs/guides/install/azure-artifacts.md +0 -73
- package/docs/guides/install/cicd.md +0 -41
- package/docs/guides/install/custom-registry.md +0 -30
- package/docs/guides/install/from-npm-install-to-bun-install.md +0 -214
- package/docs/guides/install/git-diff-bun-lockfile.md +0 -44
- package/docs/guides/install/jfrog-artifactory.md +0 -28
- package/docs/guides/install/npm-alias.md +0 -23
- package/docs/guides/install/registry-scope.md +0 -38
- package/docs/guides/install/trusted.md +0 -46
- package/docs/guides/install/workspaces.md +0 -70
- package/docs/guides/install/yarnlock.md +0 -44
- package/docs/guides/process/argv.md +0 -58
- package/docs/guides/process/ctrl-c.md +0 -16
- package/docs/guides/process/ipc.md +0 -66
- package/docs/guides/process/nanoseconds.md +0 -13
- package/docs/guides/process/os-signals.md +0 -39
- package/docs/guides/process/spawn-stderr.md +0 -31
- package/docs/guides/process/spawn-stdout.md +0 -26
- package/docs/guides/process/spawn.md +0 -41
- package/docs/guides/process/stdin.md +0 -54
- package/docs/guides/read-file/arraybuffer.md +0 -28
- package/docs/guides/read-file/buffer.md +0 -19
- package/docs/guides/read-file/exists.md +0 -16
- package/docs/guides/read-file/json.md +0 -17
- package/docs/guides/read-file/mime.md +0 -20
- package/docs/guides/read-file/stream.md +0 -26
- package/docs/guides/read-file/string.md +0 -22
- package/docs/guides/read-file/uint8array.md +0 -21
- package/docs/guides/read-file/watch.md +0 -68
- package/docs/guides/runtime/build-time-constants.md +0 -293
- package/docs/guides/runtime/cicd.md +0 -43
- package/docs/guides/runtime/codesign-macos-executable.md +0 -56
- package/docs/guides/runtime/define-constant.md +0 -145
- package/docs/guides/runtime/delete-directory.md +0 -37
- package/docs/guides/runtime/delete-file.md +0 -19
- package/docs/guides/runtime/heap-snapshot.md +0 -26
- package/docs/guides/runtime/import-html.md +0 -15
- package/docs/guides/runtime/import-json.md +0 -44
- package/docs/guides/runtime/import-toml.md +0 -30
- package/docs/guides/runtime/import-yaml.md +0 -102
- package/docs/guides/runtime/read-env.md +0 -32
- package/docs/guides/runtime/set-env.md +0 -47
- package/docs/guides/runtime/shell.md +0 -40
- package/docs/guides/runtime/timezone.md +0 -35
- package/docs/guides/runtime/tsconfig-paths.md +0 -29
- package/docs/guides/runtime/typescript.md +0 -49
- package/docs/guides/runtime/vscode-debugger.md +0 -47
- package/docs/guides/runtime/web-debugger.md +0 -82
- package/docs/guides/streams/node-readable-to-arraybuffer.md +0 -11
- package/docs/guides/streams/node-readable-to-blob.md +0 -11
- package/docs/guides/streams/node-readable-to-json.md +0 -12
- package/docs/guides/streams/node-readable-to-string.md +0 -12
- package/docs/guides/streams/node-readable-to-uint8array.md +0 -11
- package/docs/guides/streams/to-array.md +0 -14
- package/docs/guides/streams/to-arraybuffer.md +0 -14
- package/docs/guides/streams/to-blob.md +0 -14
- package/docs/guides/streams/to-buffer.md +0 -15
- package/docs/guides/streams/to-json.md +0 -14
- package/docs/guides/streams/to-string.md +0 -14
- package/docs/guides/streams/to-typedarray.md +0 -22
- package/docs/guides/test/bail.md +0 -22
- package/docs/guides/test/coverage-threshold.md +0 -60
- package/docs/guides/test/coverage.md +0 -44
- package/docs/guides/test/happy-dom.md +0 -68
- package/docs/guides/test/migrate-from-jest.md +0 -143
- package/docs/guides/test/mock-clock.md +0 -48
- package/docs/guides/test/mock-functions.md +0 -68
- package/docs/guides/test/rerun-each.md +0 -14
- package/docs/guides/test/run-tests.md +0 -111
- package/docs/guides/test/skip-tests.md +0 -39
- package/docs/guides/test/snapshot.md +0 -95
- package/docs/guides/test/spy-on.md +0 -46
- package/docs/guides/test/svelte-test.md +0 -120
- package/docs/guides/test/testing-library.md +0 -92
- package/docs/guides/test/timeout.md +0 -15
- package/docs/guides/test/todo-tests.md +0 -67
- package/docs/guides/test/update-snapshots.md +0 -46
- package/docs/guides/test/watch-mode.md +0 -19
- package/docs/guides/util/base64.md +0 -15
- package/docs/guides/util/deep-equals.md +0 -39
- package/docs/guides/util/deflate.md +0 -18
- package/docs/guides/util/detect-bun.md +0 -23
- package/docs/guides/util/entrypoint.md +0 -17
- package/docs/guides/util/escape-html.md +0 -22
- package/docs/guides/util/file-url-to-path.md +0 -14
- package/docs/guides/util/gzip.md +0 -18
- package/docs/guides/util/hash-a-password.md +0 -54
- package/docs/guides/util/import-meta-dir.md +0 -13
- package/docs/guides/util/import-meta-file.md +0 -13
- package/docs/guides/util/import-meta-path.md +0 -13
- package/docs/guides/util/javascript-uuid.md +0 -23
- package/docs/guides/util/main.md +0 -32
- package/docs/guides/util/path-to-file-url.md +0 -14
- package/docs/guides/util/sleep.md +0 -22
- package/docs/guides/util/version.md +0 -21
- package/docs/guides/util/which-path-to-executable-bin.md +0 -15
- package/docs/guides/websocket/compression.md +0 -31
- package/docs/guides/websocket/context.md +0 -77
- package/docs/guides/websocket/pubsub.md +0 -41
- package/docs/guides/websocket/simple.md +0 -33
- package/docs/guides/write-file/append.md +0 -52
- package/docs/guides/write-file/basic.md +0 -44
- package/docs/guides/write-file/blob.md +0 -28
- package/docs/guides/write-file/cat.md +0 -17
- package/docs/guides/write-file/file-cp.md +0 -16
- package/docs/guides/write-file/filesink.md +0 -52
- package/docs/guides/write-file/response.md +0 -17
- package/docs/guides/write-file/stdout.md +0 -21
- package/docs/guides/write-file/stream.md +0 -17
- package/docs/guides/write-file/unlink.md +0 -16
- package/docs/index.md +0 -77
- package/docs/install/audit.md +0 -57
- package/docs/install/cache.md +0 -59
- package/docs/install/catalogs.md +0 -298
- package/docs/install/index.md +0 -248
- package/docs/install/isolated.md +0 -197
- package/docs/install/lifecycle.md +0 -46
- package/docs/install/lockfile.md +0 -58
- package/docs/install/npmrc.md +0 -105
- package/docs/install/overrides.md +0 -73
- package/docs/install/patch.md +0 -59
- package/docs/install/registries.md +0 -30
- package/docs/install/security-scanner-api.md +0 -81
- package/docs/install/workspaces.md +0 -114
- package/docs/installation.md +0 -327
- package/docs/project/asan.md +0 -124
- package/docs/project/benchmarking.md +0 -203
- package/docs/project/bindgen.md +0 -225
- package/docs/project/building-windows.md +0 -162
- package/docs/project/contributing.md +0 -347
- 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/autoimport.md +0 -94
- package/docs/runtime/bun-apis.md +0 -207
- package/docs/runtime/bunfig.md +0 -772
- package/docs/runtime/debugger.md +0 -325
- package/docs/runtime/env.md +0 -253
- package/docs/runtime/hot.md +0 -145
- package/docs/runtime/index.md +0 -312
- package/docs/runtime/jsx.md +0 -385
- package/docs/runtime/loaders.md +0 -130
- package/docs/runtime/modules.md +0 -320
- package/docs/runtime/nodejs-apis.md +0 -463
- package/docs/runtime/plugins.md +0 -561
- package/docs/runtime/shell.md +0 -605
- 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/discovery.md +0 -85
- 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/reporters.md +0 -117
- package/docs/test/runtime-behavior.md +0 -95
- package/docs/test/snapshots.md +0 -68
- package/docs/test/time.md +0 -126
- package/docs/test/writing.md +0 -825
- package/docs/typescript.md +0 -53
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Deploy a Bun application on Railway
|
|
3
|
-
description: Deploy Bun applications to Railway with this step-by-step guide covering CLI and dashboard methods, optional PostgreSQL setup, and automatic SSL configuration.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud. It enables instant deployments from GitHub with zero configuration, automatic SSL, and built-in database provisioning.
|
|
7
|
-
|
|
8
|
-
This guide walks through deploying a Bun application with a PostgreSQL database (optional), which is exactly what the template below provides.
|
|
9
|
-
|
|
10
|
-
You can either follow this guide step-by-step or simply deploy the pre-configured template with one click:
|
|
11
|
-
|
|
12
|
-
{% raw %}
|
|
13
|
-
|
|
14
|
-
<a href="https://railway.com/deploy/bun-react-postgres?referralCode=Bun&utm_medium=integration&utm_source=template&utm_campaign=bun" target="_blank">
|
|
15
|
-
<img src="https://railway.com/button.svg" alt="Deploy on Railway" />
|
|
16
|
-
</a>
|
|
17
|
-
|
|
18
|
-
{% /raw %}
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
**Prerequisites**:
|
|
23
|
-
|
|
24
|
-
- A Bun application ready for deployment
|
|
25
|
-
- A [Railway account](https://railway.app/)
|
|
26
|
-
- Railway CLI (for CLI deployment method)
|
|
27
|
-
- A GitHub account (for Dashboard deployment method)
|
|
28
|
-
|
|
29
|
-
---
|
|
30
|
-
|
|
31
|
-
## Method 1: Deploy via CLI
|
|
32
|
-
|
|
33
|
-
---
|
|
34
|
-
|
|
35
|
-
#### Step 1
|
|
36
|
-
|
|
37
|
-
Ensure sure you have the Railway CLI installed.
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
bun install -g @railway/cli
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
---
|
|
44
|
-
|
|
45
|
-
#### Step 2
|
|
46
|
-
|
|
47
|
-
Log into your Railway account.
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
railway login
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
---
|
|
54
|
-
|
|
55
|
-
#### Step 3
|
|
56
|
-
|
|
57
|
-
After successfully authenticating, initialize a new project.
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
# Initialize project
|
|
61
|
-
bun-react-postgres$ railway init
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
---
|
|
65
|
-
|
|
66
|
-
#### Step 4
|
|
67
|
-
|
|
68
|
-
After initializing the project, add a new database and service.
|
|
69
|
-
|
|
70
|
-
> **Note:** Step 4 is only necessary if your application uses a database. If you don't need PostgreSQL, skip to Step 5.
|
|
71
|
-
|
|
72
|
-
```bash
|
|
73
|
-
# Add PostgreSQL database. Make sure to add this first!
|
|
74
|
-
bun-react-postgres$ railway add --database postgres
|
|
75
|
-
|
|
76
|
-
# Add your application service.
|
|
77
|
-
bun-react-postgres$ railway add --service bun-react-db --variables DATABASE_URL=\${{Postgres.DATABASE_URL}}
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
---
|
|
81
|
-
|
|
82
|
-
#### Step 5
|
|
83
|
-
|
|
84
|
-
After the services have been created and connected, deploy the application to Railway. By default, services are only accessible within Railway's private network. To make your app publicly accessible, you need to generate a public domain.
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
# Deploy your application
|
|
88
|
-
bun-nextjs-starter$ railway up
|
|
89
|
-
|
|
90
|
-
# Generate public domain
|
|
91
|
-
bun-nextjs-starter$ railway domain
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
---
|
|
95
|
-
|
|
96
|
-
## Method 2: Deploy via Dashboard
|
|
97
|
-
|
|
98
|
-
---
|
|
99
|
-
|
|
100
|
-
#### Step 1
|
|
101
|
-
|
|
102
|
-
Create a new project
|
|
103
|
-
|
|
104
|
-
1. Go to [Railway Dashboard](http://railway.com/dashboard?utm_medium=integration&utm_source=docs&utm_campaign=bun)
|
|
105
|
-
2. Click **"+ New"** → **"GitHub repo"**
|
|
106
|
-
3. Choose your repository
|
|
107
|
-
|
|
108
|
-
---
|
|
109
|
-
|
|
110
|
-
#### Step 2
|
|
111
|
-
|
|
112
|
-
Add a PostgreSQL database, and connect this database to the service
|
|
113
|
-
|
|
114
|
-
> **Note:** Step 2 is only necessary if your application uses a database. If you don't need PostgreSQL, skip to Step 3.
|
|
115
|
-
|
|
116
|
-
1. Click **"+ New"** → **"Database"** → **"Add PostgreSQL"**
|
|
117
|
-
2. After the database has been created, select your service (not the database)
|
|
118
|
-
3. Go to **"Variables"** tab
|
|
119
|
-
4. Click **"+ New Variable"** → **"Add Reference"**
|
|
120
|
-
5. Select `DATABASE_URL` from postgres
|
|
121
|
-
|
|
122
|
-
---
|
|
123
|
-
|
|
124
|
-
#### Step 3
|
|
125
|
-
|
|
126
|
-
Generate a public domain
|
|
127
|
-
|
|
128
|
-
1. Select your service
|
|
129
|
-
2. Go to **"Settings"** tab
|
|
130
|
-
3. Under **"Networking"**, click **"Generate Domain"**
|
|
131
|
-
|
|
132
|
-
---
|
|
133
|
-
|
|
134
|
-
Your app is now live! Railway auto-deploys on every GitHub push.
|
|
135
|
-
|
|
136
|
-
---
|
|
137
|
-
|
|
138
|
-
## Configuration (Optional)
|
|
139
|
-
|
|
140
|
-
---
|
|
141
|
-
|
|
142
|
-
By default, Railway uses [Nixpacks](https://docs.railway.com/guides/build-configuration#nixpacks-options) to automatically detect and build your Bun application with zero configuration.
|
|
143
|
-
|
|
144
|
-
However, using the [Railpack](https://docs.railway.com/guides/build-configuration#railpack) application builder provides better Bun support, and will always support the latest version of Bun. The pre-configured templates use Railpack by default.
|
|
145
|
-
|
|
146
|
-
To enable Railpack in a custom project, add the following to your `railway.json`:
|
|
147
|
-
|
|
148
|
-
```json
|
|
149
|
-
{
|
|
150
|
-
"$schema": "https://railway.com/railway.schema.json",
|
|
151
|
-
"build": {
|
|
152
|
-
"builder": "RAILPACK"
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
For more build configuration settings, check out the [Railway documentation](https://docs.railway.com/guides/build-configuration).
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Build an app with Astro and Bun
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
Initialize a fresh Astro app with `bun create astro`. The `create-astro` package detects when you are using `bunx` and will automatically install dependencies using `bun`.
|
|
6
|
-
|
|
7
|
-
```sh
|
|
8
|
-
$ bun create astro
|
|
9
|
-
╭─────╮ Houston:
|
|
10
|
-
│ ◠ ◡ ◠ We're glad to have you on board.
|
|
11
|
-
╰─────╯
|
|
12
|
-
|
|
13
|
-
astro v3.1.4 Launch sequence initiated.
|
|
14
|
-
|
|
15
|
-
dir Where should we create your new project?
|
|
16
|
-
./fumbling-field
|
|
17
|
-
|
|
18
|
-
tmpl How would you like to start your new project?
|
|
19
|
-
Use blog template
|
|
20
|
-
✔ Template copied
|
|
21
|
-
|
|
22
|
-
deps Install dependencies?
|
|
23
|
-
Yes
|
|
24
|
-
✔ Dependencies installed
|
|
25
|
-
|
|
26
|
-
ts Do you plan to write TypeScript?
|
|
27
|
-
Yes
|
|
28
|
-
|
|
29
|
-
use How strict should TypeScript be?
|
|
30
|
-
Strict
|
|
31
|
-
✔ TypeScript customized
|
|
32
|
-
|
|
33
|
-
git Initialize a new git repository?
|
|
34
|
-
Yes
|
|
35
|
-
✔ Git initialized
|
|
36
|
-
|
|
37
|
-
next Liftoff confirmed. Explore your project!
|
|
38
|
-
|
|
39
|
-
Enter your project directory using cd ./fumbling-field
|
|
40
|
-
Run `bun run dev` to start the dev server. CTRL+C to stop.
|
|
41
|
-
Add frameworks like react or tailwind using astro add.
|
|
42
|
-
|
|
43
|
-
Stuck? Join us at https://astro.build/chat
|
|
44
|
-
|
|
45
|
-
╭─────╮ Houston:
|
|
46
|
-
│ ◠ ◡ ◠ Good luck out there, astronaut! 🚀
|
|
47
|
-
╰─────╯
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
---
|
|
51
|
-
|
|
52
|
-
Start the dev server with `bunx`.
|
|
53
|
-
|
|
54
|
-
By default, Bun will run the dev server with Node.js. To use the Bun runtime instead, use the `--bun` flag.
|
|
55
|
-
|
|
56
|
-
```sh
|
|
57
|
-
$ bunx --bun astro dev
|
|
58
|
-
🚀 astro v3.1.4 started in 200ms
|
|
59
|
-
|
|
60
|
-
┃ Local http://localhost:4321/
|
|
61
|
-
┃ Network use --host to expose
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
---
|
|
65
|
-
|
|
66
|
-
Open [http://localhost:4321](http://localhost:4321) with your browser to see the result. Astro will hot-reload your app as you edit your source files.
|
|
67
|
-
|
|
68
|
-
{% image src="https://i.imgur.com/Dswiu6w.png" caption="An Astro v3 starter app running on Bun" %}
|
|
69
|
-
|
|
70
|
-
---
|
|
71
|
-
|
|
72
|
-
Refer to the [Astro docs](https://docs.astro.build/en/getting-started/) for complete documentation.
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Create a Discord bot
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
Discord.js works out of the box with Bun. Let's write a simple bot. First create a directory and initialize it with `bun init`.
|
|
6
|
-
|
|
7
|
-
```sh
|
|
8
|
-
$ mkdir my-bot
|
|
9
|
-
$ cd my-bot
|
|
10
|
-
$ bun init
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
Now install Discord.js.
|
|
16
|
-
|
|
17
|
-
```sh
|
|
18
|
-
$ bun add discord.js
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
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/setting-up-a-bot-application.html#creating-your-bot) for step-by-step instructions.
|
|
24
|
-
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
Once complete, you'll be presented with your bot's _private key_. Let's add this to a file called `.env.local`. Bun automatically reads this file and loads it into `process.env`.
|
|
28
|
-
|
|
29
|
-
{% callout %}
|
|
30
|
-
This is an example token that has already been invalidated.
|
|
31
|
-
{% /callout %}
|
|
32
|
-
|
|
33
|
-
```txt#.env.local
|
|
34
|
-
DISCORD_TOKEN=NzkyNzE1NDU0MTk2MDg4ODQy.X-hvzA.Ovy4MCQywSkoMRRclStW4xAYK7I
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
---
|
|
38
|
-
|
|
39
|
-
Be sure to add `.env.local` to your `.gitignore`! It is dangerous to check your bot's private key into version control.
|
|
40
|
-
|
|
41
|
-
```txt#.gitignore
|
|
42
|
-
node_modules
|
|
43
|
-
.env.local
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
---
|
|
47
|
-
|
|
48
|
-
Now let's actually write our bot in a new file called `bot.ts`.
|
|
49
|
-
|
|
50
|
-
```ts#bot.ts
|
|
51
|
-
// import discord.js
|
|
52
|
-
import {Client, Events, GatewayIntentBits} from 'discord.js';
|
|
53
|
-
|
|
54
|
-
// create a new Client instance
|
|
55
|
-
const client = new Client({intents: [GatewayIntentBits.Guilds]});
|
|
56
|
-
|
|
57
|
-
// listen for the client to be ready
|
|
58
|
-
client.once(Events.ClientReady, (c) => {
|
|
59
|
-
console.log(`Ready! Logged in as ${c.user.tag}`);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// login with the token from .env.local
|
|
63
|
-
client.login(process.env.DISCORD_TOKEN);
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
---
|
|
67
|
-
|
|
68
|
-
Now we can run our bot with `bun run`. It may take a several seconds for the client to initialize the first time you run the file.
|
|
69
|
-
|
|
70
|
-
```sh
|
|
71
|
-
$ bun run bot.ts
|
|
72
|
-
Ready! Logged in as my-bot#1234
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
---
|
|
76
|
-
|
|
77
|
-
You're up and running with a bare-bones Discord.js bot! This is a basic guide to setting up your bot with Bun; we recommend the [official discord.js docs](https://discordjs.guide/) for complete information on the `discord.js` API.
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Containerize a Bun application with Docker
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
{% callout %}
|
|
6
|
-
This guide assumes you already have [Docker Desktop](https://www.docker.com/products/docker-desktop/) installed.
|
|
7
|
-
{% /callout %}
|
|
8
|
-
|
|
9
|
-
[Docker](https://www.docker.com) is a platform for packaging and running an application as a lightweight, portable _container_ that encapsulates all the necessary dependencies.
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
To _containerize_ our application, we define a `Dockerfile`. This file contains a list of instructions to initialize the container, copy our local project files into it, install dependencies, and starts the application.
|
|
14
|
-
|
|
15
|
-
```docker#Dockerfile
|
|
16
|
-
# use the official Bun image
|
|
17
|
-
# see all versions at https://hub.docker.com/r/oven/bun/tags
|
|
18
|
-
FROM oven/bun:1 AS base
|
|
19
|
-
WORKDIR /usr/src/app
|
|
20
|
-
|
|
21
|
-
# install dependencies into temp directory
|
|
22
|
-
# this will cache them and speed up future builds
|
|
23
|
-
FROM base AS install
|
|
24
|
-
RUN mkdir -p /temp/dev
|
|
25
|
-
COPY package.json bun.lock /temp/dev/
|
|
26
|
-
RUN cd /temp/dev && bun install --frozen-lockfile
|
|
27
|
-
|
|
28
|
-
# install with --production (exclude devDependencies)
|
|
29
|
-
RUN mkdir -p /temp/prod
|
|
30
|
-
COPY package.json bun.lock /temp/prod/
|
|
31
|
-
RUN cd /temp/prod && bun install --frozen-lockfile --production
|
|
32
|
-
|
|
33
|
-
# copy node_modules from temp directory
|
|
34
|
-
# then copy all (non-ignored) project files into the image
|
|
35
|
-
FROM base AS prerelease
|
|
36
|
-
COPY --from=install /temp/dev/node_modules node_modules
|
|
37
|
-
COPY . .
|
|
38
|
-
|
|
39
|
-
# [optional] tests & build
|
|
40
|
-
ENV NODE_ENV=production
|
|
41
|
-
RUN bun test
|
|
42
|
-
RUN bun run build
|
|
43
|
-
|
|
44
|
-
# copy production dependencies and source code into final image
|
|
45
|
-
FROM base AS release
|
|
46
|
-
COPY --from=install /temp/prod/node_modules node_modules
|
|
47
|
-
COPY --from=prerelease /usr/src/app/index.ts .
|
|
48
|
-
COPY --from=prerelease /usr/src/app/package.json .
|
|
49
|
-
|
|
50
|
-
# run the app
|
|
51
|
-
USER bun
|
|
52
|
-
EXPOSE 3000/tcp
|
|
53
|
-
ENTRYPOINT [ "bun", "run", "index.ts" ]
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
---
|
|
57
|
-
|
|
58
|
-
Now that you have your docker image, let's look at `.dockerignore` which has the same syntax as `.gitignore`, here you need to specify the files/directories that must not go in any stage of the docker build. An example for a ignore file is
|
|
59
|
-
|
|
60
|
-
```txt#.dockerignore
|
|
61
|
-
node_modules
|
|
62
|
-
Dockerfile*
|
|
63
|
-
docker-compose*
|
|
64
|
-
.dockerignore
|
|
65
|
-
.git
|
|
66
|
-
.gitignore
|
|
67
|
-
README.md
|
|
68
|
-
LICENSE
|
|
69
|
-
.vscode
|
|
70
|
-
Makefile
|
|
71
|
-
helm-charts
|
|
72
|
-
.env
|
|
73
|
-
.editorconfig
|
|
74
|
-
.idea
|
|
75
|
-
coverage*
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
---
|
|
79
|
-
|
|
80
|
-
We'll now use `docker build` to convert this `Dockerfile` into a _Docker image_, a self-contained template containing all the dependencies and configuration required to run the application.
|
|
81
|
-
|
|
82
|
-
The `-t` flag lets us specify a name for the image, and `--pull` tells Docker to automatically download the latest version of the base image (`oven/bun`). The initial build will take longer, as Docker will download all the base images and dependencies.
|
|
83
|
-
|
|
84
|
-
```bash
|
|
85
|
-
$ docker build --pull -t bun-hello-world .
|
|
86
|
-
[+] Building 0.9s (21/21) FINISHED
|
|
87
|
-
=> [internal] load build definition from Dockerfile 0.0s
|
|
88
|
-
=> => transferring dockerfile: 37B 0.0s
|
|
89
|
-
=> [internal] load .dockerignore 0.0s
|
|
90
|
-
=> => transferring context: 35B 0.0s
|
|
91
|
-
=> [internal] load metadata for docker.io/oven/bun:1 0.8s
|
|
92
|
-
=> [auth] oven/bun:pull token for registry-1.docker.io 0.0s
|
|
93
|
-
=> [base 1/2] FROM docker.io/oven/bun:1@sha256:373265748d3cd3624cb3f3ee6004f45b1fc3edbd07a622aeeec17566d2756997 0.0s
|
|
94
|
-
=> [internal] load build context 0.0s
|
|
95
|
-
=> => transferring context: 155B 0.0s
|
|
96
|
-
# ...lots of commands...
|
|
97
|
-
=> exporting to image 0.0s
|
|
98
|
-
=> => exporting layers 0.0s
|
|
99
|
-
=> => writing image sha256:360663f7fdcd6f11e8e94761d5592e2e4dfc8d167f034f15cd5a863d5dc093c4 0.0s
|
|
100
|
-
=> => naming to docker.io/library/bun-hello-world 0.0s
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
---
|
|
104
|
-
|
|
105
|
-
We've built a new _Docker image_. Now let's use that image to spin up an actual, running _container_.
|
|
106
|
-
|
|
107
|
-
We'll use `docker run` to start a new container using the `bun-hello-world` image. It will be run in _detached_ mode (`-d`) and we'll map the container's port 3000 to our local machine's port 3000 (`-p 3000:3000`).
|
|
108
|
-
|
|
109
|
-
The `run` command prints a string representing the _container ID_.
|
|
110
|
-
|
|
111
|
-
```sh
|
|
112
|
-
$ docker run -d -p 3000:3000 bun-hello-world
|
|
113
|
-
7f03e212a15ede8644379bce11a13589f563d3909a9640446c5bbefce993678d
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
---
|
|
117
|
-
|
|
118
|
-
The container is now running in the background. Visit [localhost:3000](http://localhost:3000). You should see a `Hello, World!` message.
|
|
119
|
-
|
|
120
|
-
---
|
|
121
|
-
|
|
122
|
-
To stop the container, we'll use `docker stop <container-id>`.
|
|
123
|
-
|
|
124
|
-
```sh
|
|
125
|
-
$ docker stop 7f03e212a15ede8644379bce11a13589f563d3909a9640446c5bbefce993678d
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
---
|
|
129
|
-
|
|
130
|
-
If you can't find the container ID, you can use `docker ps` to list all running containers.
|
|
131
|
-
|
|
132
|
-
```sh
|
|
133
|
-
$ docker ps
|
|
134
|
-
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
|
135
|
-
7f03e212a15e bun-hello-world "bun run index.ts" 2 minutes ago Up 2 minutes 0.0.0.0:3000->3000/tcp flamboyant_cerf
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
---
|
|
139
|
-
|
|
140
|
-
That's it! Refer to the [Docker documentation](https://docs.docker.com/) for more advanced usage.
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Use Drizzle ORM with Bun
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
Drizzle is an ORM that supports both a SQL-like "query builder" API and an ORM-like [Queries API](https://orm.drizzle.team/docs/rqb). It supports the `bun:sqlite` built-in module.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
Let's get started by creating a fresh project with `bun init` and installing Drizzle.
|
|
10
|
-
|
|
11
|
-
```sh
|
|
12
|
-
$ bun init -y
|
|
13
|
-
$ bun add drizzle-orm
|
|
14
|
-
$ bun add -D drizzle-kit
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
Then we'll connect to a SQLite database using the `bun:sqlite` module and create the Drizzle database instance.
|
|
20
|
-
|
|
21
|
-
```ts#db.ts
|
|
22
|
-
import { drizzle } from "drizzle-orm/bun-sqlite";
|
|
23
|
-
import { Database } from "bun:sqlite";
|
|
24
|
-
|
|
25
|
-
const sqlite = new Database("sqlite.db");
|
|
26
|
-
export const db = drizzle(sqlite);
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
---
|
|
30
|
-
|
|
31
|
-
To see the database in action, add these lines to `index.ts`.
|
|
32
|
-
|
|
33
|
-
```ts#index.ts
|
|
34
|
-
import { db } from "./db";
|
|
35
|
-
import { sql } from "drizzle-orm";
|
|
36
|
-
|
|
37
|
-
const query = sql`select "hello world" as text`;
|
|
38
|
-
const result = db.get<{ text: string }>(query);
|
|
39
|
-
console.log(result);
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
---
|
|
43
|
-
|
|
44
|
-
Then run `index.ts` with Bun. Bun will automatically create `sqlite.db` and execute the query.
|
|
45
|
-
|
|
46
|
-
```sh
|
|
47
|
-
$ bun run index.ts
|
|
48
|
-
{
|
|
49
|
-
text: "hello world"
|
|
50
|
-
}
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
---
|
|
54
|
-
|
|
55
|
-
Lets give our database a proper schema. Create a `schema.ts` file and define a `movies` table.
|
|
56
|
-
|
|
57
|
-
```ts#schema.ts
|
|
58
|
-
import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core";
|
|
59
|
-
|
|
60
|
-
export const movies = sqliteTable("movies", {
|
|
61
|
-
id: integer("id").primaryKey(),
|
|
62
|
-
title: text("name"),
|
|
63
|
-
releaseYear: integer("release_year"),
|
|
64
|
-
});
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
---
|
|
68
|
-
|
|
69
|
-
We can use the `drizzle-kit` CLI to generate an initial SQL migration.
|
|
70
|
-
|
|
71
|
-
```sh
|
|
72
|
-
$ bunx drizzle-kit generate --dialect sqlite --schema ./schema.ts
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
---
|
|
76
|
-
|
|
77
|
-
This creates a new `drizzle` directory containing a `.sql` migration file and `meta` directory.
|
|
78
|
-
|
|
79
|
-
```txt
|
|
80
|
-
drizzle
|
|
81
|
-
├── 0000_ordinary_beyonder.sql
|
|
82
|
-
└── meta
|
|
83
|
-
├── 0000_snapshot.json
|
|
84
|
-
└── _journal.json
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
---
|
|
88
|
-
|
|
89
|
-
We can execute these migrations with a simple `migrate.ts` script.
|
|
90
|
-
|
|
91
|
-
This script creates a new connection to a SQLite database that writes to `sqlite.db`, then executes all unexecuted migrations in the `drizzle` directory.
|
|
92
|
-
|
|
93
|
-
```ts#migrate.ts
|
|
94
|
-
import { migrate } from "drizzle-orm/bun-sqlite/migrator";
|
|
95
|
-
|
|
96
|
-
import { drizzle } from "drizzle-orm/bun-sqlite";
|
|
97
|
-
import { Database } from "bun:sqlite";
|
|
98
|
-
|
|
99
|
-
const sqlite = new Database("sqlite.db");
|
|
100
|
-
const db = drizzle(sqlite);
|
|
101
|
-
migrate(db, { migrationsFolder: "./drizzle" });
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
---
|
|
105
|
-
|
|
106
|
-
We can run this script with `bun` to execute the migration.
|
|
107
|
-
|
|
108
|
-
```sh
|
|
109
|
-
$ bun run migrate.ts
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
---
|
|
113
|
-
|
|
114
|
-
Now that we have a database, let's add some data to it. Create a `seed.ts` file with the following contents.
|
|
115
|
-
|
|
116
|
-
```ts#seed.ts
|
|
117
|
-
import { db } from "./db";
|
|
118
|
-
import * as schema from "./schema";
|
|
119
|
-
|
|
120
|
-
await db.insert(schema.movies).values([
|
|
121
|
-
{
|
|
122
|
-
title: "The Matrix",
|
|
123
|
-
releaseYear: 1999,
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
title: "The Matrix Reloaded",
|
|
127
|
-
releaseYear: 2003,
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
title: "The Matrix Revolutions",
|
|
131
|
-
releaseYear: 2003,
|
|
132
|
-
},
|
|
133
|
-
]);
|
|
134
|
-
|
|
135
|
-
console.log(`Seeding complete.`);
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
---
|
|
139
|
-
|
|
140
|
-
Then run this file.
|
|
141
|
-
|
|
142
|
-
```sh
|
|
143
|
-
$ bun run seed.ts
|
|
144
|
-
Seeding complete.
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
---
|
|
148
|
-
|
|
149
|
-
We finally have a database with a schema and some sample data. Let's use Drizzle to query it. Replace the contents of `index.ts` with the following.
|
|
150
|
-
|
|
151
|
-
```ts#index.ts
|
|
152
|
-
import * as schema from "./schema";
|
|
153
|
-
import { db } from "./db";
|
|
154
|
-
|
|
155
|
-
const result = await db.select().from(schema.movies);
|
|
156
|
-
console.log(result);
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
---
|
|
160
|
-
|
|
161
|
-
Then run the file. You should see the three movies we inserted.
|
|
162
|
-
|
|
163
|
-
```sh
|
|
164
|
-
$ bun run index.ts
|
|
165
|
-
bun run index.ts
|
|
166
|
-
[
|
|
167
|
-
{
|
|
168
|
-
id: 1,
|
|
169
|
-
title: "The Matrix",
|
|
170
|
-
releaseYear: 1999
|
|
171
|
-
}, {
|
|
172
|
-
id: 2,
|
|
173
|
-
title: "The Matrix Reloaded",
|
|
174
|
-
releaseYear: 2003
|
|
175
|
-
}, {
|
|
176
|
-
id: 3,
|
|
177
|
-
title: "The Matrix Revolutions",
|
|
178
|
-
releaseYear: 2003
|
|
179
|
-
}
|
|
180
|
-
]
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
---
|
|
184
|
-
|
|
185
|
-
Refer to the [Drizzle website](https://orm.drizzle.team/docs/overview) for complete documentation.
|