Merge commit '42110059c7a42b317fd1391e3cd539a555f19226'

This commit is contained in:
2026-06-30 01:06:09 +02:00
7 changed files with 126 additions and 1 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "openbureau-cms-api",
"version": "0.1.0",
"version": "0.6.0",
"private": true,
"type": "module",
"description": "Headless CMS backend für OPENBUREAU — schreibt Supabase-Posts in Hugo-content/, baut und serviert die Site.",
+11
View File
@@ -12,8 +12,10 @@ import upload from './routes/upload.js';
import profile from './routes/profile.js';
import users from './routes/users.js';
import stats from './routes/stats.js';
import system from './routes/system.js';
import history from './routes/history.js';
import { requireAuth, requireAdmin } from './auth.js';
import { config } from './config.js';
import { manager } from './plugins.js';
import { runMigrations } from './migrate.js';
@@ -85,6 +87,15 @@ app.route('/api/upload', upload);
app.route('/api/profile', profile);
app.route('/api/users', users);
app.route('/api/stats', stats);
app.route('/api/system', system);
// Content-Modell der Site fürs Admin (schema-getriebenes Rendern). Jede:r
// eingeloggte Nutzer:in darf es lesen — der Editor braucht es zum Aufbauen.
app.get('/api/schema', (c) => c.json({
site: config.site || null,
auth: config.auth || 'supabase',
plugins: config.plugins,
collections: config.collections,
}));
// --- Admin-SPA (im Container mitgebaut, unter /admin serviert) ---
app.get('/admin', (c) => c.redirect('/admin/'));
+38
View File
@@ -0,0 +1,38 @@
import { Hono } from 'hono';
import { readFile } from 'node:fs/promises';
import { config } from '../config.js';
import { manager } from '../plugins.js';
import { requireAdmin } from '../auth.js';
// System-/Diagnose-Info für das Admin-Panel: welche core-Version läuft, welche
// Plugins aktiv sind, welches Content-Modell die Site fährt. Rein lesend, Admin.
// Reine Builder-Funktion (testbar) — die Route hängt nur Version + Hugo dran.
export function systemInfo({ version, hugo }) {
return {
core: { name: 'openbureau-core', version },
site: config.site || null,
auth: config.auth || 'supabase',
plugins: manager.plugins.map((p) => ({
name: p.name,
routes: (p.routes || []).length,
migrations: (p.migrations || []).length,
})),
collections: config.collections.map((c) => ({
kind: c.kind, label: c.label, statKey: c.statKey || null, fields: (c.fields || []).length,
})),
hugo,
};
}
const system = new Hono();
system.use('*', requireAdmin);
system.get('/', async (c) => {
let version = '0.0.0';
try {
const pkg = JSON.parse(await readFile(new URL('../../package.json', import.meta.url), 'utf8'));
version = pkg.version || version;
} catch { /* package.json nicht lesbar → 0.0.0 */ }
return c.json(systemInfo({ version, hugo: '0.161.1+extended' }));
});
export default system;
+30
View File
@@ -0,0 +1,30 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { fileURLToPath } from 'node:url';
process.env.CMS_CONFIG ||= fileURLToPath(new URL('../../examples/openbureau.config.js', import.meta.url));
process.env.SUPABASE_URL ||= 'http://localhost';
process.env.SUPABASE_SERVICE_KEY ||= 'x';
process.env.JWT_SECRET ||= 'x';
process.env.SITE_DIR ||= '/tmp/nosite';
const { systemInfo } = await import('../src/routes/system.js');
test('systemInfo reflects core version, plugins and content model', () => {
const info = systemInfo({ version: '0.6.0', hugo: '0.161.1+extended' });
assert.equal(info.core.name, 'openbureau-core');
assert.equal(info.core.version, '0.6.0');
assert.equal(info.site, 'openbureau');
assert.equal(info.auth, 'supabase'); // openbureau.config.js sets auth: 'supabase'
assert.equal(info.hugo, '0.161.1+extended');
// dialog plugin is active with its routes + the one migration
const dialog = info.plugins.find((p) => p.name === 'dialog');
assert.ok(dialog, 'dialog plugin listed');
assert.ok(dialog.routes > 0);
assert.equal(dialog.migrations, 1);
// content model surfaced from the config collections
assert.deepEqual(info.collections.map((c) => c.kind).sort(), ['beitrag', 'biblio', 'rubrik', 'seite']);
const beitrag = info.collections.find((c) => c.kind === 'beitrag');
assert.equal(beitrag.label, 'Beiträge');
assert.ok(beitrag.fields > 0);
});