-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
59 lines (41 loc) · 1.3 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
/**
* Created by andreistalbe on 1/23/16.
*/
// 3rd party module imports
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var cache = require('memory-cache');
// Instantiate APP
var app = express();
// Route imports
var indexRoute = require('./routes/index');
var customersRoute = require('./routes/customers');
var fileRoute = require('./routes/file');
// App module imports
var config = require('./config');
var database = require('./modules/database');
// Set app config
app.set('config', config);
app.set('database', database);
app.set('cache', cache);
// Set View Engine
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(cookieParser());
// Define route namespaces
app.use('/', indexRoute);
app.use('/customers', customersRoute);
app.use('/file', fileRoute);
database.ready(app, function(err){
if (err){
console.log("Could not establish MongoDB connection");
throw err;
}
app.listen(config.port || 3000, function () {
console.log('Retently example app listening on port', this.address().port);
console.log('===========================\n')
console.log('http://127.0.0.1:' + this.address().port);
console.log('\n===========================')
});
});