-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
37 lines (28 loc) · 952 Bytes
/
index.js
File metadata and controls
37 lines (28 loc) · 952 Bytes
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
const express = require('express');
const path = require('path');
const bodyparser = require('body-parser')
const session = require('express-session')
const {v4: uuidv4} = require('uuid')
// seprated route module imported here
const router = require('./router')
const app = express();
const port = process.env.PORT||3000;
app.use(bodyparser.json())
app.use(bodyparser.urlencoded({extended:true}))
app.set('view engine','ejs');
// load static files using path modules and express
app.use('/static',express.static(path.join(__dirname,'public')))
app.use('/assets',express.static(path.join(__dirname,'public/assets')))
app.use(session({
secret: uuidv4(),
resave:false,
saveUninitialized: true
}))
app.use('/route',router)
//home route
app.get("/",(req, res)=>{
res.render('base',{title:"Login system"})
// console.log("home route just hit")
}).listen(port,()=>{
console.log("server running on http://localhost:" + port)
})