Coder Social home page Coder Social logo

backbone-server's Introduction

backbone-server

Implements an in-memory server for Backbone.js http://documentcloud.github.com/backbone/#Sync

This project is a teaching aid. It provides an out-of-the-box server that Backbone.js models can sync with.

It uses the CORS headers to allow cross-origin requests.

Usage

  1. Clone the repository

  2. Install node.js

  3. Install the dependencies with npm install

  4. Start the server with node rasterver.js

  5. Configure your models / collections with urls in the form http://localhost:3002/[collectionname]

Examples

Create a new 'people' resource

curl -vX POST [{"name":"X POST http://withouttheloop.com:3002/people -H 'content-type: application/json' -d '{"name":"Liam", "age": 72}'

< HTTP/1.1 200 OK
< X-Powered-By: Express
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: GET,PUT,POST,DELETE
< Access-Control-Allow-Headers: Content-Type
< Content-Type: application/json; charset=utf-8
< Content-Length: 8
< Date: Tue, 29 Jan 2013 07:19:00 GMT
< Connection: keep-alive
< 
* Connection #0 to host withouttheloop.com left intact
* Closing connection #0
{"id":0}

Read the collection

curl -v http://withouttheloop.com:3002/people

< HTTP/1.1 200 OK
< X-Powered-By: Express
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: GET,PUT,POST,DELETE
< Access-Control-Allow-Headers: Content-Type
< Content-Type: application/json; charset=utf-8
< Content-Length: 65
< Date: Tue, 29 Jan 2013 07:20:57 GMT
< Connection: keep-alive
< 
* Connection #0 to host withouttheloop.com left intact
* Closing connection #0
[{"name":"Liam","age":72,"id":0}

P.S.

For truly zero-config usage I run a hosted instance of backbone-server at http://withouttheloop.com:3002. Set your model's url to http://withouttheloop.com:3002/[some unique collection id] and it will work magically. I do occassionally restart the service so not recommended for production. ;)

backbone-server's People

Contributors

alexbeletsky avatar liammclennan avatar tbranyen avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.