Nov. 13, 2016
I spent this weekend learning more about two very popular web development tools, Express and Heroku. The project I was working on was an image API using Express hosted on Heroku.
Here are my thoughts.
I used Express.js with socket.io before to create chat rooms for an android app. I was amazed at how the whole back end was written in about 20 lines of code. In this project wanted a super simple web framework for the API so I went for Node.
Pros:
var express = require('express');
var app = express();
...
var server = app.listen(8080, function () {
var host = server.address().address
var port = server.address().port
console.log("Listening at http://%s:%s", host, port)
})
Cons:
I deployed my project on Heroku. The setup was okay, but could have been smoother. I forgot to provide a package.json file, which ended up causing deployment to not recognize the app as a Node.js. The bad thing is that Heroku did not tell me that and I had to look up the error on my own. They need more useful error messages.
Since my code was no longer in development, I had to change it to use Heroku's ports:
var server = app.listen(process.env.PORT, function () {
var host = server.address().address
var port = server.address().port
console.log("Express server listening on port %d in %s mode", this.address().port, app.settings.env);
})
Everything went pretty well after those two changes. Heroku provides nice usage graphs. It was easy to pick up and I got to deploy my application really quickly without having to do any Linux level configurations. You can also set your code to deploy on new pushes which is convenient. What I'm surprised to see was that you can deploy code from Dropbox. Git > Dropbox.
What I really appreciate is the fact that I didn't have to pay anything or sign up with my billing info to get hands-on experience with this service. I'm looking at you AWS.
You can try out the API by visiting https://memedb.herokuapp.com/emotes/Kappa. You can try it out with Kappa and 4head!