How to use the koa-helmet.defaults function in koa-helmet

To help you get started, we’ve selected a few koa-helmet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tomaash / react-example-filmdb / server / koa.js View on Github external
import router from "./router";
import config from "./config/init";

import rest from "./rest";
import {clone} from "lodash";

const app = koa();
const env = process.env.NODE_ENV || "development";
// const appRouter = koaRouter();

app.use(responseTime());
app.use(logger());

// various security headers
app.use(helmet.defaults());

if (env === "production") {
	app.use(require("koa-conditional-get")());
	app.use(require("koa-etag")());
	app.use(require("koa-compressor")());

	// Cache pages
	const cache = require("lru-cache")({maxAge: 3000});
	app.use(require("koa-cash")({
		get: function*(key) {
			return cache.get(key);
		},

		set: function*(key, value) {
			cache.set(key, value);
		}