A simple node server that checks if a new sign up form is available and redirects to it.
My fiance, a vet student, was trying to sign up for a volunteer opportunity at PAWS with a limited number of opennings. Every week they release a new Google form, but whenever my fiance clicks on on the link the sign up is always already full. It seems to fill up within 1 minute of the post with the link.
To give my fiance a chance to sign up I created a simple node server that checks the RSS feed of the Wordpress site where the sign up form is posted and redirects to the form when it becomes available. It's deployed to Azure and can be triggered from any browser. Once triggered, the node server will check the RSS feed every half second for 20 minutes, looking for any post from the current day that conatins the appropriate string. Then, it parses that post looking for the sign up link and redirects the client browser to the form once it's found.
- Express - framework for simple server routing.
- Socket.io - real time communication between the server and the client web page so that I can update the web page with the status of the running script.
- Feedparser - RSS feed parsing.
- Cheerio - used for navigating through the HTML of the RSS posts and extracting the sign up form link.
- Pug - simple template engine for displaying the HTML on the client.
- Clone the repo.
- Run
npm install
in the repo folder. - Run
node index.js
to start the server. - Open up the browser and navigate to
http://localhost:3000
.
This app is configured to automatically deploy the branch deploy
to Azure.
When deploying to Azure the port that Express is litening to need to be set to process.env.port
for things to work properly. I wasted a bunch of time because I forgot about this.
app.listen(process.env.port || 3000, function () {
console.log('Server is running...');
});
For some reason Server-Sent Events are not properly working in Azure node deployments out of the box. There's an issue open on github that explains the work around:
- Go to you app service in the Azure Portal.
- Find and open the
App Service Editor
. - Open
web.config
and addresponseBufferLimit="0"
so that your handlers looks like this:
<handlers>
<!-- Indicates that the server.js file is a node.js site to be handled by the iisnode module -->
<add name="iisnode" path="index.js" verb="*" modules="iisnode" responseBufferLimit="0" />
</handlers>