-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
62 lines (46 loc) · 1.3 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
58
59
60
61
62
const express = require("express");
const path = require("path");
const mysql = require("mysql");
const dotenv = require("dotenv");
var session = require('express-session');
var flash = require('connect-flash');
var engines = require('consolidate');
var exphbs = require('express-handlebars');
dotenv.config({ path: './.env'});
const app = express();
const db = mysql.createConnection({
host: 'localhost',
user: 'root',
password: '',
database: 'mspm-website'
});
const visited = []
const publicDirectory = path.join(__dirname, './public');
app.use(express.static(publicDirectory));
app.use(express.urlencoded({ extended: false}));
app.use(express.json());
// app.engine('handlebars', engines.handlebars);
// app.engine('pug', engines.pug);
// app.set('view engine', 'pug');
// app.set('views','./views');
app.set('view engine','hbs');
db.connect((error) => {
if(error){
console.log(error)
}
else{
console.log("MY SQL CONNECTED!")
}
})
app.use('/', require('./routes/pages'));
app.use('/auth', require('./routes/auth'));
app.use(session({
secret: 'keyboard cat',
resave: false,
saveUninitialized: true,
cookie: { secure: false , maxAge: 60000 }
}))
app.use(flash());
app.listen(5001,()=>{
console.log("SERVER STARTED ON PORT 5001");
} )