Newton's Principia Mathematica
Miss any of our Open RFC calls?Watch the recordings here! »

koa-helmet

6.0.0 • Public • Published

koa-helmet

Version Build Status Coverage Status Dependency Status js-semistandard-style Downloads

koa-helmet is a wrapper for helmet to work with koa. It provides important security headers to make your app more secure by default.

Installation

yarn add koa-helmet

or via npm:

npm install koa-helmet --save

Usage

Usage is the same as helmet

Helmet offers 11 security middleware functions:

// This...
app.use(helmet());
 
// ...is equivalent to this:
app.use(helmet.contentSecurityPolicy());
app.use(helmet.dnsPrefetchControl());
app.use(helmet.expectCt());
app.use(helmet.frameguard());
app.use(helmet.hidePoweredBy());
app.use(helmet.hsts());
app.use(helmet.ieNoOpen());
app.use(helmet.noSniff());
app.use(helmet.permittedCrossDomainPolicies());
app.use(helmet.referrerPolicy());
app.use(helmet.xssFilter());

You can see more in the documentation.

Note:

In order to work well with the helmet HSTS module, koa-helmet will augment this.request to include a secure boolean to determine if the request is over HTTPS.

Example

"use strict";
 
const Koa = require("koa");
const helmet = require("koa-helmet");
const app = new Koa();
 
app.use(helmet());
 
app.use((ctx) => {
  ctx.body = "Hello World"
});
 
app.listen(4000);

Testing

To run the tests, simply run

yarn test

Versioning

  • koa-helmet >=2.x (master branch) supports koa 2.x
  • koa-helmet 1.x (koa-1 branch) supports koa 0.x and koa 1.x

Install

npm i koa-helmet

DownloadsWeekly Downloads

108,562

Version

6.0.0

License

MIT

Unpacked Size

48.1 kB

Total Files

18

Last publish

Collaborators

  • avatar