add secure middleware for express
This commit is contained in:
parent
55974bb55d
commit
90adfd04ae
2 changed files with 4 additions and 1 deletions
|
@ -22,7 +22,8 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"compression": "=1.6.2",
|
"compression": "=1.6.2",
|
||||||
"connect-static-file": "=1.1.2",
|
"connect-static-file": "=1.1.2",
|
||||||
"express": "=4.14.0"
|
"express": "=4.14.0",
|
||||||
|
"helmet": "=2.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "=1.9.0",
|
"eslint": "=1.9.0",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const staticFile = require('connect-static-file');
|
const staticFile = require('connect-static-file');
|
||||||
const compression = require('compression');
|
const compression = require('compression');
|
||||||
|
const helmet = require('helmet');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const PORT = process.env.PORT || 5000;
|
const PORT = process.env.PORT || 5000;
|
||||||
|
@ -18,6 +19,7 @@ const expressConfig = {
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
app.use(compression({ level: 9 }));
|
app.use(compression({ level: 9 }));
|
||||||
|
app.use(helmet());
|
||||||
|
|
||||||
|
|
||||||
app.use(function (request, response, next) {
|
app.use(function (request, response, next) {
|
||||||
|
|
Reference in a new issue