From d477b075037b1c1703c0d2deeb09860b3a3b43b6 Mon Sep 17 00:00:00 2001 From: "Dominik.Sigmund" <dominik.sigmund@br.de> Date: Wed, 28 Jun 2023 11:30:32 +0200 Subject: [PATCH] better structure --- index.d.ts | 1 + index.js | 12 +++++++++--- package.json | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/index.d.ts b/index.d.ts index b8320ea..248f197 100644 --- a/index.d.ts +++ b/index.d.ts @@ -4,4 +4,5 @@ export = Security; declare class Security { constructor(); + setHeaders(req: express.Request, res: express.Response, next: express.NextFunctiont): void; } diff --git a/index.js b/index.js index a878db4..910da85 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,11 @@ -module.exports = function(options) { - return function(req, res, next) { - if(!options) options = {} +module.exports = function(options = {}) { + let security = {} + security.options = options + + security.setHeaders = function(req, res, next) { + if(!this.options) options = {} + else options = this.options if (typeof options.CacheControl === 'undefined') { options.CacheControl = 'no-cache, no-store, must-revalidate' @@ -137,4 +141,6 @@ module.exports = function(options) { next() } + + return security; } \ No newline at end of file diff --git a/package.json b/package.json index 0fad25c..f263e78 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@libs/security", - "version": "2.2.3", + "version": "2.3.0", "description": "Sets Headers to a very save style in express-apps. may be overriden by config", "main": "index.js", "scripts": { -- GitLab