@leumas/static-pages
Imperium static-pages plugin router — CRUD over on-disk per-config page files (.json/.md/.html/.jsx). Consolidates the read-only StaticPages fetch/list router into a full CRUD surface for Studio.
@leumas/static-pages
Imperium static-pages plugin router — CRUD over an on-disk, per-config corpus of page files (.json / .md / .html / .jsx). Each config folder is one subdomain's static-page set (the z.Domains2/StaticPages model). Mounted by leumas-api alongside the other router-kit routers.
Absorbs (DRY-consolidated from): z.Domains2/Router/StaticPages — router.js + handlers/{list-pages,fetch-page} + utils/{file,request,response}. The legacy router was read-only (list + fetch); this adds the write half (create/overwrite/delete pages and config folders) so Studio can manage pages, not just serve them.
Endpoints
| Method | Path | Does |
|---|---|---|
| GET | / | list config folders |
| POST | / | { config } → create a config folder |
| DELETE | /:config | delete a config folder |
| GET | /:config | list page files in a config |
| GET | /:config/:page | read a page (.json parsed, else raw string) |
| PUT | /:config/:page | { content } → create/overwrite a page |
| DELETE | /:config/:page | delete a page |
Every response is { status: 'success', data } or { status: 'error', message } (legacy shape kept).
Usage (in leumas-api)
import { createStaticPagesRouter } from '@leumas/static-pages';
import { requireAuth } from '@leumas/auth';
app.use('/api/static-pages', createStaticPagesRouter({
base: process.env.STATIC_PAGES_DIR, // absolute path to the StaticPages root
gate: requireAuth(), // protects create/update/delete; reads stay public
}));
Path traversal is refused — a config can only touch files inside its own folder. Import createStore({ base }) directly if you want the filesystem CRUD without Express.