-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
49 lines (34 loc) · 1.05 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
const express= require("express");
const path=require("path");
const mysql=require("mysql");
const dotenv=require("dotenv");
const cookieParser = require('cookie-parser');
const session = require('express-session');
dotenv.config({path: './.env'});
const app = express();
const db = mysql.createConnection({
host: process.env.DATABASE_HOST,
user: process.env.DATABASE_USER,
password: process.env.DATABASE_PASSWORD,
database: process.env.DATABASE,
});
const publicDirectory = path.join(__dirname,'./public')
app.use(express.static(publicDirectory));
app.use(express.urlencoded({extended:false}));
app.use(express.json());
app.use(cookieParser());
app.use(session({secret: process.env.JWT_SECRET,saveUninitialized: true,resave: false}));
app.set('view engine', 'hbs');
db.connect((error)=> {
if(error){
console.log(error)
} else{
console.log("MYSQL Connected")
}
})
var sess;
app.use('/', require('./routes/pages'));
app.use('/auth', require('./routes/auth'));
app.listen(5001,()=>{
console.log("Server Started");
})