@symbo.ls/mermaid
v3.14.709
Published
Self-sustaining server runner for Symbols projects from JSON. Renders DOMQL projects to HTML with optional brender SSR.
Maintainers
Keywords
Readme
@symbo.ls/mermaid
Self-sustaining server runner for Symbols projects. Renders DOMQL projects from JSON to HTML, with optional brender SSR.
Works in three modes:
- Standalone —
mermaidCLI /createMermaidApp({ jsonPath })Express app - Pure render —
renderProjectHtml(data, opts)returns an HTML string in any runtime - Pluggable data source —
createMermaidApp({ getProjectData })lets you wire KV / API / DB
For the production hosting service (Cloudflare Workers + KV/API + custom domains), see @symbo.ls/mermaid-server which builds on top of this package.
Quick start
# Run a project from a local JSON file
npx mermaid --json ./app.json
# open http://localhost:3333
# Or as a library
node -e "import('@symbo.ls/mermaid').then(m => m.createMermaidApp({ jsonPath: './app.json' }).listen(3333))"API
createMermaidApp(options)
Returns an Express application.
| Option | Type | Description |
| ---------------- | -------- | --------------------------------------------------------------------- |
| jsonPath | string | Path to local JSON file (or directory containing app.json) |
| appkeyOverride | string | Force a specific appkey for all requests |
| channel | string | production (default) | staging | development |
| getProjectData | function | async (req, ctx) => { data, appkey?, channel?, isProd? } |
| cors | boolean | Enable CORS middleware (default true) |
| editor | object | { bundle: string } to inject @symbo.ls/preview-editor in non-prod |
renderProjectHtml(data, options)
Pure runtime-agnostic renderer. Returns { html, status, contentType }.
| Option | Type | Description |
| ----------------------- | ------- | ------------------------------------------------------ |
| appkey | string | identifier for metadata + comments |
| pathname | string | request pathname |
| channel | string | production | staging | development |
| isProd | boolean | controls SEO indexing (custom domains only) |
| req | object | Express-like request (used by bundle context) |
| userId | string | injects window.__SYMBOLS_AUTH__ |
| smblsIife | string | preloaded smbls IIFE source (CF Workers / build-time) |
| editorBundle | string | preview-editor bundle to inject (non-prod only) |
| analyzedScript | string | analytics tracking <script> to inject |
| indexHtml | string | override the index.html template |
| ssrCache | object | pre-computed SSR cache (skips runtime brender) |
| ProjectDataService | object | passed to getBundleScript for shared-library merging |
loadJsonData(jsonPath)
Synchronously load and parse a project JSON file.
Other exports
renderNotPublishedHtml, transpileFunctionStrings, getBundleScript, getSmblsIife, normalizeRoute, resolvePageRoute, extractRouteParams, STATIC_EXT, deepDestringifyFunctions, stripFunctionStrings, generateSitemap (if brender is available), replaceVariablesInFileSync, transpileFuncql.
Environment variables
| Variable | Default | Description |
| ----------- | ---------------------------------- | ---------------------------- |
| PORT | 3333 | HTTP port (CLI only) |
| JSON_PATH | ./app.json | JSON data path (CLI only) |
| APPKEY | — | Override appkey (CLI only) |
| NODE_ENV | development | Channel selection |
| LOG_LEVEL | debug (dev) / info (prod) | Log verbosity |
| BRENDER | enabled | Set to false to skip SSR |
