Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default (name: string, dflt: boolean) => (context: Context) => {
const request = context.getRequest();
const forced = prop('cacheForce', request);
const forcedSpecific = prop(`${name}CacheForce`, request);
const disabled = propEq('cache', false, request);
const enabledSpecific = propOr(`${name}Cache`, disabled ? false : dflt, request);
const isComplete = context.getStatus() === Status.COMPLETE;
if (context.getStatus() === Status.INIT) {
context.updateExternalMeta(CACHE, {
forced,
enabled: !disabled,
[`${name}Enabled`]: enabledSpecific,
[`${name}Force`]: forcedSpecific,
});
}
if (forcedSpecific) {
return isComplete;
}