Local Bun server for testing code using NeuroInfoAPI against a controllable mock backend.
This project now covers:
- REST API mock endpoints (
/api/v1/...) - WebSocket endpoint + ticket auth flow (
/api/ws,/api/ws/ticket) - Browser UI for editing state and emitting events (
/ui) - JSON persistence (
src/mock-state.json) - Importing real data from upstream NeuroInfoApi via
neuroinfoapi-client
Requirements:
Install deps:
cd Mock-TestServer
bun installNote
If some error accours with axios on starting the server please use npm install instead of bun install.
bun src/index.tsAlternative script:
bun run runDefault URLs:
- UI:
http://localhost:8787/ui - Health:
http://localhost:8787/health - REST base:
http://localhost:8787/api/v1 - WS endpoint:
ws://localhost:8787/api/ws - Ticket endpoint:
http://localhost:8787/api/ws/ticket
- Protected REST endpoints still require
Authorization: Bearer <token>. - Token content is accepted as-is in mock mode (no real token validation).
- WS allows either:
- ticket (
/api/ws?ticket=...) or - bearer token in
Authorizationheader.
- ticket (
/api/ws/ticketrequires an auth header and returns a short-lived one-time ticket.
REST routes include (non-exhaustive):
- Twitch
GET /api/v1/twitch/streamGET /api/v1/twitch/vodsGET /api/v1/twitch/vod?streamId=...
- Schedule
GET /api/v1/scheduleGET /api/v1/schedule/latestGET /api/v1/schedule/searchGET /api/v1/schedule/devstreamtimes
- Subathon
GET /api/v1/subathon/currentGET /api/v1/subathon/yearsGET /api/v1/subathon?year=...
The UI at /ui supports:
- Editing Twitch, Schedule, and Subathon payloads
- Emitting WS events
- Resetting or replacing full state
- Importing selected data from real API into local state
Changes are persisted to:
src/mock-state.json
Use test helper endpoint:
POST /api/v1/__test/import
Payload:
{
"target": "vods",
"token": "<real token>",
"year": 2026,
"week": 15
}Supported targets:
streamvodsscheduleLatestscheduleWeeksubathonCurrentsubathonYeardevstreamtimes
Inbound:
{"type":"addEvent","data":{"eventType":"streamOnline"}}{"type":"removeEvent","data":{"eventType":"streamOnline"}}{"type":"listEvents","data":{}}
Outbound message types:
welcomeaddSuccessremoveSuccesslistEventseventinvalid
The mock exposes helper endpoints under /api/v1/__test/* for UI and automation, including:
- state read/write/reset
- Twitch/Schedule/Subathon upserts
- event emission
- upstream import
These are intended for local development only.