This repository has been archived on 2018-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
ProgBlog/app/config/middleware.js

40 lines
1001 B
JavaScript
Raw Normal View History

2016-02-19 12:58:16 -05:00
'use strict';
// -----------------------------------------------------------------------------
// Middleware
// -----------------------------------------------------------------------------
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const express = require('express');
const helmet = require('helmet');
const requestLogger = require('morgan');
const path = require('path');
const session = require('express-session');
let middleware = new Set([
// some security settings controlled by helmet
helmet.frameguard(),
helmet.hidePoweredBy(),
helmet.ieNoOpen(),
helmet.noSniff(),
helmet.xssFilter(),
// session setup
session({
name: 'blogid',
resave: false,
saveUninitialized: false,
secret: '76al;p9vse',
}),
// basic express middleware
requestLogger('combined'),
bodyParser.json(),
bodyParser.urlencoded({ extended: false }),
cookieParser(),
express.static(path.join(__dirname, '../../public')),
]);
module.exports = middleware;