feat(wiki): serve a public documentation written from the panel
Pages live in SQLite and are read without a session: documentation nobody can reach without an account is not documentation. Drafts answer 404 even when their address is guessed, and the site never falls back to the dashboard shell, which would send a visitor to a login screen. The wiki ships with terms of use and a privacy policy written against the revised Swiss LPD, describing table by table what this codebase actually stores. Both are marked protected: they can be rewritten, not deleted, and a deleted one comes back on the next start — a bot that processes personal data must always be able to show its notice. The bracketed details still have to be completed and the whole reviewed; this is a starting point written from the schema, not legal advice. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
6 files changed
+601
-3
No files matched your search
+13
-3
@@ -11,6 +11,7 @@ import { authorize } from './auth/guard.js';
|
||||
import { broadcast, closeEventStreams, topicForPath } from './events.js';
|
||||
import { HttpError, readJsonBody, readRawBody, sendEmpty, sendJson, sendStatic } from './http.js';
|
||||
import { createRouter } from './router.js';
|
||||
import { seedWiki } from './services/wiki-seed.js';
|
||||
|
||||
/** HTTP server of the dashboard (M16-T01). */
|
||||
|
||||
@@ -71,9 +72,10 @@ export function createHandler({ client = null, setupOnly = false, startedAt = Da
|
||||
|
||||
const isApi = pathname.startsWith('/api/') || pathname.startsWith('/auth/');
|
||||
if (!isApi) {
|
||||
// Anything else is the single page application; unknown paths fall back to
|
||||
// its shell so client-side routing works on a hard refresh.
|
||||
const served = await sendStatic(response, publicDir, pathname, { fallback: 'index.html' });
|
||||
// The wiki is a separate public page: it must never fall back to the
|
||||
// dashboard shell, which would send a visitor to a login screen.
|
||||
const fallback = pathname === '/wiki' || pathname.startsWith('/wiki/') ? 'wiki.html' : 'index.html';
|
||||
const served = await sendStatic(response, publicDir, pathname, { fallback });
|
||||
if (!served) sendEmpty(response, 404);
|
||||
return;
|
||||
}
|
||||
@@ -128,6 +130,14 @@ export function createHandler({ client = null, setupOnly = false, startedAt = Da
|
||||
}
|
||||
|
||||
export function startWebServer({ client = null, setupOnly = false } = {}) {
|
||||
// A bot that processes personal data owes its users a notice, so the legal
|
||||
// pages are created before the site answers its first request.
|
||||
try {
|
||||
seedWiki();
|
||||
} catch (error) {
|
||||
log.warn('Could not seed the wiki', error);
|
||||
}
|
||||
|
||||
const server = createServer(createHandler({ client, setupOnly, startedAt: Date.now() }));
|
||||
|
||||
server.listen(env.web.port, env.web.host, () => {
|
||||
|
||||
Reference in new issue
Block a user