1 import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
2 import { Redis } from '../../lib/redis'
3 import { ApiCache, APICacheOptions } from './shared'
5 // Ensure Redis is initialized
8 const defaultOptions: APICacheOptions = {
10 HttpStatusCode.FORBIDDEN_403,
11 HttpStatusCode.NOT_FOUND_404
15 function cacheRoute (duration: string) {
16 const instance = new ApiCache(defaultOptions)
18 return instance.buildMiddleware(duration)
21 function cacheRouteFactory (options: APICacheOptions) {
22 const instance = new ApiCache({ ...defaultOptions, ...options })
24 return instance.buildMiddleware.bind(instance)
27 // ---------------------------------------------------------------------------