@echo off
REM Quick start script for SAMI-CLOUD API Server (Windows)

echo ====================================
echo SAMI-CLOUD API Server
echo ====================================
echo.

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

REM Check if node_modules exists
if not exist "node_modules" (
    echo Installing dependencies...
    call npm install
    echo.
)

REM Check environment variables
if "%CADDY_ADMIN_API%"=="" (
    echo Warning: CADDY_ADMIN_API not set, using default: http://localhost:2019
    set CADDY_ADMIN_API=http://localhost:2019
)

if "%DNS_SERVER_API%"=="" (
    echo Warning: DNS_SERVER_API not set, using default: http://192.168.254.204:5380
    set DNS_SERVER_API=http://192.168.254.204:5380
)

if "%TECHNITIUM_API_TOKEN%"=="" (
    echo Warning: TECHNITIUM_API_TOKEN not set - DNS operations will fail
    echo Set it with: set TECHNITIUM_API_TOKEN=your_token
    echo.
)

echo Starting API server...
echo.
node caddy-api.js
