-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
69 lines (44 loc) · 1.43 KB
/
index.js
File metadata and controls
69 lines (44 loc) · 1.43 KB
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
63
64
65
66
67
68
69
const express = require('express')
const app = express();
const session = require('express-session')
require("dotenv").config();
app.use("/static",express.static(__dirname+"/static"))
//Database Setup
const db = require('./database')
db.init()
// EJS Setup
app.set('view engine', 'ejs');
app.listen(process.env.PORT,()=>{
console.log(`Server is running on ${process.env.port} port`)
})
//Middleware
app.use(express.urlencoded({ extended: true }))
app.use(session({
secret: process.env.SECRET,
resave: false,
saveUninitialized: true,
}))
app.use(express.json());
app.get("/",(req,res)=>{
if(req.session.isLoggedin){
res.render("chat/mainScreen.ejs",{username:req.session.user.username});
}
else{
res.redirect("/login")
}
})
/***************** Authentication and Authorization *************/
const auth = require("./routes/auth")
app.use(auth);
/****************** Channels Routes ****************/
const channels = require("./routes/channels")
app.use("/channels",channels)
/********************* Posts Route ******************/
const posts = require("./routes/posts")
app.use("/posts",posts)
/********************************* Notification Route ***************/
const notification = require("./routes/notifications")
app.use("/notify",notification)
/************************* Dashboard *************************/
const dashboard = require("./routes/dashboard")
app.use("/dashboard",dashboard)