oblien 2.2.37 → 2.2.39
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/README.md +2 -0
- package/dist/cdn.d.ts +135 -0
- package/dist/cdn.d.ts.map +1 -0
- package/dist/cdn.js +251 -0
- package/dist/cdn.js.map +1 -0
- package/dist/cli/commands/cdn.d.ts +3 -0
- package/dist/cli/commands/cdn.d.ts.map +1 -0
- package/dist/cli/commands/cdn.js +216 -0
- package/dist/cli/commands/cdn.js.map +1 -0
- package/dist/cli/commands/serve.d.ts +17 -0
- package/dist/cli/commands/serve.d.ts.map +1 -0
- package/dist/cli/commands/serve.js +113 -0
- package/dist/cli/commands/serve.js.map +1 -0
- package/dist/cli/commands/tunnel.d.ts +1 -0
- package/dist/cli/commands/tunnel.d.ts.map +1 -1
- package/dist/cli/commands/tunnel.js +100 -3
- package/dist/cli/commands/tunnel.js.map +1 -1
- package/dist/cli/index.js +14 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/client.d.ts +5 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +7 -0
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +48 -0
- package/dist/mcp/tools.js.map +1 -1
- package/dist/runtime/proxy.d.ts +55 -0
- package/dist/runtime/proxy.d.ts.map +1 -0
- package/dist/runtime/proxy.js +79 -0
- package/dist/runtime/proxy.js.map +1 -0
- package/dist/runtime.d.ts +16 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +18 -0
- package/dist/runtime.js.map +1 -1
- package/dist/server/static.d.ts +81 -0
- package/dist/server/static.d.ts.map +1 -0
- package/dist/server/static.js +465 -0
- package/dist/server/static.js.map +1 -0
- package/dist/types/cdn.d.ts +368 -0
- package/dist/types/cdn.d.ts.map +1 -0
- package/dist/types/cdn.js +10 -0
- package/dist/types/cdn.js.map +1 -0
- package/dist/types/client.d.ts +10 -0
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/docs/cdn.md +119 -0
- package/docs/runtime.md +30 -0
- package/docs/serve.md +84 -0
- package/package.json +1 -1
package/docs/serve.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Static server
|
|
2
|
+
|
|
3
|
+
Serve a folder over HTTP and put it on the public internet in one step. The
|
|
4
|
+
server is built entirely on Node's `http`/`fs` — **no extra dependencies** — and
|
|
5
|
+
the CLI wires it straight into the [edge tunnel](./edge-tunnel.md), so a
|
|
6
|
+
directory becomes a public HTTPS URL with a single command.
|
|
7
|
+
|
|
8
|
+
## CLI
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
oblien serve # serve ./public
|
|
12
|
+
oblien serve ./dist # serve ./dist
|
|
13
|
+
oblien serve ./dist --slug my-app # pick the public subdomain
|
|
14
|
+
oblien serve ./build --spa # single-page-app fallback
|
|
15
|
+
oblien serve ./site --domain preview.example.com
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
`oblien serve` starts a static server on a loopback port and then forwards it
|
|
19
|
+
through the edge exactly like `oblien tunnel <port>` — so every tunnel flag
|
|
20
|
+
works here too:
|
|
21
|
+
|
|
22
|
+
| Flag | Description |
|
|
23
|
+
| --- | --- |
|
|
24
|
+
| `--port <n>` | Local port to serve on (default: an OS-assigned free port) |
|
|
25
|
+
| `--slug <slug>` | Custom subdomain slug for the public URL |
|
|
26
|
+
| `--name <name>` | Tunnel display name (default: the folder name) |
|
|
27
|
+
| `--domain <domain>` | Base domain or exact custom hostname (see [edge-tunnel](./edge-tunnel.md)) |
|
|
28
|
+
| `--expires-in <ttl>` | Tunnel token TTL, e.g. `30s`, `5m`, `1h`, `7d` |
|
|
29
|
+
| `--spa` | Serve `index.html` for any unmatched path (client-side routing) |
|
|
30
|
+
| `--no-listing` | Disable auto-generated directory listings |
|
|
31
|
+
| `--index <file>` | Directory index filename (default: `index.html`) |
|
|
32
|
+
|
|
33
|
+
Press `Ctrl+C` to stop — the tunnel disconnects and the local server shuts down.
|
|
34
|
+
|
|
35
|
+
## What the server handles
|
|
36
|
+
|
|
37
|
+
- **Correct MIME types** for common web, font, image, media, and document extensions.
|
|
38
|
+
- **Streamed responses** (`createReadStream`) — large files never buffer in memory.
|
|
39
|
+
- **`Range` requests** — media seeking / resumable downloads return `206 Partial Content`.
|
|
40
|
+
- **Revalidation** — `ETag` + `Last-Modified` yield `304 Not Modified` on conditional requests.
|
|
41
|
+
- **Directory handling** — serves `index.html`, redirects `/dir` → `/dir/`, and renders a clean listing when there's no index (unless `--no-listing`).
|
|
42
|
+
- **SPA fallback** (`--spa`) — unmatched paths return the root `index.html`.
|
|
43
|
+
- **Path-traversal protection** — requests are resolved against the root; anything escaping it lexically is rejected (`403`), and a file whose canonical path (following symlinks) leaves the root is rejected (`404`).
|
|
44
|
+
- **Dotfiles denied by default** — `.git/`, `.env`, and other dot-paths return `404` (the server is often public), except `.well-known/`. Opt in with `allowDotfiles`.
|
|
45
|
+
|
|
46
|
+
## Programmatic use
|
|
47
|
+
|
|
48
|
+
The same server is exported from the SDK, so you can start it yourself and pair
|
|
49
|
+
it with the [`TunnelClient`](./edge-tunnel.md) or use it standalone:
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { startStaticServer } from 'oblien';
|
|
53
|
+
|
|
54
|
+
const site = await startStaticServer({
|
|
55
|
+
root: './public',
|
|
56
|
+
spa: true, // optional: index.html fallback
|
|
57
|
+
// port: 8080, // optional: default is an OS-assigned free port
|
|
58
|
+
// host: '127.0.0.1' // optional: default loopback only
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
console.log(`serving on ${site.url}`); // http://127.0.0.1:<port>
|
|
62
|
+
|
|
63
|
+
// ...later
|
|
64
|
+
await site.close();
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`startStaticServer(options)` resolves once the server is listening and returns a
|
|
68
|
+
handle: `{ port, host, url, server, close() }`. The `port` is always resolved —
|
|
69
|
+
even when you omit it and let the OS choose. For finer control, `createStaticServer(options)`
|
|
70
|
+
returns a non-listening `http.Server`, and `createStaticHandler(options)` returns a
|
|
71
|
+
raw `(req, res)` handler you can mount on your own server.
|
|
72
|
+
|
|
73
|
+
### Options
|
|
74
|
+
|
|
75
|
+
| Option | Type | Default | Description |
|
|
76
|
+
| --- | --- | --- | --- |
|
|
77
|
+
| `root` | `string` | — | Directory to serve (resolved against cwd) |
|
|
78
|
+
| `host` | `string` | `127.0.0.1` | Interface to bind |
|
|
79
|
+
| `port` | `number` | `0` (auto) | Port to listen on |
|
|
80
|
+
| `index` | `string` | `index.html` | Directory index filename |
|
|
81
|
+
| `listing` | `boolean` | `true` | Render a listing when a directory has no index |
|
|
82
|
+
| `spa` | `boolean` | `false` | Serve the root index for unmatched paths |
|
|
83
|
+
| `allowDotfiles` | `boolean` | `false` | Serve dotfiles/dot-directories (`.well-known/` is always allowed) |
|
|
84
|
+
| `onRequest` | `(info) => void` | — | Per-request hook: `{ method, path, status }` |
|