Replace KV storage with D1, add peer_id field, simplify README

Storage changes:
- Remove KV storage adapter
- Add D1 storage adapter for Cloudflare Workers
- Update schema to use peer_id instead of info field
- Add database migrations for D1

Documentation:
- Simplify README to be more concise
- Update deployment instructions for D1
- Add D1_SETUP.md explaining migration from KV
- Update DEPLOYMENT.md with D1 setup steps

API changes:
- Replace info field with peerId in session creation
- Update all storage interfaces and implementations

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-07 21:21:13 +01:00
parent d993d6dbfc
commit 02d460fa7e
12 changed files with 512 additions and 497 deletions

View File

@@ -1,11 +1,11 @@
import { createApp } from './app.ts';
import { KVStorage } from './storage/kv.ts';
import { D1Storage } from './storage/d1.ts';
/**
* Cloudflare Workers environment bindings
*/
export interface Env {
SESSIONS: KVNamespace;
DB: D1Database;
SESSION_TIMEOUT?: string;
CORS_ORIGINS?: string;
}
@@ -15,8 +15,8 @@ export interface Env {
*/
export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
// Initialize KV storage
const storage = new KVStorage(env.SESSIONS);
// Initialize D1 storage
const storage = new D1Storage(env.DB);
// Parse configuration
const sessionTimeout = env.SESSION_TIMEOUT