|
1 | 1 | import "dotenv/config"; |
2 | | -import { FeedConfig } from "./types.js"; |
3 | 2 |
|
4 | 3 | // Environment variables validation |
5 | 4 | const REQUIRED_ENV_VARS = ["API_SECRET"]; |
@@ -46,49 +45,3 @@ export const API_SECRET = process.env.API_SECRET!; |
46 | 45 | export const ALLOWED_ORIGINS = process.env.ALLOWED_ORIGINS |
47 | 46 | ? process.env.ALLOWED_ORIGINS.split(",") |
48 | 47 | : ["*"]; |
49 | | - |
50 | | -// Default feed ID - since we're focusing on a single feed |
51 | | -export const DEFAULT_FEED_ID = "main"; |
52 | | - |
53 | | -// Default configuration |
54 | | -const DEFAULT_CONFIG: FeedConfig = { |
55 | | - id: DEFAULT_FEED_ID, |
56 | | - title: "Default RSS Feed", |
57 | | - description: "A feed of curated content", |
58 | | - siteUrl: "https://example.com", |
59 | | - copyright: "test", |
60 | | - language: "en", |
61 | | - maxItems: 100, |
62 | | - image: "https://example.com/logo.png", |
63 | | - author: { name: "Feed Author", email: "author@example.com" }, |
64 | | -}; |
65 | | - |
66 | | -let currentConfig: FeedConfig | null = null; |
67 | | - |
68 | | -// Set feed configuration |
69 | | -export function setFeedConfig(config: FeedConfig): void { |
70 | | - config.id = DEFAULT_FEED_ID; |
71 | | - |
72 | | - // Set default values for optional fields if not provided |
73 | | - config.title = config.title || DEFAULT_CONFIG.title; |
74 | | - config.description = config.description || DEFAULT_CONFIG.description; |
75 | | - config.siteUrl = config.siteUrl || DEFAULT_CONFIG.siteUrl; |
76 | | - |
77 | | - // Ensure maxItems is always a positive number |
78 | | - config.maxItems = |
79 | | - typeof config.maxItems === "number" && config.maxItems > 0 |
80 | | - ? config.maxItems |
81 | | - : DEFAULT_CONFIG.maxItems; |
82 | | - |
83 | | - config.language = config.language || DEFAULT_CONFIG.language; |
84 | | - |
85 | | - // Update the in-memory configuration |
86 | | - currentConfig = config; |
87 | | - console.log("Updated feed configuration"); |
88 | | -} |
89 | | - |
90 | | -// Get the current feed configuration |
91 | | -export const getFeedConfig = (): FeedConfig => { |
92 | | - const config = currentConfig || DEFAULT_CONFIG; |
93 | | - return JSON.parse(JSON.stringify(config)) as FeedConfig; |
94 | | -}; |
0 commit comments