Skip to content

Commit 3c8f7c8

Browse files
Claudehotlong
andauthored
Changes before error encountered
Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/9f82a7b9-1e72-4933-9f6a-3dfebc52f516 Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 72d34af commit 3c8f7c8

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

apps/server/objectstack.config.ts

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { defineStack } from '@objectstack/spec';
44
import { AppPlugin, DriverPlugin } from '@objectstack/runtime';
55
import { ObjectQLPlugin } from '@objectstack/objectql';
66
import { InMemoryDriver } from '@objectstack/driver-memory';
7+
import { TursoDriver } from '@objectstack/driver-turso';
78
import { AuthPlugin } from '@objectstack/plugin-auth';
89
import CrmApp from '../../examples/app-crm/objectstack.config';
910
import TodoApp from '../../examples/app-todo/objectstack.config';
@@ -31,13 +32,34 @@ export default defineStack({
3132
description: 'Production server aggregating CRM, Todo and BI plugins',
3233
type: 'app',
3334
},
34-
35+
36+
// Datasource Mapping Configuration
37+
// Routes different namespaces to different datasources for optimal performance
38+
datasourceMapping: [
39+
// Example apps use in-memory driver for fast, ephemeral data
40+
{ namespace: 'crm', datasource: 'memory' },
41+
{ namespace: 'todo', datasource: 'memory' },
42+
{ namespace: 'bi', datasource: 'memory' },
43+
// System objects use Turso for persistent, production-grade storage
44+
{ namespace: 'sys', datasource: 'turso' },
45+
// Default fallback to memory driver
46+
{ default: true, datasource: 'memory' },
47+
],
48+
3549
// Explicitly Load Plugins and Apps
3650
// The Runtime CLI will iterate this list and call kernel.use()
3751
plugins: [
3852
new ObjectQLPlugin(),
39-
// Register Default Driver (Memory)
40-
new DriverPlugin(new InMemoryDriver()),
53+
// Register Memory Driver for example apps (volatile, fast)
54+
new DriverPlugin(new InMemoryDriver(), { name: 'memory' }),
55+
// Register Turso Driver for system objects (persistent, production)
56+
new DriverPlugin(
57+
new TursoDriver({
58+
url: process.env.TURSO_DATABASE_URL ?? 'file:./data/server.db',
59+
authToken: process.env.TURSO_AUTH_TOKEN,
60+
}),
61+
{ name: 'turso' }
62+
),
4163
// Authentication — required for production (Vercel) deployments
4264
authPlugin,
4365
// Wrap Manifests/Stacks in AppPlugin adapter
@@ -100,10 +122,26 @@ export const PreviewHostExample = defineStack({
100122
type: 'app',
101123
},
102124

125+
// Same datasource mapping as standard server
126+
datasourceMapping: [
127+
{ namespace: 'crm', datasource: 'memory' },
128+
{ namespace: 'todo', datasource: 'memory' },
129+
{ namespace: 'bi', datasource: 'memory' },
130+
{ namespace: 'sys', datasource: 'turso' },
131+
{ default: true, datasource: 'memory' },
132+
],
133+
103134
// Same plugins as the standard host
104135
plugins: [
105136
new ObjectQLPlugin(),
106-
new DriverPlugin(new InMemoryDriver()),
137+
new DriverPlugin(new InMemoryDriver(), { name: 'memory' }),
138+
new DriverPlugin(
139+
new TursoDriver({
140+
url: process.env.TURSO_DATABASE_URL ?? 'file:./data/server.db',
141+
authToken: process.env.TURSO_AUTH_TOKEN,
142+
}),
143+
{ name: 'turso' }
144+
),
107145
authPlugin,
108146
new AppPlugin(CrmApp),
109147
new AppPlugin(TodoApp),

0 commit comments

Comments
 (0)