A Node.js skeleton using Express, Mongoose and Coffeescript.
CoffeeScript JavaScript Other
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app
assets
bin
config
.gitignore
Gruntfile.coffee
Procfile
README.md
package.json
server.js

README.md

A Node.js skeleton using Express, Mongoose and Coffeescript

Do you find yourself looking around for Node.js conventions and how to structure your Node application? Firstly, this skeleton shows how a Node.js web application can be structured properly. Secondly, it demonstrates how some popular modules that provide basic functionalities for your app can be used.

I haven't been using Node.js for long but here I've gathered some of the good things I have come across on my short journey. Hope this can help you get started.

You can find this demo running on Heroku: http://form5-node-skeleton.herokuapp.com/

Log in using admin/admin to manage users & articles.

Install

Assuming you have Node.js and npm installed, to get started developing using this skeleton, run:

	$ git clone git://github.com/olafurnielsen/form5-node-express-mongoose-coffeescript.git
	$ npm install
	$ bin/devserver

Open http://localhost:3000/ in your browser.

What does this skeleton provide you with?

  • A good way to structure your Express.js application.
  • Object modeling for MongoDB using Mongoose.
  • Passport.js for user authentication.
  • Twitter Bootstrap, to jumpstart your UI development.
  • connect-assets for serving CSS, Javascript and images to the client supporting Coffeescript and LESS on the fly.
  • connect-flash for helpful error/notice messages.
  • connect-mongo for persistent session storage.
  • Coffeescript linting using Grunt.
  • node-dev, an awesome development tool for Node.js that automatically restarts your node process when a script is modified. It also has useful growl notifications:

Screenshot

And much more...

File structure

-app/
  |--controllers/
  |--models/
  |--views/
  |__helpers/ (template helper functions)
-config/
  |--routes.coffee
  |--environment.coffee
  |--passport.coffee (auth config)
  |--express.coffee (express.js config)
  |--middlewares/ (custom middlewares)
-assets/ (Client side assets)
  |--css/ (supports LESS)
  |--js/ (supports Coffescript)
  |--img/
-bin/
  |__devserver (Shell script for firing up node-dev)
--server.js

Inspiration and further reading

This skeleton is heavily based on nodejs-express-mongoose-demo but it uses Coffeescript instead of standard javascript and implements various other modules which I think are really useful when developing an Express.js application.

Madhums - Breaking down app.js file - nodejs, express, mongoose

Stack Overflow - Node.js & Express.js: Breaking up the app.js file