Skip to content

Commit

Permalink
Merge pull request #36 from venables/update-helmet
Browse files Browse the repository at this point in the history
Update helmet depencency to ^3.12.0
  • Loading branch information
venables committed Mar 27, 2018
2 parents 23cec40 + 942ce79 commit 3c352ec
Show file tree
Hide file tree
Showing 6 changed files with 697 additions and 400 deletions.
39 changes: 39 additions & 0 deletions .eslintrc.js
@@ -0,0 +1,39 @@
module.exports = {
"env": {
"es6": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:node/recommended"
],
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "module"
},
"plugins": [
"node"
],
"rules": {
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"space-before-function-paren": [
"error",
"always"
]
}
};
6 changes: 3 additions & 3 deletions lib/promisify.js
Expand Up @@ -7,7 +7,7 @@
* @param {Function} middleware - The middleware to promisify
* @returns {Function} - The middleware function updated to return a Promise, not call a callback
*/
const promisify = function koaHelmetPromisify (middleware) {
function koaHelmetPromisify (middleware) {
return function (req, res) {
return new Promise(function (resolve, reject) {
middleware(req, res, function (err) {
Expand All @@ -19,6 +19,6 @@ const promisify = function koaHelmetPromisify (middleware) {
});
});
};
};
}

module.exports = promisify;
module.exports = koaHelmetPromisify;
24 changes: 16 additions & 8 deletions package.json
Expand Up @@ -6,8 +6,9 @@
"version": "3.3.0",
"main": "lib/koa-helmet.js",
"scripts": {
"lint": "semistandard",
"test": "semistandard && NODE_ENV=test nyc --reporter=lcov --reporter=text ava 'test/**/*.spec.js'",
"format": "eslint lib test --fix",
"lint": "eslint lib test",
"test": "eslint lib test && nyc ava",
"coverage": "nyc report --reporter=text-lcov | coveralls"
},
"keywords": [
Expand All @@ -22,17 +23,24 @@
"url": "git://github.com/venables/koa-helmet.git"
},
"engines": {
"node": ">= 4.0.0"
"node": ">= 6.0.0"
},
"dependencies": {
"helmet": "^3.9.0"
"helmet": "^3.12.0"
},
"devDependencies": {
"ava": "^0.24.0",
"ava": "^0.25.0",
"coveralls": "^3.0.0",
"koa": "^2.4.1",
"nyc": "^11.4.1",
"semistandard": "^12.0.0",
"eslint": "^4.19.1",
"eslint-plugin-node": "^6.0.1",
"koa": "^2.5.0",
"nyc": "^11.6.0",
"supertest": "^3.0.0"
},
"nyc": {
"reporter": [
"lcov",
"text"
]
}
}
5 changes: 5 additions & 0 deletions test/.eslintrc.js
@@ -0,0 +1,5 @@
module.exports = {
"rules": {
"node/no-unpublished-require": "off"
}
};
10 changes: 8 additions & 2 deletions test/koa-helmet.spec.js
Expand Up @@ -8,23 +8,29 @@ const test = require('ava');
test('it works with the default helmet call', t => {
const app = new Koa();
app.use(helmet());
app.use((ctx, next) => {
app.use((ctx) => {
ctx.body = 'Hello world!';
});

return (
request(app.listen())
.get('/')

// dnsPrefetchControl
.expect('X-DNS-Prefetch-Control', 'off')

// frameguard
.expect('X-Frame-Options', 'SAMEORIGIN')

// hsts: Not enabled in HTTP
// .expect('Strict-Transport-Security', 'max-age=5184000; includeSubDomains')
.expect('Strict-Transport-Security', 'max-age=15552000; includeSubDomains')

// ieNoOpen
.expect('X-Download-Options', 'noopen')

// noSniff
.expect('X-Content-Type-Options', 'nosniff')

// xssFilter
.expect('X-XSS-Protection', '1; mode=block')
.expect(200)
Expand Down

0 comments on commit 3c352ec

Please sign in to comment.