-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
68 lines (56 loc) · 1.52 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
// Dependencies
var express = require('express');
var app = express();
var port = process.env.PORT || 3000;
var server;
//Middlewares
var mongoose = require('mongoose');
var configDB = require('./config/database.js');
var morgan = require('morgan');
var ejs = require('ejs');
var bodyParser = require('body-parser');
//var gulp = require('gulp');
//var sessions = require('client-sessions');
// DB Config
mongoose.connect(configDB.url);
// App Config
app.use(morgan('dev'));
app.use(express.static(__dirname + '/public'));
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended:true}));
// Sessions Config
/*
app.use(sessions({
cookieName: 'app_user_session',
secret: 'somesessionconfigthatyoushouldchangetobesuperlongandundecipherable',
duration: 7 * 24 * 60 * 60 * 1000, // 1 week duration
activeDuration: 0,
cookie: {
ephemeral: true,
httpOnly: false,
secure: false
}
}));
*/
/* ROUTES */
// Auth
/*var authRouter = express.Router();
require('./routes/routesAuth.js')(authRouter);
app.use('/', authRouter);*/
// Public
var publicRouter = express.Router();
require('./routes/routesPublic.js')(publicRouter);
app.use('/', publicRouter);
// 404 (always keep last!)
app.use(function(req,res) {
res.render('404', {title:"Page Not Found 404"}, function(err, html) {
if (err) { console.log(err); }
res.send(html);
});
})
// Start the server.
server = app.listen(port, function() {
console.log("Server Start: " + port);
});