diff --git a/index.d.ts b/index.d.ts index b8320ea79de12fde4dd9b610d8d27afab4ae0a76..248f1979d7691ca2a3f9a804e6f1ddfaa5bb62a1 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 a878db47fb2c91800d795e91b6b1d59120fd0585..910da8552e6c8cc976c30a2d18166e4560afe72b 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 5241aa14a4eafcf1c8c772d2eafb28cccb0ddb2f..34cb71c91e707ece4524cfc731df5b1ae6ce1f6e 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": {