rss
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v111View latest version
This document explains the changes made during the refactoring to follow Val Town's recommended project structure.
- Before: Monolithic structure with
mod.ts
,pkg/
, andbuild.ts
- After: Clean separation with
backend/
,frontend/
, and dedicated files
mod.ts
- Replaced bybackend/services/rss.ts
build.ts
- Replaced byupdateFeeds.cron.ts
pkg/mod.ts
- Logic moved tobackend/services/rss.ts
pkg/template.tsx
- No longer needed (frontend handles rendering)
feeds.json
- Feed configuration (extracted from hardcoded array)backend/services/rss.ts
- RSS processing serviceupdateFeeds.cron.ts
- Scheduled feed updatesbackend/README.md
- Backend documentation
http.ts
- Now uses Hono framework with proper routingREADME.md
- Updated with new structure and usage
- // Old: Simple passthrough
- export default function (req: Request) {
- return tinyfeed.fetch(req);
- }
+ // New: Hono-based routing with proper error handling
+ const app = new Hono();
+ app.get("/api/data", async (c) => { ... });
+ export default app.fetch;
- // Old: unstorage with Val Town driver
- import valTownDriver from "https://esm.town/v/pomdtr/unstorage-driver/main.tsx";
- const storage = createStorage({ driver: valTownDriver({}) });
+ // New: Direct blob storage
+ import { blob } from "https://esm.town/v/std/blob";
+ await blob.setJSON("rss:app-data", data);
- // Old: Hardcoded in mod.ts
- feeds: [
- "https://blog.val.town/rss.xml",
- "https://blog.railway.com/rss.xml",
- // ... more feeds
- ]
+ // New: External JSON configuration
+ // feeds.json
+ [
+ "https://blog.val.town/rss.xml",
+ "https://blog.railway.com/rss.xml",
+ // ... more feeds
+ ]
- // Old: Manual build trigger
- // Run build.ts manually
+ // New: Automated cron job
+ // updateFeeds.cron.ts runs every 6 hours automatically
- Clear separation of concerns
- Backend services isolated from HTTP handling
- Configuration externalized for easy updates
- Comprehensive error boundaries
- Individual feed failures don't block others
- Proper HTTP status codes and responses
- Uses Hono framework for HTTP handling
- Proper static file serving with Val Town utilities
- Follows recommended directory structure
- Automatic scheduled updates
- Better API design
- Improved logging and monitoring
- ✅ Created
feeds.json
with feed configuration - ✅ Built
backend/services/rss.ts
with separated concerns - ✅ Refactored
http.ts
to use Hono framework - ✅ Created
updateFeeds.cron.ts
for automated updates - ✅ Updated documentation and README
- ✅ Cleaned up old files
- Review
feeds.json
- Verify all your feeds are included - Test the endpoints - Visit your app URL to ensure everything works
- Schedule the cron job - Set up
updateFeeds.cron.ts
to run every 6 hours
- Adjust cron frequency - Modify the schedule in
updateFeeds.cron.ts
- Add more feeds - Simply edit
feeds.json
- Customize UI - Modify React components in
frontend/
- Add API features - Extend routes in
http.ts
Data not loading?
- Run
updateFeeds.cron.ts
manually to populate initial data - Check blob storage keys are prefixed with
rss:
Feeds not updating?
- Verify cron job is scheduled and running
- Check console logs for feed fetch errors
Frontend not loading?
- Ensure static file serving is working
- Check that
frontend/index.html
exists
Check the following files for detailed information:
backend/README.md
- Backend service documentationREADME.md
- Overall project documentation- Console logs during cron job execution
- Feeds are now fetched in parallel for better performance
- Failed feeds don't block successful ones
- Results are cached in blob storage between updates
- Frontend loads data asynchronously for better UX
The refactoring is complete and your RSS aggregator now follows Val Town best practices while maintaining all existing functionality with improved reliability and maintainability.