@echo off
echo ========================================
echo FORCE RESTART Backend Server
echo ========================================
echo.

cd /d "%~dp0"

echo Step 1: Killing ALL node processes...
taskkill /F /IM node.exe 2>nul
timeout /t 3 /nobreak >nul

echo.
echo Step 2: Cleaning dist folder...
if exist dist rmdir /s /q dist

echo.
echo Step 3: Building backend...
call npm run build
if errorlevel 1 (
    echo.
    echo ========================================
    echo BUILD FAILED!
    echo ========================================
    pause
    exit /b 1
)

echo.
echo Step 4: Starting backend server on port 83...
echo.
echo ========================================
echo Backend Server Starting...
echo ========================================
echo Backend URL: http://localhost:83
echo Health Check: http://localhost:83/api/health
echo.
echo Press Ctrl+C to stop the server
echo ========================================
echo.

set PORT=83
call npm start

pause

