-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
42 lines (34 loc) · 1008 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
33
34
35
36
37
38
39
40
41
42
var express = require('express');
var morgan = require('morgan');
var mongoose = require('mongoose');
var bodyParser = require('body-parser');
var ejs = require('ejs');
var engine = require('ejs-mate');
var session = require('express-session');
var cookieParser = require('cookie-parser');
// var flash = require('express-flash');
var config = require('./config');
var app = express();
var User = require('./models/list');
// Middleware
app.use(express.static(__dirname + '/public'));
app.use(morgan('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.use(cookieParser());
// app.use(flash());
app.engine('ejs', engine);
app.set('view engine', 'ejs');
mongoose.connect(config.db, function(err){
if(err){
console.log(err );
}else{
console.log("Database connected to "+config.db);
}
});
var mainRoutes = require('./routes/main');
app.use(mainRoutes);
app.listen(config.port, function(err){
if(err) throw err;
console.log("Server running..");
})