How to use the @hapi/statehood.prepareValue function in @hapi/statehood

To help you get started, we’ve selected a few @hapi/statehood examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hapijs / yar / lib / index.js View on Github external
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;
    }

@hapi/statehood

HTTP State Management Utilities

BSD-3-Clause
Latest version published 1 year ago

Package Health Score

71 / 100
Full package analysis