UNPKG

astroboy

Version:

Astroboy(阿童木)is a Nodejs SFB(Separation of Front and Back ends) framework, built on koa2.

28 lines 821 B
"use strict"; /** * Strict-Transport-Security * https://developer.mozilla.org/zh-CN/docs/Security/HTTP_Strict_Transport_Security */ const assert = require("assert"); const factory = function (options, app) { if (typeof options === 'number') { options = { maxAge: options, }; } options = options || {}; assert(typeof options.maxAge === 'number', 'options.maxAge should be a number'); let value = 'max-age=' + options.maxAge; if (options.includeSubDomains) { value += '; includeSubDomains'; } if (options.preload) { value += '; preload'; } return function hsts(ctx, next) { ctx.set('Strict-Transport-Security', value); return next(); }; }; module.exports = factory; //# sourceMappingURL=astroboy-security-hsts.js.map