Three-column grid (sidebar / main / right rail) with Cradle aesthetic: blackflame accent on Cinzel display headings + Cormorant Garamond body in cards, system UI for chrome. Hash-based router covers all entity routes plus search, inbox, sacred-valley. api.js stores OWNER_TOKEN in localStorage and prompts via a modal on 401. dom.js provides safe el() + mount() builders so no component ever assigns innerHTML from API data (the only exception is an explicit, scary-named html: opt-in for sanitizer output, used later by the markdown editor). state.js is a tiny event bus for shared chrome state (pending count). Components and views are loaded as ES modules — sidebar / topbar / rightrail + 9 view stubs that the later Phase E tasks fill in. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
import 'dotenv/config';
|
|
import express from 'express';
|
|
import { pool } from './lib/db/pool.js';
|
|
import { log } from './lib/log.js';
|
|
import { mountApi } from './lib/api/index.js';
|
|
|
|
const VERSION = '2.0.0-alpha.1';
|
|
|
|
export function createApp() {
|
|
const app = express();
|
|
app.use(express.json({ limit: '10mb' }));
|
|
app.use(express.static('public'));
|
|
|
|
app.get('/health', async (_req, res) => {
|
|
let db_ok = false;
|
|
try {
|
|
await pool.query('SELECT 1');
|
|
db_ok = true;
|
|
} catch (e) {
|
|
log.error({ err: e }, 'healthcheck db ping failed');
|
|
}
|
|
res.json({ ok: true, db_ok, version: VERSION });
|
|
});
|
|
|
|
mountApi(app);
|
|
|
|
app.use((_req, res) => res.status(404).json({ error: { code: 'not_found' } }));
|
|
|
|
app.use((err, _req, res, _next) => {
|
|
log.error({ err }, 'unhandled');
|
|
res.status(500).json({ error: { code: 'internal', message: 'internal server error' } });
|
|
});
|
|
|
|
return app;
|
|
}
|
|
|
|
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
const port = process.env.PORT || 3000;
|
|
createApp().listen(port, () => log.info({ port }, 'void-server listening'));
|
|
}
|