@teamscala/service-boot 0.23.438 → 0.23.439
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 +1 -1
- package/src/mount-orpc-router.ts +25 -1
package/package.json
CHANGED
package/src/mount-orpc-router.ts
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import { join } from "node:path";
|
|
13
13
|
import { getAppLogger } from "@teamscala/logger/app-loggers";
|
|
14
14
|
import { registerFnRouters } from "./fn-routers/index.ts";
|
|
15
|
+
import type { InjectedDb8 } from "@teamscala/orpc/configure";
|
|
15
16
|
import type { Hono } from "hono";
|
|
16
17
|
import { bodyLimit } from "hono/body-limit";
|
|
17
18
|
|
|
@@ -70,6 +71,29 @@ export async function mountOrpcRouter(
|
|
|
70
71
|
"@teamscala/orpc/configure"
|
|
71
72
|
);
|
|
72
73
|
|
|
74
|
+
// Coexistence (Prisma 8 migration): create the v8 chained client when
|
|
75
|
+
// the shared platform contract ships inside @teamscala/db. Absence is
|
|
76
|
+
// the EXPECTED state for services that have not migrated — db8 stays
|
|
77
|
+
// undefined and v7 procedures are untouched. One boot-time creation,
|
|
78
|
+
// closed over by the request handler (connects lazily on first query).
|
|
79
|
+
let db8: InjectedDb8 | undefined;
|
|
80
|
+
try {
|
|
81
|
+
if (process.env.DATABASE_URL) {
|
|
82
|
+
const { createDbClientV8 } = await import(
|
|
83
|
+
"@teamscala/db/create-db-client-v8"
|
|
84
|
+
);
|
|
85
|
+
db8 = (await createDbClientV8({
|
|
86
|
+
connectionString: process.env.DATABASE_URL,
|
|
87
|
+
serviceName: serviceSlug,
|
|
88
|
+
})) as never;
|
|
89
|
+
}
|
|
90
|
+
} catch (err) {
|
|
91
|
+
log.info(
|
|
92
|
+
`[scala-install:${serviceSlug}] db8 (Prisma 8 chained client) unavailable: ${err instanceof Error ? err.message : err} — serving v7 procedures only`,
|
|
93
|
+
);
|
|
94
|
+
db8 = undefined;
|
|
95
|
+
}
|
|
96
|
+
|
|
73
97
|
// Bridge the composed router into tool-executor so in-process tool
|
|
74
98
|
// dispatch (chat agents' work_items/meetings/agreements/proposals
|
|
75
99
|
// tools, etc.) resolves against this service's ORPC router + Prisma
|
|
@@ -160,7 +184,7 @@ export async function mountOrpcRouter(
|
|
|
160
184
|
const prisma = getConfiguredPrisma();
|
|
161
185
|
const result = await handler.handle(c.req.raw, {
|
|
162
186
|
prefix: "/api/rpc",
|
|
163
|
-
context: { prisma, headers: c.req.raw.headers, resolveUser },
|
|
187
|
+
context: { prisma, db8, headers: c.req.raw.headers, resolveUser },
|
|
164
188
|
});
|
|
165
189
|
if (!result?.matched) return c.notFound();
|
|
166
190
|
return result.response;
|