Blueprint
News & crypto feeds
News APIs, combined feeds, and cron-fed pipelines.
Overview
News is served primarily under /api/news/*, backed by getNewsDataService in src/services/news-data.ts and types in src/types/news-data.ts. Middleware helpers in src/lib/news-data-middleware.ts provide fallback and sanitization (withFallback, sanitizeNewsItems).
Representative routes
| Path | Purpose |
|---|---|
GET /api/news/items | Paginated/filtered news items (category, tags, language, featured, priority, search, sort) |
GET /api/news/items/[uuid] | Single item |
GET /api/news/items family + home, all, articles, search, dual-language, chinese-crypto, newsflash-combined, binance-alpha, twitter, twitter/[identifier], channels, channels/[uuid], stats, health | Aggregations, feeds, and health checks |
Cron relationship
/api/cron/crypto-newsand related cron jobs (seecontent/docs/architecture/cron) ingest or refresh external/crypto content;/api/news/*is the read/query surface for the app UI and integrations.
Data flow
- Ingest pipelines (cron or admin) write to the news store.
- Clients call
GET /api/news/...with query params. - Service layer applies filters; middleware may attach fallbacks when upstream data is partial.
Key files
src/app/api/news/**/route.tssrc/services/news-data.tssrc/lib/news-data-middleware.ts
Dependencies
Environment
DATABASE_URL— read path is DB-backed (getNewsDataService).- RSS / third-party keys for ingestion live in cron and fetch code paths (see Cron), not always in the GET handlers.
Database (src/db/schema.ts)
news_items_cache,binance_alpha_news_cache,articles_cache,twitter_accounts_cache,channels_cache