Simple Login Example built with Node.js (Express), Eco and CoffeeScript
Posted on December 15, 2011
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.
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
- Don't forget to declare any value sent from server using a
@within the Eco template, e.g
<%- @user.name %>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
app.jsas a command to the Procfile as follow:
web: coffee app.coffee
heroku psto check if the app has been crashed or not.
- In case of crashing check
heroku logsfor 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 herokuand
git remote add heroku firstname.lastname@example.org:newname.git
- Instead of using an hardcoded value for a port check the PORT environment variable in your app.coffee as well
port = process.env.PORT or 9294Because 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"
You will find all source code and its build instruction at GitHub