How to Consume the Feed
Relevant source files
The following files were used as context for generating this wiki page:This project provides a consolidated news feed to help track ongoing projects, releases, and other relevant content within the Node.js community, as well as news about data breaches from various sources. The primary goal is to support news sites, blogs, and developers who need timely updates.
The feed is generated by collecting information from various sources, including GitHub releases, issues, discussions, and manual posts. This data is then processed and made available through several channels. This document outlines the different methods for consuming the generated news feed.
Sources: README.md:5-11, scripts/collect-retrospective.js, scripts/collect-releases.js, scripts/collect-issues.js, scripts/collect-discussions.js, scripts/collect-manual-posts.js
Consumption Methods
There are four primary ways to consume the news feed, catering to different use cases from automated parsing to casual reading.
| Method | Access Point | Format | Use Case |
|---|---|---|---|
| RSS Feed | https://nodejs.github.io/nodejs-news-feeder/feed.xml | XML | Automated parsing, feed readers, syndication. |
| Web Browser | https://nodejs.github.io/nodejs-news-feeder/ | HTML | Casual reading in a browser. |
| Terminal | curl command | Plain Text | Quick checks and scripting from the command line. |
| Slack | #nodejs-news-feeder channel | Slack Message | Real-time notifications within a Slack workspace. |
Sources: README.md:14-16, README.md:19-23, README.md:26-28
1. RSS Feed
The most direct way to consume the news is through the RSS feed. This is ideal for feed readers, automated scripts, or integrating the news into other websites and applications.
URL: https://nodejs.github.io/nodejs-news-feeder/feed.xml
Sources: README.md:15
RSS Feed Structure
The feed is a standard RSS 2.0 XML document. Each news item is contained within an <item> tag. The diagram below illustrates the structure of a single feed item.
This diagram shows the main elements within each <item> tag in feed.xml.
The key fields for each item are detailed below:
| Field | Description | Example |
|---|---|---|
title | The title of the news item. | Fuite de données chez Dailymotion |
description | The content of the news item, often wrapped in <![CDATA[...]]>. | <![CDATA[nom d'utilisateur, adresse email, Hachage des mots de passe</p>]]> |
pubDate | The publication date of the item. | Sat Oct 01 2016 02:00:00 GMT+0200 (heure d’été d’Europe centrale) |
link | A URL pointing to the original source or more details. | https//bonjourlafuite.eu.org/#Dailymotion-2016-10-01 |
guid | A unique identifier for the item, often the same as the link. | https://thehackernews.com/2016/12/dailymotion-video-hacked.html |
Sources: feed.xml, utils/index.js:115-126
A sample <item> from feed.xml:
<item>
<title>Fuite de données chez Dailymotion</title>
<description><![CDATA[nom d'utilisateur, adresse email, Hachage des mots de passe</p>]]></description>
<pubDate>Sat Oct 01 2016 02:00:00 GMT+0200 (heure d’été d’Europe centrale)</pubDate>
<link>https//bonjourlafuite.eu.org/#Dailymotion-2016-10-01</link>
<guid>https://thehackernews.com/2016/12/dailymotion-video-hacked.html</guid>
</item>
Sources: feed.xml:18-24
2. Web Browser
The news feed can be read directly in a web browser via a simple HTML page. This page is automatically generated from the feed.xml file.
URL: https://nodejs.github.io/nodejs-news-feeder/
Sources: README.md:26-28
Website Generation Process
The index.html page is built by the scripts/build-website.js script. This script parses the feed.xml file and uses an EJS template to render the HTML.
This flowchart shows how feed.xml is processed to generate the index.html website.
The script performs the following steps:
- Reads the content of
feed.xml. - Parses the XML content using
@ulisesgascon/rss-feed-parser. - Renders an EJS template (
templates/index.html.ejs) with the parsed items. - Writes the final rendered HTML to
index.html.
Sources: scripts/build-website.js:1-13, index.html
3. Terminal (cURL)
For quick access from the command line, you can use curl combined with other tools like grep and sed to fetch and format the latest news.
The following command fetches the RSS feed and extracts the title, link, and publication date for each item:
curl -s https://nodejs.github.io/nodejs-news-feeder/feed.xml | grep -E '(<title>|<link>|<pubDate>)' | sed 's/<[^>]*>//g' | sed 's/^[ \t]*//;s/[ \t]*$//'
This command pipeline:
curl -s: Silently fetches the content offeed.xml.grep -E '(<title>|<link>|<pubDate>)': Filters the lines to only include those containing<title>,<link>, or<pubDate>.sed 's/<[^>]*>//g': Removes all XML tags.sed 's/^[ \t]*//;s/[ \t]*$//': Trims leading and trailing whitespace from each line.
Sources: README.md:20-22
4. Manual Post Interface
The project includes a simple Express server that provides a web interface for adding and viewing "manual posts". These posts are stored in manual-posts.json and are later collected and injected into the main feed.xml. While primarily for content creation, this interface also allows for consumption of posts before they are published in the main feed.
To use this interface, you must run the server locally:
npm start
The server will be available at http://localhost:3000.
Sources: server.js:43-45, package.json:8
Local Server Endpoints
The server exposes a simple API to manage manual posts.
This sequence diagram illustrates the interactions between the user's browser, the local Express server, and the JSON file used for storage.
| Method | Endpoint | Description |
|---|---|---|
GET | / | Serves the add-post.html page, which provides a UI to add and view posts. |
GET | /api/posts | Returns a JSON array of all current posts from manual-posts.json. |
POST | /api/posts | Adds a new post to manual-posts.json. The request body should be a JSON object with title, description, link, and optional published_at. |
Sources: server.js:12-42, add-post.html:43-73
These manually added posts are then processed by scripts/collect-manual-posts.js and inserted into the main feed.xml during the build process.
Sources: scripts/collect-manual-posts.js:1-25