| 3 | dotenv.config(); |
| 4 | |
| 5 | export async function getCronSources(): Promise<{ identifier: string }[]> { |
| 6 | try { |
| 7 | console.log("Fetching sources..."); |
| 8 | |
| 9 | // Check for required API keys |
| 10 | const hasXApiKey = !!process.env.X_API_BEARER_TOKEN; |
| 11 | const hasFirecrawlKey = !!process.env.FIRECRAWL_API_KEY; |
| 12 | |
| 13 | // Define sources based on available API keys |
| 14 | const sources: { identifier: string }[] = [ |
| 15 | ...(hasFirecrawlKey |
| 16 | ? [ |
| 17 | { identifier: "https://www.firecrawl.dev/blog" }, |
| 18 | { identifier: "https://openai.com/news/" }, |
| 19 | { identifier: "https://www.anthropic.com/news" }, |
| 20 | { identifier: "https://news.ycombinator.com/" }, |
| 21 | { |
| 22 | identifier: |
| 23 | "https://www.reuters.com/technology/artificial-intelligence/", |
| 24 | }, |
| 25 | { identifier: "https://simonwillison.net/" }, |
| 26 | { identifier: "https://buttondown.com/ainews/archive/" }, |
| 27 | ] |
| 28 | : []), |
| 29 | ...(hasXApiKey ? [{ identifier: "https://x.com/skirano" }] : []), |
| 30 | ]; |
| 31 | |
| 32 | // Return the full objects instead of mapping to strings |
| 33 | return sources; |
| 34 | } catch (error) { |
| 35 | console.error(error); |
| 36 | return []; |
| 37 | } |
| 38 | } |