PeerTube/server/middlewares/cache.ts
2020-01-10 10:14:04 +01:00

25 lines
513 B
TypeScript

import { Redis } from '../lib/redis'
import * as apicache from 'apicache'
// Ensure Redis is initialized
Redis.Instance.init()
const defaultOptions = {
redisClient: Redis.Instance.getClient(),
appendKey: () => Redis.Instance.getPrefix(),
statusCodes: {
exclude: [ 404, 403 ]
}
}
const cacheRoute = (extraOptions = {}) => apicache.options({
...defaultOptions,
...extraOptions
}).middleware
// ---------------------------------------------------------------------------
export {
cacheRoute
}