Files
rondevu-server/src/worker.ts
Bas van den Aakster 82c0e8b065 Initial commit: Rondevu signaling server
Open signaling and tracking server for peer discovery in distributed P2P applications.

Features:
- REST API for WebRTC peer discovery and signaling
- Origin-based session isolation
- Multiple storage backends (SQLite, in-memory, Cloudflare KV)
- Docker and Cloudflare Workers deployment support
- Automatic session cleanup and expiration

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-02 14:32:25 +01:00

40 lines
912 B
TypeScript

import { createApp } from './app.ts';
import { KVStorage } from './storage/kv.ts';
/**
* Cloudflare Workers environment bindings
*/
export interface Env {
SESSIONS: KVNamespace;
SESSION_TIMEOUT?: string;
CORS_ORIGINS?: string;
}
/**
* Cloudflare Workers fetch handler
*/
export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
// Initialize KV storage
const storage = new KVStorage(env.SESSIONS);
// Parse configuration
const sessionTimeout = env.SESSION_TIMEOUT
? parseInt(env.SESSION_TIMEOUT, 10)
: 300000; // 5 minutes default
const corsOrigins = env.CORS_ORIGINS
? env.CORS_ORIGINS.split(',').map(o => o.trim())
: ['*'];
// Create Hono app
const app = createApp(storage, {
sessionTimeout,
corsOrigins,
});
// Handle request
return app.fetch(request, env, ctx);
},
};