Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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] };
const _getHeaders = (request: MakeRequestResult) => {
return prop('headers', _getResponse(request));
};
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;
};
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();
},
};
export const getStatus = (request: MakeRequestResult) => {
return prop('status', _getResponse(request));
};
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();
},
};
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) => {
shouldExecute: (context) => {
return makeGroupedRequest && shouldExecute && prop('batchKey', context.getRequest());
},
init: (context, next) => {