-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
36 lines (31 loc) · 1.31 KB
/
index.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
// index.js: The main routes for the web app
// Imports
var express = require('express');
var ensureLogIn = require('connect-ensure-login').ensureLoggedIn;
var database = require('./database.js');
// Ensure logged in
var ensureLoggedIn = function checkLogin(req, res, next) {
// ensureLogIn();
next();
}
// Load page
function load(req, res, next) {
res.locals.variable = "";
next();
}
// Routes
var router = express.Router();
router.get('/', function (req, res, next) {
if (!req.user) { return res.render('chat'); }
next();
}, load, function (req, res, next) {
res.redirect('/chat');
});
router.get('/calendar', ensureLoggedIn, load, function (req, res, next) { res.render('calendar', { user: req.user }); });
router.get('/chat', ensureLoggedIn, load, function (req, res, next) { res.render('chat', { user: req.user }); });
router.get('/video', ensureLoggedIn, load, function (req, res, next) { res.render('video', { user: req.user }); });
router.get('/about', ensureLoggedIn, load, function (req, res, next) { res.render('about', { user: req.user }); });
router.get('/account', ensureLoggedIn, load, function (req, res, next) { res.render('account', { user: req.user }); });
router.get('/room', ensureLoggedIn, load, function (req, res, next) { res.render('room', { user: req.user }); });
// Export
module.exports = router;