-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
41 lines (26 loc) · 929 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
36
37
38
'use strict'
require('dotenv').config()
var express = require ("express");
var bodyParser = require('body-parser');
var app = express();
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(require('cookie-parser')()); //
app.use(require('morgan')('combined'));
//Setup Passport
const passport = require('./passport-init')(app);
//Do more stuff here
const PORT = 3000;
//the forbidden route. This is where all protected routes will be directed when auth fails
app.get('/forbidden', (req,res) => {
res.send(403, 'You are not authorized')
});
// Setup Routes
const protectedRoutes = require('./routes/protected-routes');
const pubRoutes = require('./routes/public-routes');
app.use(pubRoutes);
//make sure protectedRoutes is app.use'd after the public routes.
app.use(protectedRoutes);
app.listen(PORT, function() {
console.log('Listening on port ' + PORT);
});