Example Server
Disposable Node.js discovery, pairing, gateway, and job integration.
examples/node-server is a local node:http and ws host for the
published package boundaries.
| Route | Purpose |
|---|---|
GET /.well-known/openprinter | Discovery document |
POST /openprinter/pair | Pairing-code redemption and public-key registration |
/.well-known/openprinter/gateway | Challenge-authenticated WebSocket upgrade |
POST /development/pairing-code | Create a disposable local code |
POST /agents/:agentId/jobs | Deliver a validated job to a live session |
The process logs one development pairing code at startup. It uses the SDK's volatile stores, so restarting invalidates every pairing. That behavior is useful for tests but unsuitable for production.
The host owns the WebSocket upgrade and its process-local session map.
handleGatewayConnection owns challenge verification, hello,
heartbeat, and normal message routing after the socket is accepted.
Production integrations must add durable pairing/public credential stores, authorization around code creation, pairing rate limits, durable jobs, and cluster-aware session routing.
Run all example checks with:
pnpm --filter openprinter-node-example check