My first live Meteor app

19 December 2015

I’ve been busy the last couple of months building a user interface for @ausglamblogs. You may recall I created this Twitter bot in July using nodejs. I’ve now created a web interface allowing people to add their blogs to the bot feed, and brought the whole thing inside Meteor.

I was never entirely happy with the initial bot, because it relied on me manually adding blog feeds to the list. Mike Jones asked if I could use Twitter accounts instead of names for the authors when their posts were tweeted. I thought about a few different ways to do it, and ultimately decided that it was a good chance to make a simple app in Meteor.

It was a pretty fun process. I’ve made a couple of other things with Meteor, but this is the first one I’ve deployed to a server and out into the world. I discovered a few things:

Writing an app in meteor that does more or less what you want is fairly easy

It only took about a week of evenings and weekends for me to go from nothing to a working app. It’s a pretty simple app, but given I only started learning JavaScript and Meteor this year, and I’m doing it in my spare time, this is pretty fast.

Making sure your app doesn’t do things you don’t want it to do is hard

As I do more coding, I’m starting to appreciate why there is so much buggy software, and why there are so many security breaches. It took twice as long to set up error-checking and validation rules as it did to write the guts of the app - that is, I spent twice as long making sure the app didn’t do certain things as I spent making sure it did do things. Most of the work in both of these areas was in the admin backend that probably only two or three people will ever see, but it’s important to get right.

Even then, I missed a bunch of stuff. I’ve already had to bug-fix the app twice, and it’s been running for less than a fortnight. There is also a long list of less serious issues I’d like to address in future.

LetsEncrypt is going to revolutionise HTTPS

I just happened to be about to go live at the same time LetsEncrypt finally launched their public beta. Using their tool with nginx was super easy, even though I’d never done anything with nginx before.

Deploying a Meteor app is much more complicated than testing it on your own machine or running a simple nodejs script.

This should have been obvious, but it turned into a hellish fortnight of pain. I tried to follow the official Digital Ocean guide, but it didn’t work out for me. The error messages I got were obtuse, and though I scoured Stack Exchange, nobody else seemed to be experience my combination of problems. Eventually I realised that I was missing a Meteor package (Request), which for some reason didn’t matter when I was running in development mode on my laptop, but did matter very much when I was trying to deploy to a server. By the time I figured this out, I’d made so many changes to my server environment that Meteor Up just wouldn’t work. In the end I had to start with a fresh server and Meteor Up, and finally everything worked.

Twitter are brutal if they catch you breaking their app rules

Once I got the app deployed, I was so excited that I added all 49 feeds at once, and gleefully clicked ‘approve’ on them all in quick succession. Stupid idea.

I wrote the app to tweet “I just added [blog] by [author] to my feed” as soon as it was approved. But when you automate the process and send 49 tweets in less than a minute, Twitter’s system blocks your app. To get it unblocked you have to explain to them in detail how you fixed your app so it doesn’t break their rules again. It took me another week to fix it (it now tweets the announcements one at a time as part of the 10 minute loop), and then get Twitter to unblock it.

It’s easy to make stupid mistakes

I already knew this one, but was reminded yet again after I’d finally redeployed with the changes, and Twitter had unblocked it. Everything looked good until I suddenly realised that I had a setting to say whether blog feeds were approved, but the app didn’t actually check that before running through the list and tweeting new posts. So, I guess we’re on version 0.1.02.

Even when everything possible has gone wrong during the process, coding still feels like you can do magic

It’s pretty amazing to write something from scratch and then see it working more or less as you intended. I’m definitely going to make some more stuff, and keep improving the glamblogs app.

See the app at glamblogs.newcardigan.org.
See the bot at @ausglamblogs.
See the code at Gitlab.
Learn JavaScript with Jon Duckett’s book
Learn Meteor at Meteor Tips