@codemem/server 0.22.0-alpha.5 → 0.22.1
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/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +511 -51
- package/dist/index.js.map +1 -1
- package/dist/request-rate-limit.d.ts +8 -0
- package/dist/request-rate-limit.d.ts.map +1 -0
- package/dist/routes/config.d.ts.map +1 -1
- package/dist/routes/stats.d.ts +1 -1
- package/dist/routes/stats.d.ts.map +1 -1
- package/dist/routes/sync.d.ts +11 -1
- package/dist/routes/sync.d.ts.map +1 -1
- package/package.json +3 -2
- package/static/app.js +10158 -1594
- package/static/index.html +175 -45
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface InMemoryRequestRateLimiter {
|
|
2
|
+
check(key: string, limit: number): {
|
|
3
|
+
allowed: boolean;
|
|
4
|
+
retryAfterS: number;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export declare function createInMemoryRequestRateLimiter(windowMs?: number): InMemoryRequestRateLimiter;
|
|
8
|
+
//# sourceMappingURL=request-rate-limit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-rate-limit.d.ts","sourceRoot":"","sources":["../src/request-rate-limit.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,0BAA0B;IAC1C,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7E;AAED,wBAAgB,gCAAgC,CAAC,QAAQ,SAAS,GAAG,0BAA0B,CA2C9F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/routes/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAKN,KAAK,eAAe,EAKpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/routes/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAKN,KAAK,eAAe,EAKpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AA6E5B,MAAM,WAAW,kBAAkB;IAClC,UAAU,CAAC,EAAE,MAAM,eAAe,GAAG,IAAI,CAAC;CAC1C;AAmOD,wBAAgB,YAAY,CAAC,IAAI,GAAE,kBAAuB,8EA6GzD"}
|
package/dist/routes/stats.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../src/routes/stats.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../src/routes/stats.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,WAAW,EAAW,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B;;;GAGG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,WAAW,8EA2HtD"}
|
package/dist/routes/sync.d.ts
CHANGED
|
@@ -3,11 +3,21 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { MemoryStore } from "@codemem/core";
|
|
5
5
|
import { Hono } from "hono";
|
|
6
|
+
import type { InMemoryRequestRateLimiter } from "../request-rate-limit.js";
|
|
6
7
|
type StoreFactory = () => MemoryStore;
|
|
7
8
|
type SyncRuntimeStatus = {
|
|
8
9
|
phase: "starting" | "running" | "stopping" | "error" | "disabled" | "rebootstrapping" | "needs_attention" | null;
|
|
9
10
|
detail?: string | null;
|
|
10
11
|
};
|
|
12
|
+
interface SyncProtocolRouteOptions {
|
|
13
|
+
routeRateLimit?: {
|
|
14
|
+
limiter: InMemoryRequestRateLimiter;
|
|
15
|
+
readLimit: number;
|
|
16
|
+
mutationLimit: number;
|
|
17
|
+
unauthenticatedReadLimit: number;
|
|
18
|
+
unauthenticatedMutationLimit: number;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
11
21
|
/**
|
|
12
22
|
* Peer-to-peer sync protocol routes (/v1/*).
|
|
13
23
|
*
|
|
@@ -15,7 +25,7 @@ type SyncRuntimeStatus = {
|
|
|
15
25
|
* network-accessible. All requests are auth-gated via signature
|
|
16
26
|
* verification so unauthenticated callers are rejected.
|
|
17
27
|
*/
|
|
18
|
-
export declare function syncProtocolRoutes(getStore: StoreFactory): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
|
|
28
|
+
export declare function syncProtocolRoutes(getStore: StoreFactory, opts?: SyncProtocolRouteOptions): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
|
|
19
29
|
/**
|
|
20
30
|
* Viewer-facing sync management routes (/api/sync/*).
|
|
21
31
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/routes/sync.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/routes/sync.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,KAAK,EAAE,WAAW,EAAiB,MAAM,eAAe,CAAC;AA2BhE,OAAO,EAAgB,IAAI,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAE3E,KAAK,YAAY,GAAG,MAAM,WAAW,CAAC;AACtC,KAAK,iBAAiB,GAAG;IACxB,KAAK,EACF,UAAU,GACV,SAAS,GACT,UAAU,GACV,OAAO,GACP,UAAU,GACV,iBAAiB,GACjB,iBAAiB,GACjB,IAAI,CAAC;IACR,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF,UAAU,wBAAwB;IACjC,cAAc,CAAC,EAAE;QAChB,OAAO,EAAE,0BAA0B,CAAC;QACpC,SAAS,EAAE,MAAM,CAAC;QAClB,aAAa,EAAE,MAAM,CAAC;QACtB,wBAAwB,EAAE,MAAM,CAAC;QACjC,4BAA4B,EAAE,MAAM,CAAC;KACrC,CAAC;CACF;AA8pBD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,GAAE,wBAA6B,8EA+O7F;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CACzB,QAAQ,EAAE,YAAY,EACtB,oBAAoB,CAAC,EAAE,MAAM,iBAAiB,GAAG,IAAI,8EAyzBrD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codemem/server",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"@hono/node-server": "^1.14.3",
|
|
19
19
|
"drizzle-orm": "^0.45.1",
|
|
20
20
|
"hono": "^4.7.10",
|
|
21
|
-
"
|
|
21
|
+
"limiter": "^3.0.0",
|
|
22
|
+
"@codemem/core": "^0.22.1"
|
|
22
23
|
},
|
|
23
24
|
"devDependencies": {
|
|
24
25
|
"@types/better-sqlite3": "^7.6.13",
|