-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
51 lines (45 loc) · 1.05 KB
/
index.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
/**
* MODULE DEPENDENCIES
*/
var express = require('express');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var session = require('express-session');
var mongoose = require('mongoose');
/**
* Create Express Server
*/
var app = express();
/**
* MongoDB connection
*/
mongoose.connect("mongodb://localhost/todo");
mongoose.connection.on("error", function(err) {
console.error(err);
console.error("MongoDB Connection Error.");
});
/**
* Middleware
*/
app.use(cookieParser())
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
app.use(session({
secret: "SECRET",
resave: false,
saveUninitialized: false
}));
/**
* Send routes into router
*/
require('./server/router')(app);
/**
* Express Server Configuration
*/
app.set("port", process.env.PORT || 5000);
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.use(express.static(__dirname + '/dist'));
app.listen(app.get("port"), function(){
console.log("Listening on port %d", app.get("port"));
});