Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this._assert(!this.settings.validate.payload || this.settings.payload.parse, 'Route payload must be set to \'parse\' when payload validation enabled');
this._assert(!this.settings.validate.state || this.settings.state.parse, 'Route state must be set to \'parse\' when state validation enabled');
this._assert(!this.settings.jsonp || typeof this.settings.jsonp === 'string', 'Bad route JSONP parameter name');
// Authentication configuration
this.settings.auth = (this._special ? false : this._core.auth._setupRoute(this.settings.auth, path));
// Cache
if (this.method === 'get' &&
typeof this.settings.cache === 'object' &&
(this.settings.cache.expiresIn || this.settings.cache.expiresAt)) {
this.settings.cache._statuses = new Set(this.settings.cache.statuses);
this._cache = new Catbox.Policy({ expiresIn: this.settings.cache.expiresIn, expiresAt: this.settings.cache.expiresAt });
}
// CORS
this.settings.cors = Cors.route(this.settings.cors);
// Security
this.settings.security = Security.route(this.settings.security);
// Handler
this.settings.handler = Handler.configure(handler, this);
this._prerequisites = Handler.prerequisitesConfig(this.settings.pre);
// Route lifecycle
_cachePolicy(options, _segment, realm) {
options = Config.apply('cachePolicy', options);
const plugin = realm && realm.plugin;
const segment = options.segment || _segment || (plugin ? `!${plugin}` : '');
Hoek.assert(segment, 'Missing cache segment name');
const cacheName = options.cache || '_default';
const cache = this.caches.get(cacheName);
Hoek.assert(cache, 'Unknown cache', cacheName);
Hoek.assert(!cache.segments[segment] || cache.shared || options.shared, 'Cannot provision the same cache segment more than once');
cache.segments[segment] = true;
return new Catbox.Policy(options, cache.client, segment);
}