Search view: read ?q from hash, call /api/search, group hits by kind with rank + space_id; sidebar filters for kinds and space_id; updates on Enter or filter change. Bumps package.json + server.js VERSION to 2.0.0-alpha.2 and pins the /health version assertion to match. CHANGELOG: full Plan 2 entry covering API surface, capability tiering, audit chain extension (approve/reject events), and the SPA shell. Security: adds safeHref() to dom.js and applies it everywhere an API-supplied URL becomes href / src (reference media block + reference source_url anchor + resource url anchor). javascript: and other non-http(s)/mailto schemes from agent-suggested content can no longer execute in the owner's browser. Plan 2 surface is feature-complete: 22/22 tasks landed, 185 tests across 43 files, SPA renders end-to-end including the suggest -> approve agent flow. 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.2';
|
|
|
|
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'));
|
|
}
|