Skip to content

Instantly share code, notes, and snippets.

@liammclennan
Created June 19, 2012 22:25
Show Gist options
  • Save liammclennan/2956872 to your computer and use it in GitHub Desktop.
Save liammclennan/2956872 to your computer and use it in GitHub Desktop.
Zero Configuration Backbone.js Server

Backbone-Server is a zero configuration backbone.js server. For teaching, experimentation and debugging it provides an instant server-side for backbone.js apps. Once installed it is started like so:

node rasterver.js

Then from the client you can work with models:

var Person = Backbone.Model.extend({}),
People = Backbone.Collection.extend({
    model: Person,
    url: 'http://localhost:3000/People'
}),
people = new People();
people.add({name: 'John', age: 25});
people.at(0).save();

That is enough to get the model saved to the server. Fetch, update and destroy all work properly.

The server stores the collection data in memory, so when the server stops the data is lost. This is not a good choice for production.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment