Backbone Boilerplates

Developers have been reqesting examples of how to integrate Backbone.js with a number of different technology stacks. Two common requests have included Node.js and Sinatra/Ruby but there have been a number of others too. To help with this, you can find three of these integration examples below. There are more to come soon.

Option 1

Node.js

Express

Mongoose

MongoDB

Option 2

Jade

Node.js

Express

Mongoose

MongoDB

Option 3

Haml

Ruby

Sinatra

MongoDB

Instructions

All boilerplates are based on the excellent HTML5 Boilerplate and use a MongoDB backend.

Please ensure you have MongoDB installed and running prior to running any of the boilerplates.

MongoDB Setup

Once you've downloaded MongoDB, you'll need to complete two steps to get things up and running.

Data directories

MongoDB stores data in the bin/data/db folder but won't actually create this directory for you. Navigate to where you've downloaded and extracted Mongo and run the following from terminal:

sudo mkdir -p /data/db/
sudo chown `id -u` /data/db

Running and connecting to your server

Once this is done, open up two terminal windows.

In the first, cd to your MongoDB bin directory or type in the complete path to it. You'll need to start mongod.

$ ./bin/mongod

Next, in the second terminal, start the mongo shell which will connect up to localhost by default.

$ ./bin/mongo

That's it!.

Options 1 and 2

The only main difference between Options 1 and 2 is that Option 2 uses Jade (the Node templating engine) whilst Option 1 allows you to use regular HTML for your layouts. Both run on Node.js with Express and Mongoose.

Note: The Haml layout files for Option 3 can be found in the /views folder.

Thanks and future plans

I would like to extend my thanks to Chris Riccomini for his Weapon of Choice project. It served as the inspiration and a partial base for this repo, which I plan on expanding to cover other setups such as Backbone + Socket.io, Backbone + SocketStream and more.

Backbone Boilerplates is a project that was created to stub further examples for my creative-commons book Backbone Fundamentals. The idea is to create further applications for the yet to be written RESTful/backend sections of the book, which have been repeatedly requested on the issue tracker.

If you notice any major issues, please let me know about them and I'll do my best to fix them up right away.