param( [int]$Port = 8080 ) $ErrorActionPreference = "Stop" $root = Split-Path -Parent $PSScriptRoot Set-Location $root Write-Host "Building frontend and API..." -ForegroundColor Cyan npm run build:all if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } $env:NODE_ENV = "production" $env:PORT = "$Port" Write-Host "Starting production server on port $Port ..." -ForegroundColor Cyan Write-Host "Open http://127.0.0.1:$Port" -ForegroundColor Green Set-Location (Join-Path $root "server") node dist/index.js