mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-25 20:14:38 +02:00
Adds the services/news-ingester Bun service that pulls 25 public RSS/JSON feeds into news.curated_articles every 15 min, with Mozilla Readability fallback for thin RSS bodies and 30-day retention. apps/api /feed is rewritten to read from the new pool table directly instead of the sync_changes hack, with topics/lang/since/limit/offset query params. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
19 lines
465 B
TypeScript
19 lines
465 B
TypeScript
/**
|
|
* Single Postgres connection pool, lazily instantiated.
|
|
*/
|
|
|
|
import { drizzle } from 'drizzle-orm/postgres-js';
|
|
import postgres from 'postgres';
|
|
import * as schema from './schema';
|
|
|
|
let db: ReturnType<typeof drizzle<typeof schema>> | null = null;
|
|
|
|
export function getDb(databaseUrl: string) {
|
|
if (!db) {
|
|
const client = postgres(databaseUrl, { max: 5 });
|
|
db = drizzle(client, { schema });
|
|
}
|
|
return db;
|
|
}
|
|
|
|
export type Database = ReturnType<typeof getDb>;
|