-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
59 lines (45 loc) · 1.51 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
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, http = require('http')
, path = require('path')
, stylus = require('stylus');
mongoose = require('mongoose');
var app = express();
// Error messages
defaultDBErrorMessage = "We are experiencing some database issues. Please try again later."
// all environments
app.set('port', process.env.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(require('stylus').middleware(__dirname + '/public'));
app.use(express.static(path.join(__dirname, 'public')));
// development only
if ('development' == app.get('env')) {
app.use(express.errorHandler());
}
app.get('/', routes.index);
app.get('/report', routes.submit);
app.get('/admin/regions', routes.regions);
app.get('/admin/reports', routes.reports);
app.get('/dial-up', routes.dialUp);
app.get('/feeds', routes.feeds);
app.get('/reports/:id', routes.regionReports);
// Post routes
app.post('/admin/regions/submit', routes.regionsSubmit);
app.post('/reports/submit', routes.reportSubmit)
http.createServer(app).listen(app.get('port'));
mongoose.connect('mongodb://localhost/landlines');
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function callback () {
console.log("MongoDB hooked up");
//Setting up DB Schemes
require('./config/schemas');
});