-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathdispatch.ts
More file actions
24 lines (23 loc) · 1.12 KB
/
dispatch.ts
File metadata and controls
24 lines (23 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { fetchAttentionVc } from "./attentionvc";
import { fetchGithubTrending } from "./github-trending";
import { fetchHackerNews } from "./hackernews";
import { fetchHuggingfacePapers } from "./huggingface-papers";
import { fetchLinuxDo } from "./linuxdo";
import { fetchRss } from "./rss";
import { fetchV2ex } from "./v2ex";
import type { RawArticle, SourceDef } from "./types";
/**
* Single dispatcher used by daily.ts, dry-run.ts, and the cron route.
* Add a new branch here when introducing a non-RSS fetcher.
*/
export async function fetchSource(source: SourceDef): Promise<RawArticle[]> {
if (source.id === "hackernews") return fetchHackerNews(source.id);
if (source.id === "github-trending") return fetchGithubTrending(source.id);
if (source.id === "v2ex-hot") return fetchV2ex(source.id);
if (source.id === "linuxdo") return fetchLinuxDo(source.id);
if (source.id === "attentionvc-ai") return fetchAttentionVc(source.id);
if (source.id === "huggingface-papers") return fetchHuggingfacePapers(source.id, source.keywords);
return fetchRss(source.id, source.url, source.category, {
useCurl: source.useCurl,
});
}