Simple Login Example built with Node.js (Express), Eco and CoffeeScript

Posted on December 15, 2011

After deciding to port an ActionScript Cafe Townsend example into JavaScript the first step was to build a simple login example.

It is built with Node.js (Express) on server-side and it uses Eco templates to render views on client-side. Most of code is written in CoffeeScript.

Screen shot

Screen shot of simple login example

Random notes

Here are some notes or tips based on issues I ran into writing this app:

CoffeeScript + Express

  • Use cupcake to build a skeleton of your CoffeeScript / Express app as easy as possible

Eco templates

  • Don't forget to declare any value sent from server using a @ within the Eco template, e.g <%- %> It took me some time to find and fix such a typo.

Deploying to Heroku

  • To run an app written in CoffeeScript on Heroku you have to point the and not app.js as a command to the Procfile as follow: web: coffee
  • Run heroku ps to check if the app has been crashed or not.
  • In case of crashing check heroku logs for very helpful detailes
  • Heroku may not run the version of Node.js you have installed on your local machine. At the moment of writing this post Heroku is running v.0.4.7., not the latest version of Node.js v.0.6.5. If you have to downgrade your local version you will find here a short instruction.
  • To rename your subdomain using by Heroku you have to rename the app itself as follow: heroku rename newname --app oldname. After that you may have to repoint your git repository as well: git remote rm heroku and git remote add heroku
  • Instead of using an hardcoded value for a port check the PORT environment variable in your as well port = process.env.PORT or 9294 Because Heroku tells the app which port is listen to.* Last but not least: Heroku has published an excellent article: "Getting Started with Node.js on Heroku/Cedar"

Source code

You will find all source code and its build instruction at GitHub

Have fun!


Any feedback?

comments powered by Disqus