Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi Dave,
Great project! Really cool to see the NYT put a river on their home page, and now that they've done it everyone else probably will want to.
I've been wanting to play around with River4 for a while now, so I decided to give it a shot. I'm using a Digital Ocean droplet, so I wanted to see if I could use the River4.js script to also serve the index.html file, and with a few tweaks I was able to do.
In order to dynamically serve the user's river files, the server has to compare the pathname to each river file in the /rivers directory, and serve that file if there is a match. Since the pathname is going to be dynamic (/rivers/apple.js || /rivers/nytriver.js || /rivers/*.js), using a switch statement is difficult. The only way I could think of still using a switch statement was to use regex matching for the cases and then use switch(true). I thought this was overly complicated so I rewrote the router to use if/else statements.
The danger of relying on this setup is two-fold. First, it isn't likely to scale very well. The same process that is updating the feeds is also responsible for serving them. The process could get bogged down pretty easily if there was a lot of traffic.
If scale isn't an issue though, the other problem is that it introduces a single point of failure. If the node process crashes while updating a feed, users will no longer be able to access the site. On the other hand, if this script's role is simply to fetch feed updates and another server is responsible for serving the website, then if the node process crashes users will still be able to see the site, though a somewhat outdated version of it (depending on how long the node process stays down).
In any case, I don't expect to have either of the above issues on my personal river, since it's more for me than anyone else. I thought I'd share my code regardless, in case you find any of it helpful. I look forward to more of your hacks! I think you're on to something big here.
Amiably,
Ameen