update_settings(max_parallel_updates=4)

load('ext://dotenv', 'dotenv')
dotenv()                    # defaults to .env in the current directory

local_resource(
    "server",
    cmd="npm ci --no-audit --no-fund",
    deps=[
        "server/package.json",
        "server/package-lock.json",
    ],
    serve_cmd="sh -c 'node scripts/ensure-prisma-client.mjs && exec node ./node_modules/tsx/dist/cli.mjs watch src/index.ts'",
    readiness_probe=probe(
        period_secs=2,
        timeout_secs=1,
        http_get=http_get_action(port=8787, path="/health"),
    ),
    links=[
        "http://localhost:8787/docs",
    ],
    dir="server",
    serve_dir="server",
    allow_parallel=True,
)

local_resource(
    "web",
    cmd="npm ci --no-audit --no-fund",
    serve_cmd="node ./node_modules/vite/bin/vite.js",
    deps=[
        "web/package.json",
        "web/package-lock.json",
    ],
    dir="web",
    serve_dir="web",
    readiness_probe=probe(
        period_secs=2,
        timeout_secs=1,
        http_get=http_get_action(port=5173, path="/"),
    ),
    links=[
        "http://localhost:5173",
    ],
    allow_parallel=True,
)
