silgi 0.1.0-beta.2 → 0.1.0-beta.4

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "silgi",
3
- "version": "0.1.0-beta.2",
3
+ "version": "0.1.0-beta.4",
4
4
  "private": false,
5
5
  "description": "The fastest end-to-end type-safe RPC framework for TypeScript — compiled pipelines, single package, every runtime",
6
6
  "keywords": [
@@ -84,6 +84,10 @@
84
84
  "import": "./dist/integrations/tanstack-query/index.mjs",
85
85
  "types": "./dist/integrations/tanstack-query/index.d.mts"
86
86
  },
87
+ "./drizzle": {
88
+ "import": "./dist/integrations/drizzle/index.mjs",
89
+ "types": "./dist/integrations/drizzle/index.d.mts"
90
+ },
87
91
  "./plugins": {
88
92
  "import": "./dist/plugins/index.mjs",
89
93
  "types": "./dist/plugins/index.d.mts"
@@ -116,6 +120,10 @@
116
120
  "import": "./dist/integrations/ai/index.mjs",
117
121
  "types": "./dist/integrations/ai/index.d.mts"
118
122
  },
123
+ "./better-auth": {
124
+ "import": "./dist/integrations/better-auth/index.mjs",
125
+ "types": "./dist/integrations/better-auth/index.d.mts"
126
+ },
119
127
  "./fastify": {
120
128
  "import": "./dist/adapters/fastify.mjs",
121
129
  "types": "./dist/adapters/fastify.d.mts"
@@ -144,10 +152,6 @@
144
152
  "import": "./dist/adapters/aws-lambda.mjs",
145
153
  "types": "./dist/adapters/aws-lambda.d.mts"
146
154
  },
147
- "./elysia": {
148
- "import": "./dist/adapters/elysia.mjs",
149
- "types": "./dist/adapters/elysia.d.mts"
150
- },
151
155
  "./nextjs": {
152
156
  "import": "./dist/adapters/nextjs.mjs",
153
157
  "types": "./dist/adapters/nextjs.d.mts"
@@ -227,7 +231,7 @@
227
231
  "dev": "vitest",
228
232
  "bench": "node --experimental-strip-types bench/update-benchmarks.ts",
229
233
  "bench:memory": "node --expose-gc --experimental-strip-types bench/memory.ts",
230
- "bench:elysia": "bun bench/elysia.ts",
234
+
231
235
  "bench:bun": "bun test/bun-compat.ts",
232
236
  "play": "pnpm build && pnpm --filter silgi-playground dev",
233
237
  "lint": "oxlint . && oxfmt --check .",
@@ -266,7 +270,7 @@
266
270
  "@types/ws": "^8.18.1",
267
271
  "@typescript/native-preview": "7.0.0-dev.20260316.1",
268
272
  "ai": "^6.0.134",
269
- "elysia": "^1.4.28",
273
+
270
274
  "express": "^5.2.1",
271
275
  "fastify": "^5.8.2",
272
276
  "h3": "2.0.1-rc.16",
@@ -1,17 +0,0 @@
1
- import { RouterDef } from "../types.mjs";
2
-
3
- //#region src/adapters/elysia.d.ts
4
- interface ElysiaAdapterOptions<TCtx extends Record<string, unknown>> {
5
- /** Context factory — receives the Elysia context */
6
- context?: (ctx: any) => TCtx | Promise<TCtx>;
7
- /** Route prefix. Default: "/rpc" */
8
- prefix?: string;
9
- }
10
- /**
11
- * Create an Elysia plugin that routes to Silgi procedures.
12
- *
13
- * Returns a function that can be passed to `app.use()`.
14
- */
15
- declare function silgiElysia<TCtx extends Record<string, unknown>>(router: RouterDef, options?: ElysiaAdapterOptions<TCtx>): (app: any) => any;
16
- //#endregion
17
- export { ElysiaAdapterOptions, silgiElysia };
@@ -1,76 +0,0 @@
1
- import { SilgiError, toSilgiError } from "../core/error.mjs";
2
- import { ValidationError } from "../core/schema.mjs";
3
- import { compileRouter } from "../compile.mjs";
4
- //#region src/adapters/elysia.ts
5
- /**
6
- * Elysia adapter — use Silgi with Elysia on Bun.
7
- *
8
- * @example
9
- * ```ts
10
- * import { Elysia } from "elysia"
11
- * import { silgiElysia } from "silgi/elysia"
12
- *
13
- * const app = new Elysia()
14
- * .use(silgiElysia(appRouter, { prefix: "/rpc" }))
15
- * .listen(3000)
16
- * ```
17
- */
18
- /**
19
- * Create an Elysia plugin that routes to Silgi procedures.
20
- *
21
- * Returns a function that can be passed to `app.use()`.
22
- */
23
- function silgiElysia(router, options = {}) {
24
- const flatRouter = compileRouter(router);
25
- const prefix = options.prefix ?? "/rpc";
26
- return (app) => {
27
- app.all(`${prefix}/*`, async (elysiaCtx) => {
28
- let pathname = new URL(elysiaCtx.request.url).pathname;
29
- if (pathname.startsWith(prefix)) pathname = pathname.slice(prefix.length);
30
- if (pathname.startsWith("/")) pathname = pathname.slice(1);
31
- const match = flatRouter(elysiaCtx.request.method, "/" + pathname);
32
- if (!match) {
33
- elysiaCtx.set.status = 404;
34
- return {
35
- code: "NOT_FOUND",
36
- status: 404,
37
- message: "Procedure not found"
38
- };
39
- }
40
- const route = match.data;
41
- try {
42
- const ctx = Object.create(null);
43
- if (match.params) ctx.params = match.params;
44
- if (options.context) {
45
- const baseCtx = await options.context(elysiaCtx);
46
- const keys = Object.keys(baseCtx);
47
- for (let i = 0; i < keys.length; i++) ctx[keys[i]] = baseCtx[keys[i]];
48
- }
49
- let input;
50
- if (elysiaCtx.request.method === "POST" || elysiaCtx.request.method === "PUT") input = elysiaCtx.body;
51
- else {
52
- const data = elysiaCtx.query?.data;
53
- if (data) input = typeof data === "string" ? JSON.parse(data) : data;
54
- }
55
- const signal = elysiaCtx.request.signal ?? new AbortController().signal;
56
- return await route.handler(ctx, input, signal);
57
- } catch (error) {
58
- if (error instanceof ValidationError) {
59
- elysiaCtx.set.status = 400;
60
- return {
61
- code: "BAD_REQUEST",
62
- status: 400,
63
- message: error.message,
64
- data: { issues: error.issues }
65
- };
66
- }
67
- const e = error instanceof SilgiError ? error : toSilgiError(error);
68
- elysiaCtx.set.status = e.status;
69
- return e.toJSON();
70
- }
71
- });
72
- return app;
73
- };
74
- }
75
- //#endregion
76
- export { silgiElysia };