Created
August 16, 2016 13:55
-
-
Save savelee/1145fc1ada6acf3265584fbf83a3fef5 to your computer and use it in GitHub Desktop.
server/config/express.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var morgan = require('morgan'), | |
compression = require('compression'), | |
errorHandler = require('errorhandler'), | |
path = require('path'), | |
config = require('./index'), | |
bodyParser = require('body-parser'), | |
csrf = require('csurf'), | |
passport = require('passport'), | |
express = require('express'), | |
apiRoutes = express.Router(); | |
require('./passport')(passport); | |
//additional security layer for posting of forms | |
var csrfProtection = csrf({ | |
cookie: true | |
}) | |
var parseForm = bodyParser.urlencoded({ | |
extended: false | |
}) | |
module.exports = function(app) { | |
app.use(compression()); | |
//app.use(express.static(path.join(config.root, ''))); | |
app.set('appPath', path.join(config.root, 'server/views/')); // define the path of our app inside express to use across the server if needed | |
app.use(morgan('dev')); | |
app.use(errorHandler()); // error handler | |
app.use(bodyParser.urlencoded({ | |
extended: true | |
})); | |
app.use(bodyParser.json()); | |
app.use(passport.initialize()); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment