Skip to content

Commit cce964d

Browse files
fix: move datasource mapping after bootstrap() to resolve 'objectql' not found
Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/a1cc1f6c-d9ba-459d-b0cb-fb6ba8dace02 Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
1 parent 434139f commit cce964d

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

apps/server/server/index.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,6 @@ async function ensureKernel(): Promise<ObjectKernel> {
8383

8484
await kernel.use(new DriverPlugin(tursoDriver, 'turso'));
8585

86-
// Configure datasource mapping: sys namespace → Turso, everything else → Memory
87-
const ql = await kernel.getServiceAsync<ObjectQL>('objectql');
88-
if (ql && typeof ql.setDatasourceMapping === 'function') {
89-
ql.setDatasourceMapping([
90-
// System objects (sys namespace) use Turso for persistent storage
91-
{ namespace: 'sys', datasource: 'turso' },
92-
// All other objects use Memory driver as default
93-
{ default: true, datasource: 'memory' },
94-
]);
95-
console.log('[Vercel] Datasource mapping configured: sys → turso, default → memory');
96-
}
97-
9886
// Load app manifests (BEFORE plugins that need object schemas)
9987
await kernel.use(new AppPlugin(CrmApp));
10088
await kernel.use(new AppPlugin(TodoApp));
@@ -129,6 +117,18 @@ async function ensureKernel(): Promise<ObjectKernel> {
129117

130118
await kernel.bootstrap();
131119

120+
// Configure datasource mapping AFTER bootstrap (ObjectQL service is registered during init)
121+
const ql = await kernel.getServiceAsync<ObjectQL>('objectql');
122+
if (ql && typeof ql.setDatasourceMapping === 'function') {
123+
ql.setDatasourceMapping([
124+
// System objects (sys namespace) use Turso for persistent storage
125+
{ namespace: 'sys', datasource: 'turso' },
126+
// All other objects use Memory driver as default
127+
{ default: true, datasource: 'memory' },
128+
]);
129+
console.log('[Vercel] Datasource mapping configured: sys → turso, default → memory');
130+
}
131+
132132
_kernel = kernel;
133133
console.log('[Vercel] Kernel ready.');
134134
return kernel;

0 commit comments

Comments
 (0)