1c9b531996
Complete the server-backed storage layer for PubScript so the app can run against a real Fastify + SQLite backend instead of only local IndexedDB. Server (@pubscript/server): - db.ts: better-sqlite3 schema + migrations (users, shares, projects, books, chapters, entities, boards, ai_sessions, audit); WAL mode; idempotent admin bootstrap via PUBSCRIPT_ADMIN_EMAIL/PASSWORD. - auth.ts: argon2 hashing, JWT-ish session tokens, guards, auth routes. - routes.ts: REST CRUD for projects/books/chapters/entities/boards/ai_sessions with multi-tenant isolation and optimistic concurrency (baseRev). - ws.ts: Fastify websocket hub for autosave + presence events. - mapping.ts: row <-> core type conversion. Core (@pubscript/core): - Zod domain schemas (projects, books, chapters, entities, boards, ai_sessions) exported from index. - storage-local.ts (IndexedDB/Dexie) and storage-server.ts (REST) adapters implementing the StorageAdapter contract. Tests & tooling: - storage.contract.test.ts: parameterized over both adapters; wired as `pnpm contract` and added to CI. - seed.ts (`pnpm --filter server seed`): creates demo project "The Glass Harbor" — 3 chapters of prose, 4 linked characters, 1 world location, 6-node board. - Dockerfile + compose wiring for the server runtime. Acceptance: seed project opens with 3 chapters, 4 linked characters, 1 board.
37 lines
903 B
JSON
37 lines
903 B
JSON
{
|
|
"name": "@pubscript/server",
|
|
"version": "0.1.0",
|
|
"private": true,
|
|
"type": "module",
|
|
"scripts": {
|
|
"dev": "node --watch --import tsx src/index.ts",
|
|
"start": "node --import tsx src/index.ts",
|
|
"seed": "tsx src/seed.ts",
|
|
"build": "tsc --noEmit",
|
|
"test": "vitest run",
|
|
"lint": "eslint .",
|
|
"typecheck": "tsc --noEmit"
|
|
},
|
|
"dependencies": {
|
|
"@fastify/cookie": "^11.0.1",
|
|
"@fastify/cors": "^11.0.1",
|
|
"@fastify/static": "^8.0.3",
|
|
"@fastify/websocket": "^11.0.1",
|
|
"@pubscript/core": "workspace:*",
|
|
"argon2": "^0.41.1",
|
|
"better-sqlite3": "^11.7.0",
|
|
"fastify": "^5.2.1",
|
|
"tsx": "^4.19.2",
|
|
"ulid": "^2.3.0",
|
|
"ws": "^8.18.0",
|
|
"zod": "^3.24.0"
|
|
},
|
|
"devDependencies": {
|
|
"@types/better-sqlite3": "^7.6.12",
|
|
"@types/node": "^22.10.2",
|
|
"@types/ws": "^8.5.12",
|
|
"typescript": "^5.7.2",
|
|
"vitest": "^2.1.8"
|
|
}
|
|
}
|