Add API documentation and underground station importer
- Introduced a new HTML documentation page for the oradio API, including a JavaScript file to handle dynamic content and API requests. - Added a CSS file for styling the documentation page. - Implemented an underground station importer script that fetches data from Radio-Browser and writes it to a JSON file. - Created a stats module to compute and manage vote and play statistics for radio stations. - Added a polyfill for modulepreload to ensure compatibility with older browsers.
This commit is contained in:
@@ -5,21 +5,21 @@ import { probeStream } from './probe.js';
|
||||
const probe = probeStream;
|
||||
|
||||
export async function runHealthCheck() {
|
||||
const db = getDb();
|
||||
const streams = db.prepare('SELECT id, url FROM streams').all();
|
||||
const update = db.prepare(
|
||||
"UPDATE streams SET last_status = ?, last_checked_at = datetime('now') WHERE id = ?"
|
||||
);
|
||||
for (const s of streams) {
|
||||
const status = await probe(s.url);
|
||||
update.run(status, s.id);
|
||||
}
|
||||
return streams.length;
|
||||
const db = getDb();
|
||||
const streams = db.prepare('SELECT id, url FROM streams').all();
|
||||
const update = db.prepare(
|
||||
"UPDATE streams SET last_status = ?, last_checked_at = datetime('now') WHERE id = ?"
|
||||
);
|
||||
for (const s of streams) {
|
||||
const status = await probe(s.url);
|
||||
update.run(status, s.id);
|
||||
}
|
||||
return streams.length;
|
||||
}
|
||||
|
||||
export function scheduleHealthCheck(expr) {
|
||||
if (!expr) return null;
|
||||
return cron.schedule(expr, () => {
|
||||
runHealthCheck().catch((err) => console.error('[health]', err));
|
||||
});
|
||||
if (!expr) return null;
|
||||
return cron.schedule(expr, () => {
|
||||
runHealthCheck().catch((err) => console.error('[health]', err));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user