-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
36 lines (30 loc) · 1012 Bytes
/
app.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
var express = require('express');
var app = express();
var session = require('express-session');
var MongoStore = require('connect-mongo')(session);
app.set('view engine', 'ejs');
var server = app.listen(3000, function(){
console.log('\nServer has started on Port 3000. Time:', currentTime);
});
const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/chatdb');
var db = mongoose.connection;
var io = require('socket.io').listen(server);
var router = require('./router')(app,io,db);
var path = require('path');
var bodyParser = require('body-parser');
app.use(session({
secret: 'work hard',
resave: true,
saveUninitialized: false,
cookie: {maxAge: 60000},
store: new MongoStore({
mongooseConnection: db
})
}));
// Bodyparser Middleware
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.use(router);
var date = new Date();
var currentTime = date.getHours()+':'+date.getMinutes()+':'+date.getSeconds();