Local Bun server for testing code using NeuroInfoAPI against a controllable mock backend.
This project now covers:
- REST API mock endpoints (
/api/v2/...) - WebSocket endpoint + ticket auth flow (
/api/v2/ws,/api/v2/ws/ticket) - Browser UI for editing state and emitting events (
/ui) - JSON persistence (
src/mock-state.json) - Importing real data from upstream NeuroInfoApi v2 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 for neuroinfoapi-client v2:
- UI:
http://localhost:8787/ui - Health:
http://localhost:8787/health - REST base:
http://localhost:8787/api/v2 - WS endpoint:
ws://localhost:8787/api/v2/ws - Ticket endpoint:
http://localhost:8787/api/v2/ws/ticket
neuroinfoapi-client setup example:
import { NeuroInfoApiClient, NeuroInfoApiWebsocketClient } from "neuroinfoapi-client";
const api = new NeuroInfoApiClient("mock-token", {
baseUrl: "http://localhost:8787/api/v2",
});
const ws = new NeuroInfoApiWebsocketClient("mock-token", {
baseUrl: "ws://localhost:8787/api/v2/ws",
apiBaseUrl: "http://localhost:8787/api/v2",
});- 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/v2/ws?ticket=...) or - bearer token in
Authorizationheader.
- ticket (
/api/v2/ws/ticketrequires an auth header and returns a short-lived one-time ticket.
REST routes include (non-exhaustive):
- Twitch
GET /api/v2/twitch/streamGET /api/v2/twitch/vodsGET /api/v2/twitch/vod?id=...(streamIdis also accepted)
- Schedule
GET /api/v2/scheduleGET /api/v2/schedule/latestGET /api/v2/schedule/searchGET /api/v2/devstream/timesGET /api/v2/schedule/weeks
- Subathon
GET /api/v2/subathon(active/current subathons)GET /api/v2/subathon/years(returnsRecord<year, name>)GET /api/v2/subathon?year=...
Additional docs/testing parity endpoint:
GET /api/test/geterror?code=AP1(returns documented error payloads)
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/v2/__test/import
Payload:
{
"target": "vods",
"token": "<real token>",
"year": 2026,
"week": 15
}Supported targets:
streamvodsscheduleLatestscheduleWeeksubathonCurrentsubathonYeardevstreamtimesblogFeed
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/v2/__test/* for UI and automation. Helpers include:
- state read/write/reset
- Twitch/Schedule/Subathon upserts
- event emission
- upstream import
These are intended for local development only.