UNPKG

aethercall

Version:

A scalable WebRTC video calling API built with Node.js and OpenVidu

128 lines (106 loc) • 4.26 kB
#!/usr/bin/env node /** * AetherCall Setup Helper * Helps users configure their AetherCall installation */ const { execSync } = require('child_process'); const fs = require('fs'); const path = require('path'); console.log('šŸŽ„ AetherCall Setup Helper\n'); // Check if Docker is available function checkDocker() { try { execSync('docker --version', { stdio: 'ignore' }); return true; } catch { return false; } } // Check if OpenVidu is running function checkOpenVidu() { try { const http = require('http'); const options = { hostname: 'localhost', port: 4443, path: '/dashboard', timeout: 2000 }; return new Promise((resolve) => { const req = http.get(options, (res) => { resolve(res.statusCode === 200); }); req.on('error', () => resolve(false)); req.on('timeout', () => { req.destroy(); resolve(false); }); }); } catch { return false; } } // Check if .env exists function checkEnvFile() { return fs.existsSync('.env'); } async function main() { console.log('Checking system requirements...\n'); // Check Docker const hasDocker = checkDocker(); console.log(`Docker: ${hasDocker ? 'āœ… Available' : 'āŒ Not found'}`); // Check OpenVidu const hasOpenVidu = await checkOpenVidu(); console.log(`OpenVidu: ${hasOpenVidu ? 'āœ… Running on localhost:4443' : 'āŒ Not running'}`); // Check .env file const hasEnv = checkEnvFile(); console.log(`Config file: ${hasEnv ? 'āœ… .env file exists' : 'āŒ .env file missing'}`); console.log('\nšŸ“‹ Setup Instructions:\n'); if (!hasOpenVidu) { console.log('1. Start OpenVidu Server:'); if (hasDocker) { console.log(' Run this command in a separate terminal:'); console.log(' \x1b[33mdocker run -p 4443:4443 --rm -e OPENVIDU_SECRET=MY_SECRET openvidu/openvidu-dev:2.30.0\x1b[0m\n'); } else { console.log(' āŒ Docker is required. Install it first:'); console.log(' šŸ”— https://docs.docker.com/get-docker/\n'); } } else { console.log('1. āœ… OpenVidu is running!\n'); } if (!hasEnv) { console.log('2. Create configuration file:'); console.log(' Copy the example environment file:'); console.log(' \x1b[33mcp .env.example .env\x1b[0m'); console.log(' Then edit .env with your settings\n'); } else { console.log('2. āœ… Configuration file exists!\n'); } console.log('3. Start AetherCall:'); console.log(' \x1b[33mnpm start\x1b[0m\n'); console.log('4. Test the API:'); console.log(' Open \x1b[36mhttp://localhost:3000/examples/video-test.html\x1b[0m in your browser\n'); console.log('šŸ“š For detailed instructions: \x1b[36mhttps://github.com/RayenMiri/AetherCall#readme\x1b[0m'); console.log('šŸ†˜ Need help? Create an issue: \x1b[36mhttps://github.com/RayenMiri/AetherCall/issues\x1b[0m'); // Auto-create .env if user wants if (!hasEnv && fs.existsSync('.env.example')) { console.log('\nā“ Would you like me to create a .env file from .env.example? (y/n)'); process.stdin.setEncoding('utf8'); process.stdin.on('readable', () => { const chunk = process.stdin.read(); if (chunk !== null) { const answer = chunk.trim().toLowerCase(); if (answer === 'y' || answer === 'yes') { try { fs.copyFileSync('.env.example', '.env'); console.log('āœ… Created .env file! Please edit it with your configuration.'); } catch (error) { console.log('āŒ Failed to create .env file:', error.message); } } process.exit(0); } }); } } main().catch(console.error);