aethercall
Version:
A scalable WebRTC video calling API built with Node.js and OpenVidu
128 lines (106 loc) ⢠4.26 kB
JavaScript
/**
* 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);