import { Request , Response } from 'express' ; import { CacheService } from '@services/cache.service' ; description class Cache { description private static instance : Cache ; private constructor ( ) { } description static get ( ) { if ( ! Cache . instance ) { Cache . instance = new Cache ( ) ; } return Cache . instance ; } description param req param res param next async read ( req , res , next ) { if ( ! CacheService . isCachable ( req ) ) { return next ( ) ; } const cached = CacheService . engine . get ( CacheService . key ( req ) ) as unknown ; if ( cached ) { res . status ( 200 ) ; res . json ( cached ) ; return ; } next ( ) ; } } const cache = Cache . get ( ) ; export { cache as Cache } ;