UNPKG

663 BJavaScriptView Raw
1// Name : Example Backbone Server
2// Author : Nate Hunzaker
3// License : MIT
4
5require('../lib/backbone-server');
6
7//-- 1. Create Backbone.Server
8App = new Backbone.Server({
9 'port' : 9000,
10 'socketio' : true,
11
12 // Database Config
13 'database' : {
14 'adapter' : 'mongo',
15 'location' : 'mongodb://localhost/example_db'
16 }
17});
18
19//-- 2. Require Modules
20App.load('app/routes');
21App.load('app/models');
22
23
24//-- 3. Collections
25articles = new Articles().fetch();
26
27
28//-- 4. Socket.IO Events
29
30App.bind('connection', function() {
31
32 App.send('updateDB', articles.toJSON());
33
34});
35
36
37//-- 6. Start Server
38App.start();
\No newline at end of file