3fff3cd2f8
apps/sito passa in radice, apps/platforms si toglie: vive in gitea:Adriano/InsanityLab-platforms, con la storia del repo comune. I piani e le specifiche di Longevity e Campus lasciano docs/ e seguono le piattaforme. README e compose: deploy da /opt/docker/insanitylab/src; al primo deploy .env va spostato da apps/sito/.env alla radice. Refs #20 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
import type { APIRoute } from 'astro';
|
|
import { getDb } from '../../../../lib/db';
|
|
import { seedByTag } from '../../../../data/content-seed';
|
|
export const prerender = false;
|
|
|
|
const json = (status: number, body: object) =>
|
|
new Response(JSON.stringify(body), { status, headers: { 'Content-Type': 'application/json' } });
|
|
|
|
export const GET: APIRoute = () => {
|
|
const rows = getDb().prepare(
|
|
'SELECT tag, type, value, styles, updated_at, updated_by FROM content_blocks ORDER BY tag'
|
|
).all() as { tag: string; type: string; value: string; styles: string; updated_at: string; updated_by: string | null }[];
|
|
const items = rows.map((r) => {
|
|
let styles: Record<string, string> = {};
|
|
try { styles = JSON.parse(r.styles); } catch { /* styles corrotto: si ignora */ }
|
|
if (typeof styles !== 'object' || styles === null) styles = {};
|
|
return {
|
|
tag: r.tag,
|
|
type: r.type,
|
|
value: r.value,
|
|
styles,
|
|
styleOptions: seedByTag.get(r.tag)?.styleOptions ?? [],
|
|
updatedAt: r.updated_at,
|
|
updatedBy: r.updated_by,
|
|
};
|
|
});
|
|
return json(200, { items });
|
|
};
|