From 03af9b8cc2bb68102d2d18ace4a80eb507345caa Mon Sep 17 00:00:00 2001 From: Clement Denis Date: Tue, 5 May 2026 16:08:18 +0200 Subject: [PATCH] fix(router): move db global import to the router scope --- api/deno.json | 2 +- api/router.ts | 7 +++---- signal-router/deno.json | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/api/deno.json b/api/deno.json index e14e6ba..b4790ff 100644 --- a/api/deno.json +++ b/api/deno.json @@ -4,7 +4,7 @@ "@std/http": "jsr:@std/http@^1.0.25" }, "name": "@01edu/api", - "version": "0.2.6", + "version": "0.2.7", "license": "MIT", "exports": { "./context": "./context.ts", diff --git a/api/router.ts b/api/router.ts index a92038e..46100cb 100644 --- a/api/router.ts +++ b/api/router.ts @@ -40,10 +40,6 @@ export type RouterOptions = { metrics?: Metric[] } -const db = (globalThis as unknown as { - ['@01edu/db']: Database | undefined -})['@01edu/db'] - /** * A declaration function for creating a route handler. * This is primarily used for type inference and doesn't have any runtime logic. @@ -128,6 +124,9 @@ export const makeRouter = ( ): (ctx: RequestContext) => Awaitable => { const routeMaps: Record = Object.create(null) + const db = (globalThis as unknown as { + ['@01edu/db']: Database | undefined + })['@01edu/db'] if (db) { if (!defs['POST/api/sql/execute']) { defs['POST/api/sql/execute'] = createSqlDevRoute(db) diff --git a/signal-router/deno.json b/signal-router/deno.json index e46ae5b..1efcf12 100644 --- a/signal-router/deno.json +++ b/signal-router/deno.json @@ -1,10 +1,10 @@ { "imports": { "@preact/signals": "npm:@preact/signals@^2.9.0", - "preact": "npm:preact@^10.29.0" + "preact": "npm:preact@^10.29.1" }, "name": "@01edu/signal-router", - "version": "0.2.2", + "version": "0.2.3", "license": "MIT", "exports": { ".": "./mod.tsx" }, "compilerOptions": {