Skip to content

Commit 5b47ea9

Browse files
Copilothotlong
andcommitted
feat(app-host): switch Vercel deployment from InMemoryDriver to TursoDriver
Replace @objectstack/driver-memory with @objectstack/driver-turso in the app-host example. On Vercel, the driver connects to Turso cloud via TURSO_DATABASE_URL and TURSO_AUTH_TOKEN env vars (remote mode). For local development without those variables, it falls back to :memory: (ephemeral SQLite). Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com> Agent-Logs-Url: https://github.com/objectstack-ai/spec/sessions/1190de98-61cc-419b-b502-b9728e8e3db8
1 parent 1968935 commit 5b47ea9

6 files changed

Lines changed: 26 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
- **Vercel deployment — switched from InMemoryDriver to TursoDriver** — The `app-host` example now
12+
uses `@objectstack/driver-turso` (TursoDriver) instead of `@objectstack/driver-memory`
13+
(InMemoryDriver) for Vercel deployments. In production, the driver connects to a Turso cloud
14+
database via `TURSO_DATABASE_URL` and `TURSO_AUTH_TOKEN` environment variables (remote mode).
15+
For local development without those variables, it falls back to `:memory:` (ephemeral SQLite).
16+
This ensures data persistence across serverless function invocations on Vercel.
17+
1018
### Added
1119
- **`@objectstack/driver-turso` — dual transport architecture** — TursoDriver now supports three
1220
transport modes: `local`, `replica`, and `remote`. Remote mode (`url: 'libsql://...'`) enables

examples/app-host/debug-registry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import { ObjectKernel, DriverPlugin, AppPlugin } from '@objectstack/runtime';
55
import { SchemaRegistry, ObjectQL, ObjectQLPlugin } from '@objectstack/objectql';
6-
import { InMemoryDriver } from '@objectstack/driver-memory';
6+
import { TursoDriver } from '@objectstack/driver-turso';
77

88
import TodoApp from '@example/app-todo/objectstack.config';
99

@@ -16,7 +16,7 @@ import TodoApp from '@example/app-todo/objectstack.config';
1616

1717
kernel
1818
.use(new ObjectQLPlugin())
19-
.use(new DriverPlugin(new InMemoryDriver(), 'memory'))
19+
.use(new DriverPlugin(new TursoDriver({ url: ':memory:' }), 'turso'))
2020
.use(new AppPlugin(TodoApp));
2121

2222
await kernel.bootstrap();

examples/app-host/objectstack.config.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { defineStack } from '@objectstack/spec';
44
import { AppPlugin, DriverPlugin } from '@objectstack/runtime';
55
import { ObjectQLPlugin } from '@objectstack/objectql';
6-
import { InMemoryDriver } from '@objectstack/driver-memory';
6+
import { TursoDriver } from '@objectstack/driver-turso';
77
import { AuthPlugin } from '@objectstack/plugin-auth';
88
import CrmApp from '../app-crm/objectstack.config';
99
import TodoApp from '../app-todo/objectstack.config';
@@ -35,8 +35,11 @@ export default defineStack({
3535
// The Runtime CLI will iterate this list and call kernel.use()
3636
plugins: [
3737
new ObjectQLPlugin(),
38-
// Register Default Driver (Memory)
39-
new DriverPlugin(new InMemoryDriver()),
38+
// Register Default Driver (Turso — remote mode on Vercel, in-memory for local dev)
39+
new DriverPlugin(new TursoDriver({
40+
url: process.env.TURSO_DATABASE_URL ?? ':memory:',
41+
authToken: process.env.TURSO_AUTH_TOKEN,
42+
})),
4043
// Authentication — required for production (Vercel) deployments
4144
authPlugin,
4245
// Wrap Manifests/Stacks in AppPlugin adapter
@@ -101,7 +104,10 @@ export const PreviewHostExample = defineStack({
101104
// Same plugins as the standard host
102105
plugins: [
103106
new ObjectQLPlugin(),
104-
new DriverPlugin(new InMemoryDriver()),
107+
new DriverPlugin(new TursoDriver({
108+
url: process.env.TURSO_DATABASE_URL ?? ':memory:',
109+
authToken: process.env.TURSO_AUTH_TOKEN,
110+
})),
105111
authPlugin,
106112
new AppPlugin(CrmApp),
107113
new AppPlugin(TodoApp),

examples/app-host/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"clean": "rm -rf dist node_modules"
1414
},
1515
"dependencies": {
16-
"@objectstack/driver-memory": "workspace:*",
16+
"@objectstack/driver-turso": "workspace:*",
1717
"@example/app-crm": "workspace:*",
1818
"@example/app-todo": "workspace:*",
1919
"@objectstack/metadata": "workspace:*",

examples/app-host/vercel.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"outputDirectory": "dist",
66
"env": {
77
"AUTH_SECRET": "@auth_secret",
8-
"VERCEL_URL": "@vercel_url"
8+
"VERCEL_URL": "@vercel_url",
9+
"TURSO_DATABASE_URL": "@turso_database_url",
10+
"TURSO_AUTH_TOKEN": "@turso_auth_token"
911
}
1012
}

pnpm-lock.yaml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)