-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
executable file
·66 lines (50 loc) · 1.33 KB
/
server.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
66
var express = require('express'),
app = express();
var bodyParser = require('body-parser');
var fs = require('fs');
var multer = require('multer')
// configure Express
app.use(multer({
dest: './uploads/'
}))
var html_dir = __dirname + '/public';
app.use(express.static(html_dir));
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json());
app.use(express.cookieParser());
app.use(express.session({
secret: '1234567890QWERTY'
}));
// Mongo DB connection
var mongoose = require('mongoose');
var dbConnection;
if (process.argv[2] == 'local')
dbConnection = mongoose.connect('mongodb://localhost/TimeSheetDB');
else
dbConnection = mongoose.connect('mongodb://root:FbVQsj0Zx2LW@localhost/admin');
// User API
var userApi = require('./routes/userRoutes')(app, {
'mongoose': mongoose,
'db': dbConnection
});
// TimeSheet API
var timeSheetApi = require('./routes/timeSheetRoutes')(app, {
'mongoose': mongoose,
'db': dbConnection
});
// FIleContent API
var fileContentApi = require('./routes/fileContentRoutes')(app, {
'mongoose': mongoose,
'db': dbConnection
});
// Common API
var commonApi = require('./routes/commonRoutes')(app, {
'mongoose': mongoose,
'db': dbConnection
});
// Binding port
var server = app.listen(8000, function() {
console.log('listening on port %d', server.address().port);
});