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 = {
            _store: request.yar._store

        const value = await Statehood.prepareValue(, content, settings.cookieOptions);
        if (value.length <= settings.maxCookieSize) {
            h.state(, 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;


HTTP State Management Utilities

Latest version published 1 year ago

Package Health Score

71 / 100
Full package analysis