-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
123 lines (105 loc) · 3.35 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// var express = require('express');
// var app = express();
//
// var bodyParser = require('body-parser');
// app.use(bodyParser.json());
// app.use(bodyParser.urlencoded({ extended: true }));
//
// // configure a public directory to host static content
// app.use(express.static(__dirname + '/public'));
//
// require ("./test/app.js")(app);
//
// var port = process.env.PORT || 3000;
//
// app.listen(port);
// var express = require('express');
// var app = express();
//
// var bodyParser = require('body-parser');
// app.use(bodyParser.json());
// app.use(bodyParser.urlencoded({ extended: true }));
// app.set('view engine', 'ejs');
// // configure a public directory to host static content
// app.use(express.static(__dirname + '/public'));
//
// require ("./test/app.js")(app);
// require ("./assignment/app.js")(app);
//
// var port = process.env.PORT || 3000;
//
// app.listen(port);
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
var passport = require('passport');
var cookieParser = require('cookie-parser');
var session = require('express-session');
app.use(session({
secret: process.env.SECRET,
resave: true,
saveUninitialized: true
}));
app.use(cookieParser());
app.use(passport.initialize());
app.use(passport.session());
app.set('view engine', 'ejs');
// configure a project directory to host static content
app.use(express.static(__dirname + '/public'));
require ("./test/app.js")(app);
// require("./assignment/app")(app);
require ("./server/app")(app);
console.log("Starting Server...");
var connectionString = 'mongodb://127.0.0.1:27017/bhadada-himtanaya-webdev';
if(process.env.MLAB_USERNAME) {
connectionString = process.env.MLAB_USERNAME + ":" +
process.env.MLAB_PASSWORD + "@" +
process.env.MLAB_HOST + ':' +
process.env.MLAB_PORT + '/' +
process.env.MLAB_APP_NAME;
}
var mongoose = require("mongoose");
mongoose.Promise = require('q').Promise;
mongoose.connect(connectionString);
console.log('Server running at http://localhost:3000');
var port = process.env.PORT || 3000;
app.listen(port);
// var app = require('./express');
// var bodyParser = require('body-parser');
// var passport = require('passport');
// var cookieParser = require('cookie-parser');
// var session = require('express-session');
//
// app.use(bodyParser.json()); // for parsing application/json
// app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
//
// app.use(cookieParser());
// app.use(session({
// secret: "put some text here",
// // secret: process.env.SESSION_SECRET, //Store it in process.env.SESSION_SECRET
// resave: true,
// saveUninitialized: true
// }));
// // app.use(session({ secret: "put some text here" }));
// app.use(passport.initialize());
// app.use(passport.session());
//
// app.set('view engine', 'ejs');
// // require('./utilities/filelist');
//
// app.use(app.express.static(__dirname + '/public'));
//
// // require('./assignment/app');
// require ("./test/app.js")(app);
// require('./project/app')(app);
//
// // require('./assignment/graduates/app');
//
// // app.listen(process.env.PORT || 3000);
//
// console.log('Server running at http://localhost:3000');
// var port = process.env.PORT || 3000;
//
// app.listen(port);