mirror of
https://github.com/xtr-dev/rondevu-server.git
synced 2025-12-10 10:53:24 +00:00
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>
40 lines
912 B
TypeScript
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);
|
|
},
|
|
};
|