@echo off
title Class Generator - Development Server

echo.
echo 🚀 Starting Class Generator Development Server...
echo.

:: Check if Node.js is installed
node --version >nul 2>&1
if %errorlevel% neq 0 (
    echo ❌ Node.js is not installed or not in PATH
    echo Please install Node.js from https://nodejs.org/
    pause
    exit /b 1
)

:: Kill any existing servers first
echo 🧹 Cleaning up existing servers...
taskkill /f /im node.exe >nul 2>&1
taskkill /F /IM caddy.exe >nul 2>&1

:: Start the server
echo ✅ Node.js found
echo 🔄 Starting server on port 8080...
echo 📡 Server will be available at: http://localhost:8080
echo 🧪 DRS Tests available at: http://localhost:8080/test-drs-interface.html
echo 🌐 ES6 modules support: ✅
echo 🔗 CORS enabled: ✅
echo 🔌 API endpoints: ✅
echo ⏳ Waiting for system initialization...
echo.

timeout /t 3 /nobreak >nul

:: Start browser
start msedge "http://localhost:8080"

:: Start Node.js server
node server.js

:: If we get here, the server stopped
echo.
echo 👋 Server stopped
pause