How to use the @tinkoff/utils/object/prop function in @tinkoff/utils

To help you get started, we’ve selected a few @tinkoff/utils 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 TinkoffCreditSystems / tinkoff-request / packages / plugin-batch / src / batch.ts View on Github external
init: (context, next) => {
            const request = context.getRequest();
            const batchKey: string = prop('batchKey', request);
            const batchTimeout = propOr('batchTimeout', timeout, request);

            context.updateExternalMeta(BATCH, {
                batched: true,
            });

            const running = batchRequests[batchKey];

            if (running) {
                running.requests.push(request);
                running.nexts.push(next);
                return;
            }

            batchRequests[batchKey] = { requests: [request], nexts: [next] };
github TinkoffCreditSystems / tinkoff-request / packages / plugin-protocol-http / src / utils.ts View on Github external
const _getHeaders = (request: MakeRequestResult) => {
    return prop('headers', _getResponse(request));
};
github TinkoffCreditSystems / tinkoff-request / packages / cache-utils / src / getCacheKey.ts View on Github external
export default (context: Context, cacheKey = defaultCacheKey) => {
    let key = prop('key', context.getInternalMeta(CACHE));

    if (!key) {
        key = cacheKey(context.getRequest());

        context.updateInternalMeta(CACHE, {
            key,
        });
    }

    return key;
};
github TinkoffCreditSystems / tinkoff-request / packages / plugin-cache-memory / src / memory.ts View on Github external
complete: (context, next) => {
            const cacheKey = getCacheKeyUtil(context, getCacheKey);
            const ttl = prop('memoryCacheTtl', context.getRequest());

            lruCache.set(cacheKey, context.getResponse(), ttl);

            context.updateExternalMeta(metaTypes.CACHE, {
                memoryCacheBackground: prop('memoryCacheBackground', context.getRequest()),
            });

            next();
        },
    };
github TinkoffCreditSystems / tinkoff-request / packages / plugin-protocol-http / src / utils.ts View on Github external
export const getStatus = (request: MakeRequestResult) => {
    return prop('status', _getResponse(request));
};
github TinkoffCreditSystems / tinkoff-request / packages / plugin-cache-memory / src / memory.ts View on Github external
complete: (context, next) => {
            const cacheKey = getCacheKeyUtil(context, getCacheKey);
            const ttl = prop('memoryCacheTtl', context.getRequest());

            lruCache.set(cacheKey, context.getResponse(), ttl);

            context.updateExternalMeta(metaTypes.CACHE, {
                memoryCacheBackground: prop('memoryCacheBackground', context.getRequest()),
            });

            next();
        },
    };
github TinkoffCreditSystems / tinkoff-request / packages / plugin-log / src / log.ts View on Github external
init: (context, next) => {
            const request = context.getRequest();
            const start = Date.now();
            const silent = prop('silent', request);

            if (!silent) {
                log.info('init', getInfo(request));
            }

            log.debug('init', request);

            context.updateExternalMeta(LOG, {
                start,
            });

            next();
        },
        complete: (context, next) => {
github TinkoffCreditSystems / tinkoff-request / packages / plugin-batch / src / batch.ts View on Github external
shouldExecute: (context) => {
            return makeGroupedRequest && shouldExecute && prop('batchKey', context.getRequest());
        },
        init: (context, next) => {