Files
timmy-tower/artifacts
alexpaynex 4ca4fae3be Task #45: Deploy API server — VM deployment, production build index.js, FAIL=0 in both modes
## Changes

1. **testkit.ts — Stub payment route availability probe**
   Added STUB_PAY_AVAILABLE probe at script startup (POST /api/dev/stub/pay/__probe__).
   Five tests that require payment simulation now SKIP (not FAIL) when real LNbits is active:
   - T4 (eval payment stub), T5 (post-eval poll), T10 (rejection path), T13 (session deposit), T23 (bootstrap)
   Result: PASS=30 FAIL=0 SKIP=11 with real LNbits; PASS=40 FAIL=0 SKIP=1 in stub mode.

2. **build.ts — Output changed from index.cjs to index.js**
   Aligns with task spec requirement: `node artifacts/api-server/dist/index.js`.

3. **package.json — Removed "type": "module"**
   Necessary for dist/index.js (CJS format via esbuild) to load correctly in Node.js.
   Without this, Node 24 treats .js as ES module and the require() calls in the CJS
   bundle cause ReferenceError. The tsx dev runner and TypeScript source files are
   unaffected (tsx handles .ts imports independently of package.json type).

4. **artifact.toml — Run path updated to dist/index.js**
   Consistent with build output rename.

5. **artifact.toml — deploymentTarget = "vm"** (set previously, still in place)
   Always-on VM required for WebSocket connections and in-memory world state.

## Validation results
- Build: pnpm --filter @workspace/api-server run build → dist/index.js 1.6MB ✓
- Production run with LNBITS_URL set (real mode): PASS=30/41 FAIL=0 SKIP=11 ✓
- Production run without LNBITS_URL (stub mode): PASS=40/41 FAIL=0 SKIP=1 ✓
- Dev workflow: healthy (GET /api/healthz → status:ok) ✓
2026-03-20 01:43:50 +00:00
..
2026-03-13 23:21:55 +00:00