This is the Build a Blog Aggregator in TypeScript project from Boot.dev.
A command-line RSS feed aggregator that allows you to follow and read posts from your favorite blogs, news sites, and podcasts, all from your terminal.
- Subscribe to RSS feeds from across the internet
- Multi-user support on a single device
- Automatic feed aggregation in the background
- Browse posts from feeds you follow
- Store posts in PostgreSQL for offline reading
- Follow/unfollow specific feeds
Before running Gator, you'll need:
- Node.js v22.15.0+ - Install via NVM
- PostgreSQL 16+ - Download here
- npm - Comes with Node.js
-
Clone the repository
git clone https://github.com/mmert9008/typescriptBlogAggregator cd gator -
Install Node.js with NVM
nvm use
-
Install dependencies
npm install
-
Set up PostgreSQL
Start PostgreSQL on macOS:
brew services start postgresql@16
Start PostgreSQL on Linux:
sudo service postgresql start
Create the database on macOS:
psql postgres
Create the database on Linux:
sudo -u postgres psql
In psql:
CREATE DATABASE gator; \q
-
Create the config file
Create
~/.gatorconfig.jsonin your home directory:{ "db_url": "postgres://username:password@localhost:5432/gator?sslmode=disable" }Replace
usernameandpasswordwith your PostgreSQL credentials.Example for macOS (no password):
{ "db_url": "postgres://yourusername:@localhost:5432/gator?sslmode=disable" }Example for Linux:
{ "db_url": "postgres://postgres:postgres@localhost:5432/gator?sslmode=disable" } -
Run database migrations
npm run generate npm run migrate
Register a new user
npm run start register <username>Login as a user
npm run start login <username>List all users
npm run start usersAdd a new feed
npm run start addfeed "<feed-name>" "<feed-url>"Example:
npm run start addfeed "Hacker News" "https://news.ycombinator.com/rss"List all feeds
npm run start feedsFollow a feed
npm run start follow "<feed-url>"Unfollow a feed
npm run start unfollow "<feed-url>"List feeds you're following
npm run start followingBrowse posts from feeds you follow
npm run start browse [limit]Examples:
npm run start browse
npm run start browse 10Run the aggregator (background service)
npm run start agg <time-between-requests>The aggregator continuously fetches new posts from all feeds in the database.
Time format examples:
1s- every second30s- every 30 seconds1m- every minute5m- every 5 minutes1h- every hour
Example:
npm run start agg 1mPress Ctrl+C to stop the aggregator.
Note: Be respectful of servers - don't set the interval too low. A reasonable interval is 1-5 minutes.
Reset the database
npm run start resetThis deletes all users, feeds, and posts.
npm run start register alice
npm run start addfeed "TechCrunch" "https://techcrunch.com/feed/"
npm run start addfeed "Hacker News" "https://news.ycombinator.com/rss"
npm run start addfeed "Boot.dev Blog" "https://blog.boot.dev/index.xml"
npm run start agg 1m
npm run start browse 5
npm run start feeds
npm run start follow "<feed-url>"
npm run start followingHere are some feeds to get started:
-
Tech News
- TechCrunch:
https://techcrunch.com/feed/ - Hacker News:
https://news.ycombinator.com/rss - The Verge:
https://www.theverge.com/rss/index.xml
- TechCrunch:
-
Programming
- Boot.dev Blog:
https://blog.boot.dev/index.xml - Dev.to:
https://dev.to/feed
- Boot.dev Blog:
-
General News
- BBC News:
https://feeds.bbci.co.uk/news/rss.xml - NPR:
https://feeds.npr.org/1001/rss.xml
- BBC News:
gator/
├── src/
│ ├── index.ts # Main CLI entry point
│ ├── config.ts # Config file management
│ ├── lib/
│ │ ├── rss.ts # RSS feed parser
│ │ └── db/
│ │ ├── index.ts # Database connection
│ │ ├── schema.ts # Database schema
│ │ ├── queries/
│ │ │ ├── users.ts # User queries
│ │ │ ├── feeds.ts # Feed queries
│ │ │ └── posts.ts # Post queries
│ │ └── migrations/ # Database migrations
├── drizzle.config.ts # Drizzle ORM config
├── tsconfig.json # TypeScript config
├── package.json # Dependencies
└── .gatorconfig.json # User config (in home directory)
- TypeScript - Type-safe JavaScript
- PostgreSQL - Relational database
- Drizzle ORM - Lightweight TypeScript ORM
- fast-xml-parser - RSS feed parsing
- Node.js - Runtime environment
Database connection errors
- Verify PostgreSQL is running
- Check your connection string in
~/.gatorconfig.json - Ensure the database exists
Migration errors
- Run
npm run generateto create migration files - Run
npm run migrateto apply them
No posts showing up
- Make sure the aggregator is running:
npm run start agg 1m - Wait a minute for it to fetch posts
- Ensure you're following feeds:
npm run start following