-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathapp.js
More file actions
52 lines (47 loc) · 1.59 KB
/
app.js
File metadata and controls
52 lines (47 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* Module dependencies.
*/
var express = require('express'),
http = require('http'),
path = require('path'),
app = express(),
io = require('socket.io'),
_ = require('underscore'),
Backbone = require('backbone');
var mongoose = require('mongoose');
require('./config.js')(app, express, mongoose);
/**
* Network configuration.
*/
var server = http.createServer(app).listen(app.get('port'), function () {
console.log('Express server listening on port ' + app.get('port'));
});
var socketio = io.listen(server);
socketio.set('log level', 1);
/**
* App configuration.
*/
//Model
//Backbone model
var model = require('./app/models/Server.Measure.Model')(require('./app/models/Measure.Model')(Backbone));
var collection = new (require('./app/models/Measure.Collection')(Backbone,model));
//MongoDb model
var modelDb = require('./app/models/modelDB')(mongoose, model);
//
// Override Backbone.sync :
Backbone.sync = require('./app/controllers/backboneServerSync')(modelDb);
collection.fetch(); //Sync the collection with the db
//
//Views
//create a Backbone.ServerView
require('./app/networkView/ServerBackboneView')(Backbone, _);
//extend from Backbone.ServerView
new (require('./app/networkView/socketView')(socketio, Backbone, _))({collection: collection});
new (require('./app/networkView/apiView')(app, "/"+model.getCollectionName(), Backbone, _, model.getCategoriesMasks()))({collection: collection});
new (require('./app/networkView/scaleView')(app, _, Backbone))({collection: collection});
/**
* Routes configuration.
*/
//Client (index.html)
var client = require('./app/routes');
client.init(app);