mirror of
https://github.com/xtr-dev/rondevu-server.git
synced 2025-12-10 10:53:24 +00:00
- Add version parameter to AppConfig interface - Pass version from environment config instead of using process.env - Update worker.ts to pass VERSION environment variable - Update wrangler.toml with VERSION variable - Update deploy script to automatically set VERSION to git commit hash This fixes the 'process is not defined' error in Cloudflare Workers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
61 lines
1.5 KiB
TypeScript
61 lines
1.5 KiB
TypeScript
import { serve } from '@hono/node-server';
|
|
import { createApp } from './app.ts';
|
|
import { loadConfig } from './config.ts';
|
|
import { SQLiteStorage } from './storage/sqlite.ts';
|
|
import { Storage } from './storage/types.ts';
|
|
|
|
/**
|
|
* Main entry point for the standalone Node.js server
|
|
*/
|
|
async function main() {
|
|
const config = loadConfig();
|
|
|
|
console.log('Starting Rondevu server...');
|
|
console.log('Configuration:', {
|
|
port: config.port,
|
|
storageType: config.storageType,
|
|
storagePath: config.storagePath,
|
|
sessionTimeout: `${config.sessionTimeout}ms`,
|
|
corsOrigins: config.corsOrigins,
|
|
});
|
|
|
|
let storage: Storage;
|
|
|
|
if (config.storageType === 'sqlite') {
|
|
storage = new SQLiteStorage(config.storagePath);
|
|
console.log('Using SQLite storage');
|
|
} else {
|
|
throw new Error('Unsupported storage type');
|
|
}
|
|
|
|
const app = createApp(storage, {
|
|
sessionTimeout: config.sessionTimeout,
|
|
corsOrigins: config.corsOrigins,
|
|
version: process.env.RONDEVU_VERSION || 'unknown',
|
|
});
|
|
|
|
const server = serve({
|
|
fetch: app.fetch,
|
|
port: config.port,
|
|
});
|
|
|
|
console.log(`Server running on http://localhost:${config.port}`);
|
|
|
|
process.on('SIGINT', async () => {
|
|
console.log('\nShutting down gracefully...');
|
|
await storage.close();
|
|
process.exit(0);
|
|
});
|
|
|
|
process.on('SIGTERM', async () => {
|
|
console.log('\nShutting down gracefully...');
|
|
await storage.close();
|
|
process.exit(0);
|
|
});
|
|
}
|
|
|
|
main().catch((err) => {
|
|
console.error('Fatal error:', err);
|
|
process.exit(1);
|
|
});
|