-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.js
More file actions
53 lines (43 loc) · 1.09 KB
/
Copy pathMain.js
File metadata and controls
53 lines (43 loc) · 1.09 KB
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
const express = require('express');
const app = express();
const path = require('path');
const mysql = require('mysql');
const session = require('express-session');
const MySQLStore = require('express-mysql-session')(session);
const Router = require('./Router');
app.use(express.static(path.join(__dirname, 'build')));
app.use(express.json());
//console.log('Testing Server');
const db = mysql.createConnection({
host:'localhost',
user:'root',
password:'',
database:'my_app'
});
db.connect(function(err){
if(err){
console.log('DB Error.');
throw err;
return false;
}
});
const sessionStore = new MySQLStore({
expiration:(1825 * 86400 * 1000),
endConnectionOnClose: false
}, db);
app.use(session({
key:'jnsdjsrerej553331',
secret:'jdhjhj3h5j3h3jh3',
store: sessionStore,
resave:false,
saveUninitialized:false,
cookie:{
maxAge:(1825 * 86400 * 1000),
httpOnly:false
}
}));
new Router(app, db);
app.get('/', function(req, res){
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});
app.listen(3000);