-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
32 lines (27 loc) · 876 Bytes
/
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
var express = require("express"),
path = require("path"),
bodyParser = require('body-parser'),
mongoose = require('mongoose'), //ADD THIS
app = express();
/* Database Connection ADD THIS */
mongoose.Promise = global.Promise;
require('./config/mongoose.js');
mongoose.connect('mongodb://localhost/surveys', function(err) {
if (err) {
console.log('Could not connect to mongodb...');
} else {
console.log('Successfully connected to mongodb...');
}
});
/*********************************/
app.use(bodyParser.urlencoded({ extended: true}));
app.use(express.static(path.join(__dirname, "./static")));
app.set('views', path.join(__dirname, "./views"));
app.set('view engine', 'ejs');
app.get('/', (req,res) => {
res.render("index");
});
require('./routes/index.js')(app);
app.listen(8000, () => {
console.log("Listening to port 8000");
});