@cequrebackends/cequre-ts 0.12.1 → 0.12.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.
|
@@ -65,11 +65,11 @@ export declare function createBunWebSocketRoute({ path, heartbeat, onJoinRoom, }
|
|
|
65
65
|
timeout?: number;
|
|
66
66
|
} | false;
|
|
67
67
|
onJoinRoom?: (room: string, ws: CequreServerWebSocket) => MaybePromise<boolean>;
|
|
68
|
-
}): (request: Request, server
|
|
68
|
+
}): (request: Request, server?: any) => Promise<any>;
|
|
69
69
|
export declare function createBunWebSocketHandlers(): Bun.WebSocketHandler<CequreWebSocketData>;
|
|
70
70
|
export declare class CequreWebsocket {
|
|
71
71
|
static get manager(): WebSocketManager;
|
|
72
|
-
static route(options?: Parameters<typeof createBunWebSocketRoute>[0]): (request: Request, server
|
|
72
|
+
static route(options?: Parameters<typeof createBunWebSocketRoute>[0]): (request: Request, server?: any) => Promise<any>;
|
|
73
73
|
static handler(options?: Parameters<typeof createWebSocketHandler>[0]): CequreWebSocketHandler;
|
|
74
74
|
static handlers(): Bun.WebSocketHandler<CequreWebSocketData>;
|
|
75
75
|
static register(ws: CequreServerWebSocket): void;
|
package/dist/index.js
CHANGED
|
@@ -1449,12 +1449,12 @@ async function populateDocuments(schema, collectionSlug, docs, adapter, depth) {
|
|
|
1449
1449
|
// shared/main/runtime.ts
|
|
1450
1450
|
init_openapi();
|
|
1451
1451
|
init_kv();
|
|
1452
|
-
import { RateLimiter } from "@cequrebackends/
|
|
1452
|
+
import { RateLimiter } from "@cequrebackends/plugin-security";
|
|
1453
1453
|
init_logger();
|
|
1454
1454
|
import path from "path";
|
|
1455
1455
|
import { AsyncLocalStorage } from "async_hooks";
|
|
1456
|
-
import { computeAuditHmac, verifyAuditChain } from "@cequrebackends/
|
|
1457
|
-
import { encryptField, decryptField, isEncrypted } from "@cequrebackends/
|
|
1456
|
+
import { computeAuditHmac, verifyAuditChain } from "@cequrebackends/plugin-security";
|
|
1457
|
+
import { encryptField, decryptField, isEncrypted } from "@cequrebackends/plugin-security";
|
|
1458
1458
|
|
|
1459
1459
|
// shared/utils/crypto.ts
|
|
1460
1460
|
async function sha256Hex(input) {
|
|
@@ -2881,6 +2881,7 @@ class CequreRuntime {
|
|
|
2881
2881
|
},
|
|
2882
2882
|
maxBodyBytes: this.schema.core?.api?.maxBodyBytes,
|
|
2883
2883
|
idempotencyKV: this.idempotencyKV,
|
|
2884
|
+
state: (server2) => server2,
|
|
2884
2885
|
headers: {
|
|
2885
2886
|
...this.schema.security?.headers?.enabled ? {
|
|
2886
2887
|
"X-Content-Type-Options": "nosniff",
|
|
@@ -2969,7 +2970,7 @@ class CequreRuntime {
|
|
|
2969
2970
|
}
|
|
2970
2971
|
let executionPromise = (async () => {
|
|
2971
2972
|
let r2 = await this.router.handle(req, srv, ctx.user, this);
|
|
2972
|
-
return r2
|
|
2973
|
+
return r2;
|
|
2973
2974
|
})();
|
|
2974
2975
|
const timeoutMs = this.schema.core?.api?.requestTimeoutMs;
|
|
2975
2976
|
let timeoutHandle;
|
|
@@ -2984,7 +2985,7 @@ class CequreRuntime {
|
|
|
2984
2985
|
}
|
|
2985
2986
|
let res = await executionPromise;
|
|
2986
2987
|
for (const plugin of this.plugins) {
|
|
2987
|
-
if (plugin.afterRequest)
|
|
2988
|
+
if (plugin.afterRequest && res)
|
|
2988
2989
|
await plugin.afterRequest(ctx, res);
|
|
2989
2990
|
}
|
|
2990
2991
|
return res;
|
|
@@ -13,7 +13,7 @@ export interface DurableStreamStore {
|
|
|
13
13
|
* In-memory implementation of DurableStreamStore.
|
|
14
14
|
* [Development Only] This uses a local array ring buffer.
|
|
15
15
|
* It does not scale across multiple servers and loses data on restart.
|
|
16
|
-
* Use @cequrebackends/
|
|
16
|
+
* Use @cequrebackends/plugin-durable-streams for production.
|
|
17
17
|
*/
|
|
18
18
|
export declare class MemoryStreamStore implements DurableStreamStore {
|
|
19
19
|
private streams;
|
|
@@ -2,7 +2,7 @@ import type { TSchema, Static } from "@sinclair/typebox";
|
|
|
2
2
|
import type { CequreRuntime } from "./runtime";
|
|
3
3
|
import type { CequreRouteContext, CequreParams, CequreQuery } from "../core/request";
|
|
4
4
|
import { type BunRouteResult } from "../../adapters/bun/bun-response";
|
|
5
|
-
import type { CequreMonitoringAPI } from "@cequrebackends/
|
|
5
|
+
import type { CequreMonitoringAPI } from "@cequrebackends/plugin-monitoring";
|
|
6
6
|
export type CequreRouteHandler<TCollections extends Record<string, any> = any, TState = unknown, TParams extends TSchema | undefined = undefined, TQuery extends TSchema | undefined = undefined, TBody extends TSchema | undefined = undefined, TResponse extends TSchema | undefined = undefined> = (context: CequreRouteContext<TCollections, TState, TParams extends TSchema ? Static<TParams> : CequreParams, TQuery extends TSchema ? Static<TQuery> : CequreQuery, TBody extends TSchema ? Static<TBody> : unknown>) => TResponse extends TSchema ? BunRouteResult<Static<TResponse>> | Promise<BunRouteResult<Static<TResponse>>> : BunRouteResult | Promise<BunRouteResult>;
|
|
7
7
|
export interface CequreRouteOptions<TParams extends TSchema | undefined = undefined, TQuery extends TSchema | undefined = undefined, TBody extends TSchema | undefined = undefined, TResponse extends TSchema | undefined = undefined> {
|
|
8
8
|
body?: TBody;
|
|
@@ -4,12 +4,12 @@ import { type DurableStreamStore } from "../core/stream";
|
|
|
4
4
|
import type { AccessRules, AuthUser, CequreRequestContext } from "./access";
|
|
5
5
|
import type { Hooks } from "./hooks";
|
|
6
6
|
import { CequreRouter } from "./router";
|
|
7
|
-
import { type CequreMonitoringAPI } from "@cequrebackends/
|
|
8
|
-
import { RateLimiter } from "@cequrebackends/
|
|
7
|
+
import { type CequreMonitoringAPI } from "@cequrebackends/plugin-monitoring";
|
|
8
|
+
import { RateLimiter } from "@cequrebackends/plugin-security";
|
|
9
9
|
import { type CequreMailer } from "../core/email";
|
|
10
10
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
11
|
-
import { JWTAuthenticator } from "@cequrebackends/
|
|
12
|
-
import { type CequreAuditEvent } from "@cequrebackends/
|
|
11
|
+
import { JWTAuthenticator } from "@cequrebackends/plugin-security";
|
|
12
|
+
import { type CequreAuditEvent } from "@cequrebackends/plugin-security";
|
|
13
13
|
/**
|
|
14
14
|
* AsyncLocalStorage for propagating the request ID from the router
|
|
15
15
|
* to the runtime's audit calls without threading it through every
|