import { Func } from './Func'; import { CacheAge } from './CacheAge'; import { Construct } from './Constructor'; import { meta } from './Meta'; export interface Store { execute: (fetch: From, f: Func, From>) => Promise; } export type CacheOptions = { expiresIn?: CacheAge; store?: Construct; }; export const toCacheOptions = (co: Partial): CacheOptions => ({ expiresIn: co.expiresIn ?? '5m', store: co.store, }); export const cache = (options: Partial): ClassDecorator => (subject: unknown): void => { meta(subject).set('cache', toCacheOptions(options)); };