Skip to content

Commit 617d8ca

Browse files
Copilothotlong
andcommitted
feat(studio): switch Vercel serverless API from InMemoryDriver to TursoDriver
Replace @objectstack/driver-memory with @objectstack/driver-turso in the Studio Vercel API entrypoint (apps/studio/api/index.ts). On Vercel, the driver connects to Turso cloud via TURSO_DATABASE_URL and TURSO_AUTH_TOKEN env vars (remote mode). Falls back to :memory: for local dev. Revert incorrect app-host changes from previous commits. The browser MSW mock kernel (createKernel.ts) remains unchanged — InMemoryDriver is the correct choice for browser dev mode. Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com> Agent-Logs-Url: https://github.com/objectstack-ai/spec/sessions/85c7bfe8-af37-430d-b5dd-b974be65ad32
1 parent 392522e commit 617d8ca

9 files changed

Lines changed: 29 additions & 27 deletions

File tree

CHANGELOG.md

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

1010
### 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.
11+
- **Studio Vercel deployment — switched from InMemoryDriver to TursoDriver** — The Studio serverless
12+
API entrypoint (`apps/studio/api/index.ts`) now uses `@objectstack/driver-turso` (TursoDriver)
13+
instead of `@objectstack/driver-memory` (InMemoryDriver) for Vercel deployments. In production,
14+
the driver connects to a Turso cloud database via `TURSO_DATABASE_URL` and `TURSO_AUTH_TOKEN`
15+
environment variables (remote mode). For local development without those variables, it falls back
16+
to `:memory:` (ephemeral SQLite). This ensures data persistence across serverless function
17+
invocations on Vercel. The browser MSW mock kernel remains unchanged (InMemoryDriver).
1718

1819
### Added
1920
- **`@objectstack/driver-turso` — dual transport architecture** — TursoDriver now supports three

apps/studio/api/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
import { ObjectKernel, DriverPlugin, AppPlugin } from '@objectstack/runtime';
2929
import { ObjectQLPlugin } from '@objectstack/objectql';
30-
import { InMemoryDriver } from '@objectstack/driver-memory';
30+
import { TursoDriver } from '@objectstack/driver-turso';
3131
import { createHonoApp } from '@objectstack/hono';
3232
import { AuthPlugin } from '@objectstack/plugin-auth';
3333
import { SecurityPlugin } from '@objectstack/plugin-security';
@@ -70,7 +70,10 @@ async function ensureKernel(): Promise<ObjectKernel> {
7070
const kernel = new ObjectKernel();
7171

7272
await kernel.use(new ObjectQLPlugin());
73-
await kernel.use(new DriverPlugin(new InMemoryDriver(), 'memory'));
73+
await kernel.use(new DriverPlugin(new TursoDriver({
74+
url: process.env.TURSO_DATABASE_URL ?? ':memory:',
75+
...(process.env.TURSO_AUTH_TOKEN && { authToken: process.env.TURSO_AUTH_TOKEN }),
76+
}), 'turso'));
7477
await kernel.use(new AppPlugin(studioConfig));
7578

7679
// Auth plugin — uses better-auth for real authentication

apps/studio/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"@objectstack/client": "workspace:*",
2121
"@objectstack/client-react": "workspace:*",
2222
"@objectstack/driver-memory": "workspace:*",
23+
"@objectstack/driver-turso": "workspace:*",
2324
"@objectstack/hono": "workspace:*",
2425
"@objectstack/metadata": "workspace:*",
2526
"@objectstack/objectql": "workspace:*",

apps/studio/vercel.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"build": {
88
"env": {
99
"VITE_RUNTIME_MODE": "server",
10-
"VITE_SERVER_URL": ""
10+
"VITE_SERVER_URL": "",
11+
"TURSO_DATABASE_URL": "@turso_database_url",
12+
"TURSO_AUTH_TOKEN": "@turso_auth_token"
1113
}
1214
},
1315
"rewrites": [

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 { TursoDriver } from '@objectstack/driver-turso';
6+
import { InMemoryDriver } from '@objectstack/driver-memory';
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 TursoDriver({ url: ':memory:' }), 'turso'))
19+
.use(new DriverPlugin(new InMemoryDriver(), 'memory'))
2020
.use(new AppPlugin(TodoApp));
2121

2222
await kernel.bootstrap();

examples/app-host/objectstack.config.ts

Lines changed: 4 additions & 10 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 { TursoDriver } from '@objectstack/driver-turso';
6+
import { InMemoryDriver } from '@objectstack/driver-memory';
77
import { AuthPlugin } from '@objectstack/plugin-auth';
88
import CrmApp from '../app-crm/objectstack.config';
99
import TodoApp from '../app-todo/objectstack.config';
@@ -35,11 +35,8 @@ export default defineStack({
3535
// The Runtime CLI will iterate this list and call kernel.use()
3636
plugins: [
3737
new ObjectQLPlugin(),
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-
...(process.env.TURSO_AUTH_TOKEN && { authToken: process.env.TURSO_AUTH_TOKEN }),
42-
})),
38+
// Register Default Driver (Memory)
39+
new DriverPlugin(new InMemoryDriver()),
4340
// Authentication — required for production (Vercel) deployments
4441
authPlugin,
4542
// Wrap Manifests/Stacks in AppPlugin adapter
@@ -104,10 +101,7 @@ export const PreviewHostExample = defineStack({
104101
// Same plugins as the standard host
105102
plugins: [
106103
new ObjectQLPlugin(),
107-
new DriverPlugin(new TursoDriver({
108-
url: process.env.TURSO_DATABASE_URL ?? ':memory:',
109-
...(process.env.TURSO_AUTH_TOKEN && { authToken: process.env.TURSO_AUTH_TOKEN }),
110-
})),
104+
new DriverPlugin(new InMemoryDriver()),
111105
authPlugin,
112106
new AppPlugin(CrmApp),
113107
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-turso": "workspace:*",
16+
"@objectstack/driver-memory": "workspace:*",
1717
"@example/app-crm": "workspace:*",
1818
"@example/app-todo": "workspace:*",
1919
"@objectstack/metadata": "workspace:*",

examples/app-host/vercel.json

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

pnpm-lock.yaml

Lines changed: 5 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)