Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.events = new Podium(internals.events);
this.heavy = new Heavy(this.settings.load);
this.instances = new Set();
this.methods = new Methods(this); // Server methods
this.mime = new Mimos(this.settings.mime);
this.onConnection = null; // Used to remove event listener on stop
this.plugins = {}; // Exposed plugin properties by name
this.registrations = {}; // Tracks plugin for dependency validation { name -> { version } }
this.registring = 0; // > 0 while register() is waiting for plugin callbacks
this.requestCounter = { value: internals.counter.min, min: internals.counter.min, max: internals.counter.max };
this.router = new Call.Router(this.settings.router);
this.phase = 'stopped'; // 'stopped', 'initializing', 'initialized', 'starting', 'started', 'stopping', 'invalid'
this.sockets = null; // Track open sockets for graceful shutdown
this.actives = new WeakMap(); // Active requests being processed
this.started = false;
this.states = new Statehood.Definitions(this.settings.state);
this.toolkit = new Toolkit.Manager();
this.extensionsSeq = 0; // Used to keep absolute order of extensions based on the order added across locations
this.extensions = {
server: {
onPreStart: new Ext('onPreStart', this),
onPostStart: new Ext('onPostStart', this),
onPreStop: new Ext('onPreStop', this),
onPostStop: new Ext('onPostStop', this)
},
route: {
onRequest: new Ext('onRequest', this),
onPreAuth: new Ext('onPreAuth', this),
onCredentials: new Ext('onCredentials', this),
onPostAuth: new Ext('onPostAuth', this),
onPreHandler: new Ext('onPreHandler', this),
if (lazyKeys.length) {
request.yar._store._lazyKeys = lazyKeys;
}
}
// Store session data in cookie
const settings = request.yar._settings;
if (settings.maxCookieSize) {
const content = {
id: request.yar.id,
_store: request.yar._store
};
const value = await Statehood.prepareValue(settings.name, content, settings.cookieOptions);
if (value.length <= settings.maxCookieSize) {
h.state(settings.name, value, settings.rawCookieOptions);
return h.continue;
}
}
// Store session data in cache
const cache = request.yar._cache;
if (!settings.errorOnCacheNotReady &&
!cache.isReady()) {
request.log('Cache is not ready: not storing sessions to cache');
return h.continue;
}