@heybejs/core 1.5.1 → 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/package.json
CHANGED
|
@@ -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:
|
|
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
|
);
|