Commit bffaf9b3 authored by Rosanny Sihombing's avatar Rosanny Sihombing
Browse files

Merge branch 'best-practice' into 'testing'

express js best practices

See merge request !4
parents a8aff445 38b6ee35
Pipeline #944 passed with stage
in 18 seconds
......@@ -7,6 +7,8 @@ const bodyParser = require('body-parser')
const session = require('express-session')
const flash = require('express-flash')
const fileUpload = require('express-fileupload')
const helmet = require('helmet')
const compression = require('compression')
var env = process.env.NODE_ENV || 'testing'
const config = require('./config/config')[env]
......@@ -15,13 +17,15 @@ var app = express()
app.set('port', config.app.port)
app.set('views', __dirname + '/views')
app.set('view engine', 'pug')
app.set('view engine', 'pug')
app.use(helmet())
app.use(compression())
app.use(morgan('combined'))
app.use(cookieParser())
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({extended: false}))
app.use(express.static(path.join(__dirname, 'public')))
app.use(session(
{
resave: true,
......@@ -29,10 +33,8 @@ app.use(session(
secret: 'thisisasecret-thisisasecret-thisisasecret'
}
))
app.use(passport.initialize())
app.use(passport.session())
app.use(flash())
app.use((req, res, next) => {
res.locals.errors = req.flash("error")
......@@ -46,7 +48,6 @@ app.use(fileUpload({
fileSize: 1000000 // 1 MB max. file size
}
}))
// caching disabled for every route
// NOTE: Works in Firefox and Opera. Does not work in Edge
app.use(function(req, res, next) {
......
This diff is collapsed.
{
"name": "passport-saml-example",
"name": "m4_lab-projects",
"version": "0.0.1",
"description": "Example for PassportJS SAML strategy",
"description": "M4_LAB Projects Manager",
"author": {
"name": "Gerard Braad",
"email": "me@gbraad.nl",
"url": "http://gbraad.nl"
"name": "Rosanny Sihombing",
"email": "rosanny.sihombing@hft-stuttgart.de"
},
"contributors": [
{
"name": "Christian Kuster",
"email": "git@kusti.ch"
}
],
"keywords": [
"saml",
"sso"
"m4_lab",
"prjects"
],
"repository": {
"type": "git",
"url": "https://github.com/gbraad/passport-saml-example.git"
"url": "https://transfer.hft-stuttgart.de/gitlab/m4lab_tv1/project-page.git"
},
"scripts": {
"start": "nodemon app.js",
"test": ""
},
"dependencies": {
"body-parser": "1.15.1",
"body-parser": "^1.19.0",
"compression": "^1.7.4",
"cookie-parser": "1.4.3",
"errorhandler": "1.4.3",
"express": "4.13.4",
"express": "^4.17.1",
"express-fileupload": "^1.1.7-alpha.2",
"express-flash": "0.0.2",
"express-session": "1.13.0",
"express-session": "^1.17.1",
"fs": "0.0.1-security",
"morgan": "1.7.0",
"helmet": "^3.23.3",
"morgan": "^1.10.0",
"mysql": "^2.18.1",
"nodemon": "1.9.2",
"passport": "0.3.2",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment