-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
57 lines (36 loc) · 1.23 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
var express = require('express');
const bodyPareser = require('body-parser');
const app = express();
var session = require("express-session");
var mysqlstore = require("express-mysql-session")(session);
//middle ware / routing
app.listen(3001, function(){console.log('My server is ruinning on port 3001');});
//npm install express-session express-mysql-session
//npm i mutler
//npm install sharp
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
var indexRouter = require('./routes/index');
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
var sessionStore = new mysqlstore({/*using defulat options*/ },require('./conf/database'));
var sessionOptions = {
key:"cscid",
secret:"this is a super secrect for csc317",
store:sessionStore,
cookie:{secure:false,httpOnly:false,maxAge:900000},
resave:false,
saveUninitialized:false
}
app.use(session(sessionOptions));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', indexRouter);
app.use(function(err,req,res,next)
{
console.log(err);
res.sendFile("error.html",{root:"public/html"});
});
module.exports = app;