@gambrel/bun 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +52 -19
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,19 +1,52 @@
1
- # @gambrel/bun
2
-
3
- `Bun.serve` adapter
4
-
5
- Part of [Gambrel](https://github.com/thenolle/gambrel), a small TypeScript-first, JSX-based full-stack framework for Bun.
6
-
7
- ## Install
8
-
9
- ```bash
10
- bun add @gambrel/bun
11
- ```
12
-
13
- ## Documentation
14
-
15
- See the [Gambrel documentation](https://github.com/thenolle/gambrel/tree/master/docs).
16
-
17
- ## License
18
-
19
- Licensed under the PolyForm-Strict-1.0.0: noncommercial use only, no distribution, no modification. See the LICENSE file.
1
+ # @gambrel/bun
2
+
3
+ Bun server integration and static-file middleware for Gambrel.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ bun add @gambrel/bun @gambrel/core
9
+ ```
10
+
11
+ ## Serve an application
12
+
13
+ ```ts
14
+ import { serve } from '@gambrel/bun'
15
+ import { createApp } from '@gambrel/core'
16
+
17
+ const app = createApp().get('/', () => 'Hello')
18
+ const server = serve(app, { port: 3000 })
19
+
20
+ console.log(server.url.href)
21
+ ```
22
+
23
+ `serve` accepts `port`, `hostname`, and `development`. Use port 0 to request an available port.
24
+
25
+ Call `await server.stop()` to stop the server.
26
+
27
+ ## Serve static files
28
+
29
+ ```ts
30
+ import { staticFiles } from '@gambrel/bun'
31
+
32
+ app.use(staticFiles({
33
+ directory: 'dist/client',
34
+ prefix: '/assets'
35
+ }))
36
+ ```
37
+
38
+ GET and HEAD requests under the prefix serve files from the directory. Missing files return a plain-text 404 rather than falling through to an HTML page.
39
+
40
+ Keep the served directory limited to public assets. Do not place credentials or private data inside it.
41
+
42
+ ## Runtime
43
+
44
+ Bun.
45
+
46
+ ## Documentation
47
+
48
+ [Bun adapter reference](https://thenolle.github.io/gambrel/#/bun)
49
+
50
+ ## License
51
+
52
+ PolyForm Strict License 1.0.0. See LICENSE for permitted uses and restrictions.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gambrel/bun",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "`Bun.serve` adapter",
5
5
  "license": "PolyForm-Strict-1.0.0",
6
6
  "type": "module",
@@ -15,7 +15,7 @@
15
15
  }
16
16
  },
17
17
  "dependencies": {
18
- "@gambrel/core": "^0.2.0"
18
+ "@gambrel/core": "^0.2.2"
19
19
  },
20
20
  "files": [
21
21
  "dist",