-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
68 lines (50 loc) · 1.37 KB
/
app.js
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
53
54
55
56
57
58
59
60
61
62
63
64
65
var express = require('express');
var app = module.exports = express();
var resource;
app.config = require('./config');
var http=require('http');
app.configure(function(){
app.set('port',3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use (express.logger("dev"));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(__dirname + '/public'));
});
/*
database connection
*/
var mongodb = require('mongodb')
mongodb.MongoClient.connect(app.config.database.uri, function (error, db) {
if(error) {
console.log("Error connecting to database: " + error.toString().replace("Error: ",""));
}
else {
console.log("Connected to DB " + 'mongodb://localhost:27017/ipdb');
app.db = db;
app.models = {
IpModel : require('./lib/models/ip')(app)
};
app.controllers = {
IpController : require('./lib/controllers/ips')(app)
};
/*
routes
*/
routes = require('./routes')(app);
/*
starts the pinging service
*/
resource = require('./resources/ping')(app)
resource.pingLoop;
/*
server
*/
var port = process.env.PORT || 3000;
app.listen(port, function(){
console.log("Express server listening on port %d in %s mode", 3000, app.settings.env);
});
}
});