@cequrebackends/cequre-ts 0.13.0 → 0.14.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/dist/index.js CHANGED
@@ -22,34 +22,38 @@ import {
22
22
  sqlLiteral,
23
23
  validateCreate,
24
24
  validateUpdate
25
- } from "./index-kyvy0s1x.js";
25
+ } from "./index-6qbca8zn.js";
26
26
  import {
27
27
  CequreStreamMedia,
28
28
  methodNotAllowed,
29
29
  notFound,
30
30
  toResponse
31
31
  } from "./index-mfqj7cwr.js";
32
+ import {
33
+ CequreQueueManager
34
+ } from "./index-7xxm1add.js";
35
+ import {
36
+ CequreError,
37
+ buildErrorResponse,
38
+ extractPathname,
39
+ getConstraintErrorMessage,
40
+ getConstraintErrorStatus,
41
+ parseConstraintError,
42
+ toErrorResponse
43
+ } from "./index-qzzg2p5r.js";
32
44
  import {
33
45
  CequreErrorLogs,
34
46
  CequreKV,
35
- CequreQueueManager,
36
47
  createLogger,
37
48
  init_kv,
38
49
  init_logger,
39
50
  logger
40
- } from "./index-c3vh32en.js";
51
+ } from "./index-8bhn0nb4.js";
41
52
  import {
42
- CequreError,
43
53
  __require,
44
54
  __toCommonJS,
45
- buildErrorResponse,
46
- extractPathname,
47
- getConstraintErrorMessage,
48
- getConstraintErrorStatus,
49
- parseConstraintError,
50
- toErrorResponse,
51
55
  ulid
52
- } from "./index-17yswtmg.js";
56
+ } from "./index-cpw1bjf1.js";
53
57
 
54
58
  // shared/main/sse.ts
55
59
  var encoder = new TextEncoder;
@@ -2836,8 +2840,7 @@ class CequreRuntime {
2836
2840
  return toErrorResponse(err, req, this.adapter);
2837
2841
  }
2838
2842
  }
