Skip to content

Commit

Permalink
Updated App.js file to ES6 and added Queue route to checkSession midd…
Browse files Browse the repository at this point in the history
…leware function
  • Loading branch information
itajenglish committed Mar 3, 2017
1 parent 95a0929 commit 42e4994
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 38 deletions.
39 changes: 19 additions & 20 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,10 @@ const express = require('express'),
mustache = require('mustache-express'),
pgp = require('pg-promise')(),
methodOverride = require('method-override'),
bdPars = require('body-parser'),
bcrypt = require('bcrypt'),
session = require('express-session'),
bdPars = require('body-parser'),
morgan = require('morgan');
var db = pgp(process.env.DATABASE_URL || 'postgres://tajenglish@localhost:5432/quedj');

//Controllers
const USERS_ROUTER = require('./controllers/Users');
const SESSIONS_ROUTER = require('./controllers/Sessions');
const HOME_ROUTER = require('./controllers/Home');
const DASHBOARDS_ROUTER = require('./controllers/Dashboards');
const QUEUE_ROUTER = require('./controllers/Queue');
const API_ROUTER = require('./controllers/API');

const checkSession = require('./lib/helpers/checkSession');

//configure express and related packages
app.engine('html', mustache());
Expand All @@ -34,27 +23,37 @@ app.use(bdPars.json()); //body parser


app.use(session({
secret: 'test',
secret: 'quedj',
resave: false,
saveUninitialized: true,
cookie: {
secure: false
}
}));

//Redirects any user that is not logged in when visiting /users
app.all(['/users*'], checkSession)
const checkSession = require('./lib/helpers/checkSession');

//start the server
var PORT = process.env.PORT || 3000;
app.listen(PORT, function() {
console.log('Server running on port ' + PORT + '!');
});
//Redirects any user that is not logged in when visiting /users
app.all(['/users*','/queue*'], checkSession)

//Controllers
const USERS_ROUTER = require('./controllers/Users');
const SESSIONS_ROUTER = require('./controllers/Sessions');
const HOME_ROUTER = require('./controllers/Home');
const DASHBOARDS_ROUTER = require('./controllers/Dashboards');
const QUEUE_ROUTER = require('./controllers/Queue');
const API_ROUTER = require('./controllers/API');

// Define All Routes
app.use(HOME_ROUTER);
app.use(SESSIONS_ROUTER);
app.use(DASHBOARDS_ROUTER);
app.use('/Users', USERS_ROUTER);
app.use('/Queue', QUEUE_ROUTER);
app.use('/Api', API_ROUTER);

//start the server
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log('Server running on port ' + PORT + '!');
});
18 changes: 0 additions & 18 deletions routes/User.js

This file was deleted.

0 comments on commit 42e4994

Please sign in to comment.