@sybilion/mock-server
v1.0.1
Published
Express-based mock API server for Sybilion demos and local dev
Readme
@sybilion/mock-server
Mock API server for Sybilion apps. Serves /api/v1 routes from local JSON/data files for development, demos, and E2E tests.
Published to npm.
Install
yarn add @sybilion/mock-serverUsage
Standalone app (createMockServer)
Creates a full Express app with CORS, JSON body parsing, and mock routes at /api/v1:
import { createMockServer } from "@sybilion/mock-server";
import path from "path";
const app = createMockServer({
dataPath: path.join(__dirname, "data"),
userEmail: "[email protected]",
allowWrites: true,
});
app.listen(3000);Mount in existing app (createApiRouter)
Mount only the API router in an existing Express app:
import express from "express";
import {
createApiRouter,
ensureUserEmailCookiesMiddleware,
} from "@sybilion/mock-server";
const app = express();
app.use(express.json());
app.use(ensureUserEmailCookiesMiddleware("[email protected]"));
app.use(
"/api/v1",
createApiRouter({
dataPath: path.resolve(__dirname, "mocks"),
userEmail: "[email protected]",
allowWrites: false,
}),
);Options
| Option | Type | Description |
| ------------------ | --------- | ----------------------------------------------------------------------- |
| dataPath | string | Path to data directory (required) |
| userEmail | string | User email for user-scoped data |
| cacheVersionPath | string | Path for cache-version.json |
| importApiBase | string | Real API URL for import (default: https://api.sybilion.com/api/v1) |
| agentServiceUrl | string | Agent service URL for chat (default: https://demo-agent.sybilion.com) |
| allowWrites | boolean | Enable import/user writes (default: true) |
API routes
- Datasets, analyses, components
- Auth, chat, subscriptions
- Historicals, import, user-series
- Link preview, ping
- Demo data: users, files, forecast
Build
yarn buildConsumers
- design-demo – full mock server for demo app
- sybilion-client –
createApiRouterwhenMOCK_API=true(E2E tests)