2839
- async start(options = {}) {
2840
- if (false) {}
2843
+ async init() {
2841
2844
  for (const plugin of this.plugins) {
2842
2845
  if (plugin.onInit) {
2843
2846
  await plugin.onInit(this);
@@ -2862,6 +2865,10 @@ class CequreRuntime {
2862
2865
  }
2863
2866
  await this.syncDatabaseSchema();
2864
2867
  await this.buildRoutes();
2868
+ }
2869
+ async start(options = {}) {
2870
+ if (false) {}
2871
+ await this.init();
2865
2872
  this.queue.startWorker();
2866
2873
  if (process.env.CEQURE_CLI_GENERATE) {
2867
2874
  const { generateTypeScriptClientSDK: generateTypeScriptClientSDK2 } = (init_sdk(), __toCommonJS(exports_sdk));
@@ -3076,7 +3083,7 @@ ${r}${b} |_| ${reset}
3076
3083
  `;
3077
3084
  if (!process.env.CEQURE_DEV) {
3078
3085
  console.log(banner);
3079
- } else {
3086
+ } else if (process.env.CEQURE_VITE_MODE !== "1") {
3080
3087
  const p = server ? server.port : options.port;
3081
3088
  console.log(`\uD83D\uDE80 Cequre API Framework started gracefully on port ${p}`);
3082
3089
  }
@@ -19,10 +19,11 @@ import {
19
19
  sqlLiteral,
20
20
  validateCreate,
21
21
  validateUpdate
22
- } from "../../index-kyvy0s1x.js";
22
+ } from "../../index-6qbca8zn.js";
23
+ import"../../index-qzzg2p5r.js";
23
24
  import {
24
25
  ulid
25
- } from "../../index-17yswtmg.js";
26
+ } from "../../index-cpw1bjf1.js";
26
27
  export {
27
28
  validateUpdate,
28
29
  validateCreate,
@@ -24,9 +24,9 @@ export interface CequreConfig {
24
24
  plugins?: CequrePlugin[];
25
25
  email?: import("../core/types").EmailConfig;
26
26
  streamStore?: DurableStreamStore;
27
- /** KV store config for rate limiter. Defaults to memory (single-instance). Use redis for multi-instance. */
27
+ /** KV store config for rate limiter. Defaults to memory (single-instance). Use redis for multi-instance. Use upstash for serverless. */
28
28
  kv?: {
29
- driver: "memory" | "sqlite" | "redis";
29
+ driver: "memory" | "sqlite" | "redis" | "upstash";
30
30
  redis?: {
31
31
  host?: string;
32
32
  port?: number;
@@ -35,13 +35,17 @@ export interface CequreConfig {
35
35
  sqlite?: {
36
36
  path?: string;
37
37
  };
38
+ upstash?: {
39
+ url?: string;
40
+ token?: string;
41
+ };
38
42
  };
39
43
  serverProvider?: import("../core/types").ServerProvider;
40
44
  cronProvider?: import("../core/types").CronProvider;
41
45
  realtimeProvider?: import("../core/types").RealtimeProvider;
42
46
  }
43
47
  import { CequreDurableQueue } from "../utils/durable-queue";
44
- export declare class CequreRuntime<TCollections extends Record<string, any> = Record<string, any>> {
48
+ export declare class CequreRuntime<TCollections extends Record<string, any> = Record<string, any>, TUser = AuthUser> {
45
49
  schema: CequreAST;
46
50
  adapter: CequreAdapter;
47
51
  router: CequreRouter<TCollections>;
@@ -181,6 +185,15 @@ export declare class CequreRuntime<TCollections extends Record<string, any> = Re
181
185
  */
182
186
  cron(name: string, schedule: string, handler: (app: CequreRuntime<TCollections>) => unknown): void;
183
187
  fetch(req: Request): Promise<Response>;
188
+ /**
189
+ * Initialize the runtime without starting a server. Used by serverless
190
+ * platforms (Vercel, Cloudflare) where the platform handles invocation.
191
+ * Runs: plugin init → adapter connect → schema sync → route building.
192
+ * Does NOT start: server, queue worker, cron scheduler, graceful shutdown.
193
+ *
194
+ * After init(), call `fetch(req)` to handle individual requests.
195
+ */
196
+ init(): Promise<void>;
184
197
  start(options?: {
185
198
  port?: number;
186
199
  drainTimeoutMs?: number;
@@ -1,4 +1,4 @@
1
- export type KVDriverType = "memory" | "sqlite" | "redis";
1
+ export type KVDriverType = "memory" | "sqlite" | "redis" | "upstash";
2
2
  export interface KVOptions {
3
3
  /** The storage driver to use. Default: "sqlite" */
4
4
  driver?: KVDriverType;
@@ -17,6 +17,13 @@ export interface KVOptions {
17
17
  /** Redis connection URL. Default: "redis://localhost:6379" */
18
18
  url?: string;
19
19
  };
20
+ /** Configuration for the Upstash Redis driver (HTTP-based, serverless) */
21
+ upstash?: {
22
+ /** Upstash Redis REST URL */
23
+ url?: string;
24
+ /** Upstash Redis REST token */
25
+ token?: string;
26
+ };
20
27
  }
21
28
  export interface KVAdapter {
22
29
  get<T>(key: string): Promise<T | null> | T | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cequrebackends/cequre-ts",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "The Cequre Universal Runtime Engine",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -26,6 +26,11 @@
26
26
  "types": "./dist/adapters/node/index.d.ts",
27
27
  "import": "./dist/adapters/node/index.js",
28
28
  "default": "./dist/adapters/node/index.js"
29
+ },
30
+ "./adapters/vercel": {
31
+ "types": "./dist/adapters/vercel/index.d.ts",
32
+ "import": "./dist/adapters/vercel/index.js",
33
+ "default": "./dist/adapters/vercel/index.js"
29
34
  }
30
35
  },
31
36
  "files": [
@@ -40,7 +45,7 @@
40
45
  "url": "https://github.com/cequrebackends/cequre.git"
41
46
  },
42
47
  "scripts": {
43
- "build": "rm -rf dist && bun build ./index.ts ./shared/core/index.ts ./adapters/bun/index.ts ./adapters/node/index.ts --outdir ./dist --target bun --packages external --splitting --format esm && tsc --emitDeclarationOnly"
48
+ "build": "rm -rf dist && bun build ./index.ts ./shared/core/index.ts ./adapters/bun/index.ts ./adapters/node/index.ts ./adapters/vercel/index.ts --outdir ./dist --target bun --packages external --splitting --format esm && tsc --emitDeclarationOnly"
44
49
  },
45
50
  "dependencies": {
46
51
  "@sinclair/typebox": "^0.34.49",