| 39 | // ============================================================================= |
| 40 | |
| 41 | async function dispatchAction(action, payload) { |
| 42 | switch (action) { |
| 43 | // Required by contract: readiness check. |
| 44 | // Return ready: true when the server can process actions. |
| 45 | // Gate on core dependencies (DB pool, etc.), NOT on user-initiated |
| 46 | // connections (QR scans, OAuth flows). |
| 47 | // The orchestrator blocks provisioning until this returns ready. |
| 48 | case "ping": { |
| 49 | // TODO: add your own checks here, e.g.: |
| 50 | // await db.query("SELECT 1"); |
| 51 | return { ready: true }; |
| 52 | } |
| 53 | default: |
| 54 | throw new Error(`Unknown action: ${action}`); |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | // ============================================================================= |
| 59 | // CONTRACT HANDLERS, you usually don't need to modify these |