bun-types 1.3.2-canary.20251105T140650 → 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.
Files changed (308) hide show
  1. package/docs/README.md +28 -0
  2. package/package.json +1 -1
  3. package/docs/api/binary-data.md +0 -1038
  4. package/docs/api/cc.md +0 -197
  5. package/docs/api/color.md +0 -262
  6. package/docs/api/console.md +0 -57
  7. package/docs/api/cookie.md +0 -449
  8. package/docs/api/dns.md +0 -110
  9. package/docs/api/fetch.md +0 -463
  10. package/docs/api/ffi.md +0 -557
  11. package/docs/api/file-io.md +0 -366
  12. package/docs/api/file-system-router.md +0 -112
  13. package/docs/api/file.md +0 -19
  14. package/docs/api/glob.md +0 -178
  15. package/docs/api/globals.md +0 -387
  16. package/docs/api/hashing.md +0 -319
  17. package/docs/api/html-rewriter.md +0 -334
  18. package/docs/api/http.md +0 -1408
  19. package/docs/api/import-meta.md +0 -69
  20. package/docs/api/node-api.md +0 -14
  21. package/docs/api/redis.md +0 -597
  22. package/docs/api/s3.md +0 -850
  23. package/docs/api/secrets.md +0 -319
  24. package/docs/api/semver.md +0 -52
  25. package/docs/api/spawn.md +0 -582
  26. package/docs/api/sql.md +0 -1374
  27. package/docs/api/sqlite.md +0 -694
  28. package/docs/api/streams.md +0 -230
  29. package/docs/api/tcp.md +0 -221
  30. package/docs/api/transpiler.md +0 -276
  31. package/docs/api/udp.md +0 -123
  32. package/docs/api/utils.md +0 -891
  33. package/docs/api/websockets.md +0 -573
  34. package/docs/api/workers.md +0 -322
  35. package/docs/api/yaml.md +0 -668
  36. package/docs/benchmarks.md +0 -120
  37. package/docs/bun-flavored-toml.md +0 -42
  38. package/docs/bundler/css.md +0 -1028
  39. package/docs/bundler/css_modules.md +0 -145
  40. package/docs/bundler/executables.md +0 -626
  41. package/docs/bundler/fullstack.md +0 -418
  42. package/docs/bundler/hmr.md +0 -234
  43. package/docs/bundler/html.md +0 -349
  44. package/docs/bundler/index.md +0 -1735
  45. package/docs/bundler/intro.md +0 -75
  46. package/docs/bundler/loaders.md +0 -410
  47. package/docs/bundler/macros.md +0 -329
  48. package/docs/bundler/plugins.md +0 -449
  49. package/docs/bundler/vs-esbuild.md +0 -1127
  50. package/docs/cli/add.md +0 -173
  51. package/docs/cli/bun-completions.md +0 -3
  52. package/docs/cli/bun-create.md +0 -338
  53. package/docs/cli/bun-install.md +0 -349
  54. package/docs/cli/bun-upgrade.md +0 -39
  55. package/docs/cli/bunx.md +0 -89
  56. package/docs/cli/filter.md +0 -90
  57. package/docs/cli/info.md +0 -65
  58. package/docs/cli/init.md +0 -85
  59. package/docs/cli/install.md +0 -344
  60. package/docs/cli/link.md +0 -40
  61. package/docs/cli/outdated.md +0 -90
  62. package/docs/cli/patch-commit.md +0 -11
  63. package/docs/cli/pm.md +0 -285
  64. package/docs/cli/publish.md +0 -120
  65. package/docs/cli/remove.md +0 -7
  66. package/docs/cli/run.md +0 -261
  67. package/docs/cli/test.md +0 -397
  68. package/docs/cli/unlink.md +0 -9
  69. package/docs/cli/update.md +0 -129
  70. package/docs/cli/why.md +0 -67
  71. package/docs/contributing/upgrading-webkit.md +0 -57
  72. package/docs/ecosystem/elysia.md +0 -24
  73. package/docs/ecosystem/express.md +0 -37
  74. package/docs/ecosystem/hono.md +0 -18
  75. package/docs/ecosystem/react.md +0 -65
  76. package/docs/ecosystem/stric.md +0 -38
  77. package/docs/guides/binary/arraybuffer-to-array.md +0 -27
  78. package/docs/guides/binary/arraybuffer-to-blob.md +0 -24
  79. package/docs/guides/binary/arraybuffer-to-buffer.md +0 -25
  80. package/docs/guides/binary/arraybuffer-to-string.md +0 -15
  81. package/docs/guides/binary/arraybuffer-to-typedarray.md +0 -39
  82. package/docs/guides/binary/blob-to-arraybuffer.md +0 -14
  83. package/docs/guides/binary/blob-to-dataview.md +0 -14
  84. package/docs/guides/binary/blob-to-stream.md +0 -14
  85. package/docs/guides/binary/blob-to-string.md +0 -15
  86. package/docs/guides/binary/blob-to-typedarray.md +0 -14
  87. package/docs/guides/binary/buffer-to-arraybuffer.md +0 -14
  88. package/docs/guides/binary/buffer-to-blob.md +0 -14
  89. package/docs/guides/binary/buffer-to-readablestream.md +0 -41
  90. package/docs/guides/binary/buffer-to-string.md +0 -25
  91. package/docs/guides/binary/buffer-to-typedarray.md +0 -14
  92. package/docs/guides/binary/dataview-to-string.md +0 -15
  93. package/docs/guides/binary/typedarray-to-arraybuffer.md +0 -25
  94. package/docs/guides/binary/typedarray-to-blob.md +0 -16
  95. package/docs/guides/binary/typedarray-to-buffer.md +0 -14
  96. package/docs/guides/binary/typedarray-to-dataview.md +0 -14
  97. package/docs/guides/binary/typedarray-to-readablestream.md +0 -41
  98. package/docs/guides/binary/typedarray-to-string.md +0 -16
  99. package/docs/guides/deployment/railway.md +0 -157
  100. package/docs/guides/ecosystem/astro.md +0 -72
  101. package/docs/guides/ecosystem/discordjs.md +0 -77
  102. package/docs/guides/ecosystem/docker.md +0 -140
  103. package/docs/guides/ecosystem/drizzle.md +0 -185
  104. package/docs/guides/ecosystem/edgedb.md +0 -228
  105. package/docs/guides/ecosystem/elysia.md +0 -31
  106. package/docs/guides/ecosystem/express.md +0 -40
  107. package/docs/guides/ecosystem/hono.md +0 -39
  108. package/docs/guides/ecosystem/mongoose.md +0 -87
  109. package/docs/guides/ecosystem/neon-drizzle.md +0 -220
  110. package/docs/guides/ecosystem/neon-serverless-postgres.md +0 -55
  111. package/docs/guides/ecosystem/nextjs.md +0 -49
  112. package/docs/guides/ecosystem/nuxt.md +0 -56
  113. package/docs/guides/ecosystem/pm2.md +0 -57
  114. package/docs/guides/ecosystem/prisma.md +0 -141
  115. package/docs/guides/ecosystem/qwik.md +0 -107
  116. package/docs/guides/ecosystem/react.md +0 -50
  117. package/docs/guides/ecosystem/remix.md +0 -78
  118. package/docs/guides/ecosystem/render.md +0 -79
  119. package/docs/guides/ecosystem/sentry.md +0 -52
  120. package/docs/guides/ecosystem/solidstart.md +0 -58
  121. package/docs/guides/ecosystem/ssr-react.md +0 -51
  122. package/docs/guides/ecosystem/stric.md +0 -55
  123. package/docs/guides/ecosystem/sveltekit.md +0 -125
  124. package/docs/guides/ecosystem/systemd.md +0 -113
  125. package/docs/guides/ecosystem/vite.md +0 -71
  126. package/docs/guides/html-rewriter/extract-links.md +0 -68
  127. package/docs/guides/html-rewriter/extract-social-meta.md +0 -93
  128. package/docs/guides/http/cluster.md +0 -66
  129. package/docs/guides/http/fetch-unix.md +0 -33
  130. package/docs/guides/http/fetch.md +0 -24
  131. package/docs/guides/http/file-uploads.md +0 -94
  132. package/docs/guides/http/hot.md +0 -26
  133. package/docs/guides/http/proxy.md +0 -24
  134. package/docs/guides/http/server.md +0 -46
  135. package/docs/guides/http/simple.md +0 -18
  136. package/docs/guides/http/stream-file.md +0 -48
  137. package/docs/guides/http/stream-iterator.md +0 -47
  138. package/docs/guides/http/stream-node-streams-in-bun.md +0 -20
  139. package/docs/guides/http/tls.md +0 -30
  140. package/docs/guides/install/add-dev.md +0 -26
  141. package/docs/guides/install/add-git.md +0 -36
  142. package/docs/guides/install/add-optional.md +0 -25
  143. package/docs/guides/install/add-peer.md +0 -43
  144. package/docs/guides/install/add-tarball.md +0 -33
  145. package/docs/guides/install/add.md +0 -42
  146. package/docs/guides/install/azure-artifacts.md +0 -73
  147. package/docs/guides/install/cicd.md +0 -41
  148. package/docs/guides/install/custom-registry.md +0 -30
  149. package/docs/guides/install/from-npm-install-to-bun-install.md +0 -214
  150. package/docs/guides/install/git-diff-bun-lockfile.md +0 -44
  151. package/docs/guides/install/jfrog-artifactory.md +0 -28
  152. package/docs/guides/install/npm-alias.md +0 -23
  153. package/docs/guides/install/registry-scope.md +0 -38
  154. package/docs/guides/install/trusted.md +0 -46
  155. package/docs/guides/install/workspaces.md +0 -70
  156. package/docs/guides/install/yarnlock.md +0 -44
  157. package/docs/guides/process/argv.md +0 -58
  158. package/docs/guides/process/ctrl-c.md +0 -16
  159. package/docs/guides/process/ipc.md +0 -66
  160. package/docs/guides/process/nanoseconds.md +0 -13
  161. package/docs/guides/process/os-signals.md +0 -39
  162. package/docs/guides/process/spawn-stderr.md +0 -31
  163. package/docs/guides/process/spawn-stdout.md +0 -26
  164. package/docs/guides/process/spawn.md +0 -41
  165. package/docs/guides/process/stdin.md +0 -54
  166. package/docs/guides/read-file/arraybuffer.md +0 -28
  167. package/docs/guides/read-file/buffer.md +0 -19
  168. package/docs/guides/read-file/exists.md +0 -16
  169. package/docs/guides/read-file/json.md +0 -17
  170. package/docs/guides/read-file/mime.md +0 -20
  171. package/docs/guides/read-file/stream.md +0 -26
  172. package/docs/guides/read-file/string.md +0 -22
  173. package/docs/guides/read-file/uint8array.md +0 -21
  174. package/docs/guides/read-file/watch.md +0 -68
  175. package/docs/guides/runtime/build-time-constants.md +0 -293
  176. package/docs/guides/runtime/cicd.md +0 -43
  177. package/docs/guides/runtime/codesign-macos-executable.md +0 -56
  178. package/docs/guides/runtime/define-constant.md +0 -145
  179. package/docs/guides/runtime/delete-directory.md +0 -37
  180. package/docs/guides/runtime/delete-file.md +0 -19
  181. package/docs/guides/runtime/heap-snapshot.md +0 -26
  182. package/docs/guides/runtime/import-html.md +0 -15
  183. package/docs/guides/runtime/import-json.md +0 -44
  184. package/docs/guides/runtime/import-toml.md +0 -30
  185. package/docs/guides/runtime/import-yaml.md +0 -102
  186. package/docs/guides/runtime/read-env.md +0 -32
  187. package/docs/guides/runtime/set-env.md +0 -47
  188. package/docs/guides/runtime/shell.md +0 -40
  189. package/docs/guides/runtime/timezone.md +0 -35
  190. package/docs/guides/runtime/tsconfig-paths.md +0 -29
  191. package/docs/guides/runtime/typescript.md +0 -49
  192. package/docs/guides/runtime/vscode-debugger.md +0 -47
  193. package/docs/guides/runtime/web-debugger.md +0 -82
  194. package/docs/guides/streams/node-readable-to-arraybuffer.md +0 -11
  195. package/docs/guides/streams/node-readable-to-blob.md +0 -11
  196. package/docs/guides/streams/node-readable-to-json.md +0 -12
  197. package/docs/guides/streams/node-readable-to-string.md +0 -12
  198. package/docs/guides/streams/node-readable-to-uint8array.md +0 -11
  199. package/docs/guides/streams/to-array.md +0 -14
  200. package/docs/guides/streams/to-arraybuffer.md +0 -14
  201. package/docs/guides/streams/to-blob.md +0 -14
  202. package/docs/guides/streams/to-buffer.md +0 -15
  203. package/docs/guides/streams/to-json.md +0 -14
  204. package/docs/guides/streams/to-string.md +0 -14
  205. package/docs/guides/streams/to-typedarray.md +0 -22
  206. package/docs/guides/test/bail.md +0 -22
  207. package/docs/guides/test/coverage-threshold.md +0 -60
  208. package/docs/guides/test/coverage.md +0 -44
  209. package/docs/guides/test/happy-dom.md +0 -68
  210. package/docs/guides/test/migrate-from-jest.md +0 -143
  211. package/docs/guides/test/mock-clock.md +0 -48
  212. package/docs/guides/test/mock-functions.md +0 -68
  213. package/docs/guides/test/rerun-each.md +0 -14
  214. package/docs/guides/test/run-tests.md +0 -111
  215. package/docs/guides/test/skip-tests.md +0 -39
  216. package/docs/guides/test/snapshot.md +0 -95
  217. package/docs/guides/test/spy-on.md +0 -46
  218. package/docs/guides/test/svelte-test.md +0 -120
  219. package/docs/guides/test/testing-library.md +0 -92
  220. package/docs/guides/test/timeout.md +0 -15
  221. package/docs/guides/test/todo-tests.md +0 -67
  222. package/docs/guides/test/update-snapshots.md +0 -46
  223. package/docs/guides/test/watch-mode.md +0 -19
  224. package/docs/guides/util/base64.md +0 -15
  225. package/docs/guides/util/deep-equals.md +0 -39
  226. package/docs/guides/util/deflate.md +0 -18
  227. package/docs/guides/util/detect-bun.md +0 -23
  228. package/docs/guides/util/entrypoint.md +0 -17
  229. package/docs/guides/util/escape-html.md +0 -22
  230. package/docs/guides/util/file-url-to-path.md +0 -14
  231. package/docs/guides/util/gzip.md +0 -18
  232. package/docs/guides/util/hash-a-password.md +0 -54
  233. package/docs/guides/util/import-meta-dir.md +0 -13
  234. package/docs/guides/util/import-meta-file.md +0 -13
  235. package/docs/guides/util/import-meta-path.md +0 -13
  236. package/docs/guides/util/javascript-uuid.md +0 -23
  237. package/docs/guides/util/main.md +0 -32
  238. package/docs/guides/util/path-to-file-url.md +0 -14
  239. package/docs/guides/util/sleep.md +0 -22
  240. package/docs/guides/util/version.md +0 -21
  241. package/docs/guides/util/which-path-to-executable-bin.md +0 -15
  242. package/docs/guides/websocket/compression.md +0 -31
  243. package/docs/guides/websocket/context.md +0 -77
  244. package/docs/guides/websocket/pubsub.md +0 -41
  245. package/docs/guides/websocket/simple.md +0 -33
  246. package/docs/guides/write-file/append.md +0 -52
  247. package/docs/guides/write-file/basic.md +0 -44
  248. package/docs/guides/write-file/blob.md +0 -28
  249. package/docs/guides/write-file/cat.md +0 -17
  250. package/docs/guides/write-file/file-cp.md +0 -16
  251. package/docs/guides/write-file/filesink.md +0 -52
  252. package/docs/guides/write-file/response.md +0 -17
  253. package/docs/guides/write-file/stdout.md +0 -21
  254. package/docs/guides/write-file/stream.md +0 -17
  255. package/docs/guides/write-file/unlink.md +0 -16
  256. package/docs/index.md +0 -77
  257. package/docs/install/audit.md +0 -57
  258. package/docs/install/cache.md +0 -59
  259. package/docs/install/catalogs.md +0 -298
  260. package/docs/install/index.md +0 -248
  261. package/docs/install/isolated.md +0 -197
  262. package/docs/install/lifecycle.md +0 -46
  263. package/docs/install/lockfile.md +0 -58
  264. package/docs/install/npmrc.md +0 -105
  265. package/docs/install/overrides.md +0 -73
  266. package/docs/install/patch.md +0 -59
  267. package/docs/install/registries.md +0 -30
  268. package/docs/install/security-scanner-api.md +0 -81
  269. package/docs/install/workspaces.md +0 -114
  270. package/docs/installation.md +0 -327
  271. package/docs/project/asan.md +0 -124
  272. package/docs/project/benchmarking.md +0 -203
  273. package/docs/project/bindgen.md +0 -225
  274. package/docs/project/building-windows.md +0 -162
  275. package/docs/project/contributing.md +0 -347
  276. package/docs/project/internals/build-process-for-ci.md +0 -75
  277. package/docs/project/licensing.md +0 -73
  278. package/docs/project/roadmap.md +0 -87
  279. package/docs/quickstart.md +0 -157
  280. package/docs/runtime/autoimport.md +0 -94
  281. package/docs/runtime/bun-apis.md +0 -207
  282. package/docs/runtime/bunfig.md +0 -772
  283. package/docs/runtime/debugger.md +0 -325
  284. package/docs/runtime/env.md +0 -253
  285. package/docs/runtime/hot.md +0 -145
  286. package/docs/runtime/index.md +0 -312
  287. package/docs/runtime/jsx.md +0 -385
  288. package/docs/runtime/loaders.md +0 -130
  289. package/docs/runtime/modules.md +0 -320
  290. package/docs/runtime/nodejs-apis.md +0 -463
  291. package/docs/runtime/plugins.md +0 -561
  292. package/docs/runtime/shell.md +0 -605
  293. package/docs/runtime/typescript.md +0 -139
  294. package/docs/runtime/web-apis.md +0 -128
  295. package/docs/test/configuration.md +0 -154
  296. package/docs/test/coverage.md +0 -142
  297. package/docs/test/discovery.md +0 -85
  298. package/docs/test/dom.md +0 -75
  299. package/docs/test/examples/concurrent-test-glob.md +0 -132
  300. package/docs/test/hot.md +0 -15
  301. package/docs/test/lifecycle.md +0 -81
  302. package/docs/test/mocks.md +0 -313
  303. package/docs/test/reporters.md +0 -117
  304. package/docs/test/runtime-behavior.md +0 -95
  305. package/docs/test/snapshots.md +0 -68
  306. package/docs/test/time.md +0 -126
  307. package/docs/test/writing.md +0 -825
  308. 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.