Documentation Index
Fetch the complete documentation index at: https://docs.laportenard.com/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
- Node.js 20+ (
node -vto check) - Odoo 12 running locally at
http://localhost:8069with a POS session open - A terminal with 3 tabs
Step 1: Build the protocol package
The protocol package must be built first since the hub depends on it.Step 2: Start the hub in dev mode
Open a new terminal tab:.env file for local development:
.env
HUB_DEV_AUTH=true enables dev-mode auth bypass. When the frontend sends an empty token, the hub authenticates using its own Odoo credentials instead of rejecting the connection.http://localhost:8766/ in a browser to see the live dashboard.
Step 3: Enable hub mode in Odoo
- Odoo UI
- Python shell
- Environment variable
- Go to Point of Sale > Configuration
- Set
nu_hub_enabled= checked - Set
nu_hub_url=ws://localhost:8766 - Save
Step 4: Start the frontend
Open a third terminal tab:- Tab 1:
http://localhost:3000/pos-react/order/?table=1 - Tab 2:
http://localhost:3000/pos-react/order/?table=1
http://localhost:8766/ should show 2 connected terminals.
Step 5: Test real-time sync
- In Tab 1: Add an item to the order
- Watch Tab 2: The item should appear within milliseconds
- Check the dashboard: 2 terminals, 1 active lease, events flowing
Test leasing
- In Tab 1, open an order (acquires a lease)
- In Tab 2, try to open the same order
- Tab 2 should see a “LEASE_DENIED”
- Navigate away in Tab 1 (releases the lease)
- Tab 2 can now acquire the lease
Test offline recovery
- Stop the hub (
Ctrl+Cin the hub terminal) - Add items in Tab 1 — they queue in the localStorage outbox
- Restart the hub (
npm run dev) - The frontend reconnects automatically and flushes the outbox
Development workflow
Inspecting the hub database
The dev SQLite file is atnu_pos_hub/dev.sqlite:
Testing with wscat
Connect to the hub directly to test the protocol:Troubleshooting
Hub won't start: Cannot find module '@nu/sync-protocol'
Hub won't start: Cannot find module '@nu/sync-protocol'
Build the protocol package first:
Auth fails for all terminals
Auth fails for all terminals
Make sure Odoo is running and credentials in
.env are correct. In dev mode, ensure HUB_DEV_AUTH=true is set.Frontend stays in 'Connecting' state
Frontend stays in 'Connecting' state
- Is the hub running?
curl http://localhost:8766/health - Is
nu_hub_enabledset totrue? - Check browser DevTools Network tab for WS connections
- Look for connection errors in the browser console
Orders not forwarding to Odoo
Orders not forwarding to Odoo
- Is Odoo reachable?
curl http://localhost:8069/web/login - Check hub logs for forwarding errors
- Ensure
ODOO_USER/ODOO_PASSWORDhas POS access
'Lease request timed out'
'Lease request timed out'
The hub didn’t respond to
LEASE_ACQUIRE within 10 seconds. Usually means the hub is overloaded or the message was lost. Check hub logs.Stale dev.sqlite causing SQLite errors
Stale dev.sqlite causing SQLite errors
Environment variable reference
| Variable | Default | Description |
|---|---|---|
ODOO_URL | http://localhost:8069 | Odoo instance URL |
ODOO_DB | pos | Odoo database name |
ODOO_USER | admin | Odoo user for hub session |
ODOO_PASSWORD | admin | Odoo password |
HUB_HTTP_PORT | 8766 | HTTP + WebSocket port |
HUB_DB_PATH | ./hub.sqlite | SQLite database file |
HUB_LOG_LEVEL | info | Log level |
HUB_MDNS_ENABLED | true | mDNS discovery |
HUB_LEASE_TTL_MS | 60000 | Lease duration (ms) |
HUB_HEARTBEAT_MS | 20000 | Heartbeat interval (ms) |
HUB_GRACE_MS | 10000 | Disconnect grace period (ms) |
HUB_FORWARD_INTERVAL_MS | 5000 | Odoo drain interval (ms) |
HUB_FORWARD_BATCH_SIZE | 20 | Events per drain batch |
HUB_DEV_AUTH | false | Dev-mode auth bypass |