mirror of
https://github.com/xtr-dev/rondevu-server.git
synced 2025-12-10 19:03:24 +00:00
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>
This commit is contained in:
39
src/worker.ts
Normal file
39
src/worker.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
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);
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user