forked from Sarathcani999/duty_leave_automation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
35 lines (29 loc) · 902 Bytes
/
server.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
const express = require('express')
const app = express()
const path = require('path')
const cookieparser = require('cookie-parser')
const connection = require('./config/connect')
const auth = require('./routes/middleware/auth')
//Opening connection
connection.connect((err) => {
if (err) {
throw err
}
console.log("Mysql connected")
});
// Body Parsers
app.use(express.urlencoded({ extended : false }))
app.use(express.json())
app.use(cookieparser())
app.set('views' , path.join( __dirname , './views'))
app.set('view engine' , 'hbs')
app.use(express.static(path.join(__dirname , './public')))
app.get('/' , auth.notAuth , (req,res) => {
res.render('index')
})
app.use('/api' , require('./routes/api'))
app.use('/student' , require('./routes/student'))
app.use('/admin' , require('./routes/admin'))
app.listen(3000 , () => {
console.log("Port estalbished at 3000")
})