Rework scan screen, make lookups non-blocking, fix review findings

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-18 10:19:32 -07:00
1 parent 468cafc6db
commit b5defb4e4f
46 files changed
+1957 -406

No files matched your search

+5 -5
View File
@@ -1,5 +1,6 @@
import { existsSync, readFileSync, statSync } from 'node:fs';
import { extname, join, normalize, resolve as resolvePath } from 'node:path';
import { extname, join, resolve as resolvePath } from 'node:path';
import { staticPath } from './static.ts';
import { serve } from '@hono/node-server';
import { openDb } from './db.ts';
import { createJobs } from './jobs.ts';
@@ -24,15 +25,14 @@ const resolver = createResolver({ fetch: globalThis.fetch, cache: db.cache });
const jobs = createJobs({
db, resolver, onChange: (b) => events.emitBook(b), isTemporary: (e) => e instanceof TemporaryError,
});
const app = createApp({ db, jobs, resolver, renderCardsPdf, renderCalibrationPdf, classNames, events });
const app = createApp({ port, db, jobs, resolver, renderCardsPdf, renderCalibrationPdf, classNames, events });
app.get('*', (c) => {
if (!existsSync(join(webRoot, 'index.html'))) {
return c.text('The web app has not been built. Run `npm run build` and reload.', 503);
}
const rel = normalize(decodeURIComponent(c.req.path)).replace(/^([/\\])+/, '');
const file = resolvePath(webRoot, rel === '' ? 'index.html' : rel);
if (!file.startsWith(webRoot) || !existsSync(file) || !statSync(file).isFile()) return c.text('Not found', 404);
const file = staticPath(webRoot, c.req.path);
if (!file || !existsSync(file) || !statSync(file).isFile()) return c.text('Not found', 404);
return c.body(readFileSync(file), 200, { 'Content-Type': MIME[extname(file)] ?? 'application/octet-stream' });
});