@teamscala/service-boot 0.23.469 → 0.23.471

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
@@ -6,7 +6,7 @@
6
6
  },
7
7
  "name": "@teamscala/service-boot",
8
8
  "type": "module",
9
- "version": "0.23.469",
9
+ "version": "0.23.471",
10
10
  "sideEffects": false,
11
11
  "imports": {
12
12
  "#service-boot/*": "./src/*",
@@ -11,7 +11,6 @@
11
11
 
12
12
  import { join } from "node:path";
13
13
  import { getAppLogger } from "@teamscala/logger/app-loggers";
14
- import { registerFnRouters } from "./fn-routers/index.ts";
15
14
  import type { InjectedDb8 } from "@teamscala/db/db8-registry";
16
15
  import type { Hono } from "hono";
17
16
  import { bodyLimit } from "hono/body-limit";
@@ -30,13 +29,47 @@ export async function mountOrpcRouter(
30
29
  serviceSlug: string,
31
30
  ): Promise<OrpcMountResult | null> {
32
31
  const log = getAppLogger();
33
- registerFnRouters();
32
+ // registerFnRouters() is retired: the row-composed bundle (orpc-bundle from
33
+ // api_route rows) is the sole fn source. The handwritten registration is
34
+ // fully shadowed by generated.fn (all families have rows) — keeping it
35
+ // would block generated-only procedures (auth, cacheAdmin, regions,
36
+ // realtime) from serving.
34
37
  const routerPath = join(
35
38
  process.cwd(),
36
39
  "prisma/generated/orpc/routers/index.ts",
37
40
  );
38
41
  const schemaPath = join(process.cwd(), "prisma/schema.prisma");
39
42
 
43
+ // ORPC forward mode: when SCALA_ORPC_FORWARD_URL is set and there is no
44
+ // local bundle, /api/rpc/* proxies to the central ORPC surface instead of
45
+ // mounting a per-service router. This is the collapse's consolidation path —
46
+ // services shed their local bundle and the central surface serves all
47
+ // row-composed procedures.
48
+ const forwardUrl = process.env.SCALA_ORPC_FORWARD_URL;
49
+ if (!await Bun.file(routerPath).exists() && forwardUrl) {
50
+ const base = forwardUrl.replace(/\/+$/, "");
51
+ app.all("/api/rpc/*", async (c) => {
52
+ const url = new URL(c.req.url);
53
+ const target = `${base}${url.pathname}${url.search}`;
54
+ const res = await fetch(target, {
55
+ method: c.req.method,
56
+ headers: c.req.raw.headers,
57
+ body: c.req.raw.body,
58
+ // @ts-ignore — duplex is required for streaming bodies in Bun
59
+ duplex: "half",
60
+ });
61
+ return new Response(res.body, {
62
+ status: res.status,
63
+ statusText: res.statusText,
64
+ headers: res.headers,
65
+ });
66
+ });
67
+ log.info(
68
+ `[scala-install:${serviceSlug}] ORPC forward mounted at /api/rpc/* → ${base}`,
69
+ );
70
+ return { routeCount: 0 };
71
+ }
72
+
40
73
  // No generated ORPC router is the EXPECTED state for daemon-only / boot-hook
41
74
  // services (session-picker, dep-sync, etc.) that own no DB schema or
42
75
  // api_routes — they serve no /api/rpc surface. Skip silently: importing a