diff --git a/lib/exposure/exposure.js b/lib/exposure/exposure.js index 1023552..aa6a143 100644 --- a/lib/exposure/exposure.js +++ b/lib/exposure/exposure.js @@ -53,20 +53,19 @@ export default class Exposure { this.initCountMethod(); } - _validateAndClean() { - if (typeof(this.config) === 'function') { - const firewall = this.config; - this.config = {firewall}; + _validateAndClean(config) { + if (typeof(config) === 'function') { + const firewall = config; + config = {firewall}; + } + config = ExposureConfigSchema.clean(config); + ExposureConfigSchema.validate(config); + + if (config && config.body) { + ExposureConfigSchema.validateBody(this.collection, config.body); } - this.config = ExposureConfigSchema.clean(this.config); - ExposureConfigSchema.validate(this.config); - - if (this.config && this.config.body) { - ExposureConfigSchema.validateBody(this.collection, this.config.body); - } - - return _.extend({}, Exposure.getConfig(), this.config); + return _.extend({}, Exposure.getConfig(), config); } /** @@ -207,4 +206,4 @@ export default class Exposure { return findOne(filters, options); } } -}; \ No newline at end of file +};