const parser = new Parser();
const app = express();
+const FEED_REFRESH_RATE = parseInt(process.env.FEED_REFRESH_RATE || '0');
+
function contentExtractor(feed: FeedSchema, item): string {
let str = '';
switch(feed.title) {
const feedsToQuery = completeFeedList.filter(feed => {
// only update every 5 minutes
- return Date.now() > (feed.updated_at + (1000 * 60 * 5));
+ return Math.floor(Date.now()/1000) > (feed.updated_at + (1000 * 60 * FEED_REFRESH_RATE));
});
console.log(`Querying ${feedsToQuery.length} feeds`);
}
}
- setTimeout(queryFeeds, (Number(process.env.FEED_REFRESH_RATE) + 1) * 1000 * 60);
+ // we query every minute, incase new feeds were added
+ // but we only check feeds that havne't been checked
+ // in the last 5 minutes (based on FEED_REFRESH_RATE)
+ setTimeout(queryFeeds, 1000 * 60);
}
app.use(express.static(join(__dirname, 'public')));
app.listen(process.env.API_PORT, () => {
console.log(`Listening on port ${process.env.API_PORT}`);
- console.log(`Feed refresh rate: ${(Number(process.env.FEED_REFRESH_RATE) + 1)}m`);
+ console.log(`Feed refresh rate: ${FEED_REFRESH_RATE}m`);
queryFeeds();
});