@@ -4,6 +4,7 @@ import { defineStack } from '@objectstack/spec';
44import { AppPlugin , DriverPlugin } from '@objectstack/runtime' ;
55import { ObjectQLPlugin } from '@objectstack/objectql' ;
66import { InMemoryDriver } from '@objectstack/driver-memory' ;
7+ import { TursoDriver } from '@objectstack/driver-turso' ;
78import { AuthPlugin } from '@objectstack/plugin-auth' ;
89import CrmApp from '../../examples/app-crm/objectstack.config' ;
910import 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