NPR::HUB

Self-hosted NPR signal hub. Copy. Run. Done.

0

Download

Twee opties: static (Netlify) of full (self-hosted).

⧉ copy # Static (alleen HTML/JS/CSS — voor Netlify of browserven) curl -LO https://npr-hub.nl/api/public-zip -o npr-hub-public.zip
⧉ copy # Full (met index.js, package.json, README — voor self-hosting) curl -LO https://npr-hub.nl/api/full-zip -o npr-hub-full.zip
1

Prerequisites

Node.js 20+ and a local LLM (llama.cpp or Ollama).

$ node -v
v22.22.0 ✓

# Or install (no sudo — use nvm):
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
$ nvm install 22
2

Extract & Setup

One command does it all — deps, detect llama, gen token.

⧉ copy unzip npr-hub-full.zip && cd npr-hub-* && node index.js
╔══════════════════════════════════════╗
║ NPR Hub — Setup ║
╚══════════════════════════════════════╝
Node.js v22.22.0
Dependencies installed
Llama endpoint: http://[::1]:8765
Writing config...
Config written

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Dashboard: http://[::1]:3000/dashboard
Terminal: http://[::1]:3000/terminal
API Token: ••••••••••••••••••••••••
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
3

Start

Fire it up. First visit redirects to browser setup if needed.

⧉ copy node index.js
[NPR-HUB] Listening on [::]:3000
[NPR-HUB] Dashboard → http://[::1]:3000/dashboard
[NPR-HUB] Terminal → http://[::1]:3000/terminal
[NPR-HUB] API → http://[::1]:3000/api/
[NPR-HUB] Health → http://[::1]:3000/health
4

Connect Terminal

CLI remote control via the terminal endpoint.

# WebSocket (interactive):
$ wscat -c ws://localhost:3000/terminal-ws -H "X-API-Key: YOUR_TOKEN"

# Or HTTP commands:
$ curl -H "X-API-Key: YOUR_TOKEN" http://localhost:3000/api/slots
{"slots": [...]}

$ curl -H "X-API-Key: YOUR_TOKEN" http://localhost:3000/health
{"status":"ok"}

Configuration

Generated by setup.sh. Edit config.json for manual changes.

config.json

nprHub.hostBind address — :: (all), ::1 (localhost IPv6), 127.0.0.1 (IPv4)
nprHub.portHTTP port — default 3000
auth.tokenAPI auth token — auto-generated, 48 chars hex
llama.endpointOpenAI-compatible API URL for local LLM
llama.modelModel name — e.g. qwen3.6:27
slots[]NPR slots — Noord, Oost, Zuid, West, Śūnyā
refreshMsStatus refresh interval — 3000ms

Host Modes

::All interfaces, IPv6
::1Localhost IPv6 only
0.0.0.0All interfaces, IPv4

Slots

NoordN — hex 0001
OostE — hex 0002
ZuidS — hex 0003
WestW — hex 0004
ŚūnyāC — hex 0000

CLI Control REMOTE

Control the hub from any terminal. WebSocket for interactive, HTTP for one-shot.

WebSocket Terminal

Full interactive shell. Install wscat or use websockets Python.

# Install wscat (one-time):
$ npm install -g wscat

# Connect:
$ wscat -c ws://localhost:3000/terminal-ws \
-H "X-API-Key: YOUR_TOKEN"

connected (press CTRL+C to disconnect)
> slots
{ "slots": [...] }
> status
{ "status": "ok" }

HTTP Commands

One-shot queries via curl. All API routes require the token header.

# Health check:
$ curl http://localhost:3000/health
{"status":"ok","uptime":42}

# Slot status:
$ curl -H "X-API-Key: TOKEN" http://localhost:3000/api/slots
{"slots":[{"id":0,"status":"idle"},...]}

# Balans (signal balance):
$ curl -H "X-API-Key: TOKEN" http://localhost:3000/api/balans
{"balance":0.87,"center":0.42}

# Activate slot:
$ curl -X POST -H "X-API-Key: TOKEN" \
-H "Content-Type: application/json" \
-d '{"slot":0,"prompt":"scan north"}' \
http://localhost:3000/api/activate

# Deactivate slot:
$ curl -X POST -H "X-API-Key: TOKEN" \
-H "Content-Type: application/json" \
-d '{"slot":0}' \
http://localhost:3000/api/deactivate

Quick Aliases

Add to your .bashrc or .zshrc:

# Add to ~/.bashrc:
$ cat >> ~/.bashrc << 'EOF'
export NPR_TOKEN="YOUR_TOKEN"
export NPR_URL="http://localhost:3000"
npr-health() { curl -s $NPR_URL/health | jq .; }
npr-slots() { curl -s -H "X-API-Key: $NPR_TOKEN" $NPR_URL/api/slots | jq .; }
npr-balans() { curl -s -H "X-API-Key: $NPR_TOKEN" $NPR_URL/api/balans | jq .; }
npr-activate() { curl -s -X POST -H "X-API-Key: $NPR_TOKEN" -H "Content-Type: application/json" -d "{\"slot\":$1,\"prompt\":\"$2\"}" $NPR_URL/api/activate | jq .; }
EOF
$ source ~/.bashrc

API Reference

All authenticated routes require X-API-Key header.

GET/health— Status check (public)
GET/api/slots— Slot grid status
GET/api/balans— Signal balance
POST/api/activate— Activate slot + prompt
POST/api/deactivate— Deactivate slot
GET/api/sessions— Active sessions
GET/api/config— Current config
WS/terminal-ws— Interactive terminal
WS/dashboard-ws— Dashboard live updates

Auth

# Header (recommended):
X-API-Key: your-token-here

# Or query param:
GET /api/slots?token=your-token-here
✓ Copied