@heybejs/core 1.5.0 → 1.6.0

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 ADDED
@@ -0,0 +1,32 @@
1
+ # @heybejs/core
2
+
3
+ The [Heybe](https://github.com/emresandikci/heybe) server: an open source backend in a single binary with a database, auth, file storage, realtime and an admin dashboard, written in TypeScript on Bun.
4
+
5
+ Run it with [Bun](https://bun.sh) 1.4.4 or newer:
6
+
7
+ ```sh
8
+ bunx @heybejs/core serve
9
+ ```
10
+
11
+ Or install the `heybe` command:
12
+
13
+ ```sh
14
+ bun add -g @heybejs/core
15
+ heybe serve
16
+ ```
17
+
18
+ The dashboard is at http://127.0.0.1:8090/_/ and the REST API at http://127.0.0.1:8090/api/. The release binary, the install script and the Docker image run the same server without Bun: see [Getting started](https://emresandikci.github.io/heybe/getting-started).
19
+
20
+ Add it as a dev dependency to get editor types for `hb_hooks` and `hb_migrations`:
21
+
22
+ ```sh
23
+ bun add -d @heybejs/core
24
+ ```
25
+
26
+ ## Documentation
27
+
28
+ https://emresandikci.github.io/heybe/
29
+
30
+ ## License
31
+
32
+ [MIT](LICENSE)
package/package.json CHANGED
@@ -1,6 +1,20 @@
1
1
  {
2
2
  "name": "@heybejs/core",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
+ "description": "Open source backend in a single binary: database, auth, file storage, realtime and an admin dashboard. TypeScript on Bun.",
5
+ "keywords": [
6
+ "heybe",
7
+ "backend",
8
+ "baas",
9
+ "bun",
10
+ "typescript",
11
+ "sqlite",
12
+ "realtime",
13
+ "auth",
14
+ "file-storage",
15
+ "admin-dashboard",
16
+ "self-hosted"
17
+ ],
4
18
  "type": "module",
5
19
  "license": "MIT",
6
20
  "exports": "./src/index.ts",
@@ -25,6 +39,10 @@
25
39
  "url": "git+https://github.com/emresandikci/heybe.git",
26
40
  "directory": "packages/core"
27
41
  },
42
+ "homepage": "https://emresandikci.github.io/heybe/",
43
+ "bugs": {
44
+ "url": "https://github.com/emresandikci/heybe/issues"
45
+ },
28
46
  "devDependencies": {
29
47
  "@types/nodemailer": "^8.0.2",
30
48
  "autocannon": "^9.0.0",
@@ -19,6 +19,9 @@ import type { RequestEvent, Router } from "../router";
19
19
 
20
20
  const IDLE_TIMEOUT = 5 * 60_000;
21
21
  const MAX_TIMEOUT = 30 * 60_000;
22
+ // Frames written but not yet read by the client. A client that stops reading
23
+ // is closed here, before its buffer fills the server's memory.
24
+ const MAX_BUFFERED = 1000;
22
25
 
23
26
  const encoder = new TextEncoder();
24
27
 
@@ -94,6 +97,7 @@ async function realtimeConnect(e: RequestEvent): Promise<void> {
94
97
  } catch {
95
98
  return;
96
99
  }
100
+ if ((controller.desiredSize ?? 0) < -MAX_BUFFERED) return;
97
101
  timers.clearTimeout(idleTimer);
98
102
  idleTimer = timers.setTimeout(close, ce.idleTimeout);
99
103
  }
package/src/settings.ts CHANGED
@@ -200,7 +200,7 @@ const DEFAULTS: SettingsData = {
200
200
  { label: "/api/", audience: "", duration: 10, maxRequests: 300 },
201
201
  ],
202
202
  excludedIPs: [],
203
- enabled: false,
203
+ enabled: true,
204
204
  },
205
205
  trustedProxy: { headers: [], useLeftmostIP: false },
206
206
  batch: { enabled: false, maxRequests: 50, timeout: 3, maxBodySize: 0 },
package/src/test-app.ts CHANGED
@@ -4,7 +4,12 @@ import { type App, type AppOptions, createApp } from "./app";
4
4
  export function testApp(opts: AppOptions = {}): App {
5
5
  const app = createApp({ dir: ":memory:", ...opts });
6
6
  const { db } = app;
7
+ // Rate limiting is on by default; only the tests about it should turn it on.
7
8
  db.tx(() => {
9
+ db.run(
10
+ "INSERT OR IGNORE INTO _params (key, value) VALUES ('settings', ?)",
11
+ [JSON.stringify({ rateLimits: { enabled: false } })],
12
+ );
8
13
  const rows = db.query<{ id: string; data: string }>(
9
14
  "SELECT id, data FROM _collections WHERE type = 'auth' OR name = '_otps'",
10
15
  );