http.targets.psm1

function Start-Target {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory)]
        [string]$Name,

        [int]$Port = 8080
    )

    $targetPath = Join-Path $PSScriptRoot "pages\$Name"
    Write-Host "DEBUG root path: $targetPath"
    if (-not (Test-Path $targetPath)) {
        throw "❌ Target '$Name' not found in: $targetPath"
    }

    if (-not (Get-Command Start-HttpServer -ErrorAction SilentlyContinue)) {
        throw "❌ 'http.server' module is required. Run: Install-Module http.server"
    }

    Start-HttpServer -Port $Port -Root $targetPath
}