40 lines
1001 B
JavaScript
40 lines
1001 B
JavaScript
|
'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;
|