Files
RSSFeed/scripts/dev.mjs
T
TMCandClaude Opus 5.5 1cc99df9bb
Release / build (push) Successful in 1m25s
Build RSSFeed: self-hosted Croatian news feed with a local LLM
Merges RSS/Atom/JSON sources into one feed. A local OpenAI-compatible
LLM filters articles against plain-language negatives, groups reports
of the same event into stories, and writes a one-sentence Croatian
title and a description of at most two sentences for each story.
Original articles are only ever linked as published.

- Pipeline: fetch, dedupe, Readability extraction, keyword + AI triage
  with exceptions and learned corrections, embedding clustering with an
  LLM same-event check, summary with format check and Croatian
  language guard, regeneration for developing stories
- Neutral importance scoring with coverage boost and manual override
- Feed controls: Live or Editions, daily/category/source limits,
  breaking bypass, 7-day preview; daily digest with offline fallback
- Circuit breaker that pauses and resumes the queue on LLM outages
- Express 5 + node:sqlite server, React 19 + Vite web UI (dark, PWA)
- Feeds under /feeds/ for a single Pangolin rule; optional feed token
- Dockerfile runs typecheck and the full test suite before building;
  Gitea workflow builds, scans and pushes the image

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 10:58:32 +01:00

73 lines
2.5 KiB
JavaScript

#!/usr/bin/env node
/**
* One-command dev environment: backend (Express + API on :34500) and the Vite dev server
* (:5173, proxying /api and /feeds to the backend), with prefixed output and clean shutdown.
* npm run dev → open http://localhost:5173
* npm run dev -- --mock → also starts the mock LLM on :11435 (no real LLM needed)
*/
import { spawn } from 'node:child_process';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const dataDir = process.env.RSSFEED_DATA_DIR ?? path.join(root, '.data');
const withMock = process.argv.includes('--mock');
const procs = [];
let shuttingDown = false;
function start(name, color, command, extraEnv = {}) {
const child = spawn(command, { cwd: root, shell: true, env: { ...process.env, ...extraEnv } });
const prefix = `\x1b[${color}m[${name}]\x1b[0m `;
const pipe = (stream, out) => {
let buf = '';
stream.on('data', (d) => {
buf += d.toString();
let i;
while ((i = buf.indexOf('\n')) >= 0) {
out.write(prefix + buf.slice(0, i) + '\n');
buf = buf.slice(i + 1);
}
});
stream.on('end', () => {
if (buf.length > 0) out.write(prefix + buf + '\n');
});
};
pipe(child.stdout, process.stdout);
pipe(child.stderr, process.stderr);
child.on('exit', (code) => {
process.stdout.write(prefix + `exited (code ${code})\n`);
shutdown();
});
procs.push(child);
}
function shutdown() {
if (shuttingDown) return;
shuttingDown = true;
for (const p of procs) {
try {
if (process.platform === 'win32') spawn('taskkill', ['/pid', String(p.pid), '/T', '/F']);
else p.kill('SIGTERM');
} catch {
/* already gone */
}
}
setTimeout(() => process.exit(0), 500);
}
process.on('SIGINT', shutdown);
process.on('SIGTERM', shutdown);
console.log('RSSFeed dev — backend :34500 + web :5173' + (withMock ? ' + mock LLM :11435' : ''));
console.log(` data dir: ${dataDir}`);
console.log(' open → \x1b[36mhttp://localhost:5173\x1b[0m\n');
const serverEnv = { RSSFEED_DATA_DIR: dataDir, RSSFEED_ALLOW_PRIVATE_URLS: process.env.RSSFEED_ALLOW_PRIVATE_URLS ?? '1' };
if (withMock) {
serverEnv.RSSFEED_LLM_BASE_URL = 'http://127.0.0.1:11435/v1';
start('mock-llm', '33', 'node server/src/testing/mock-llm.ts 11435');
}
start('server', '36', 'npm run dev --workspace server', serverEnv);
start('web', '35', 'npm run dev --workspace web');