PeerTube/server/middlewares/cache.ts

25 lines
513 B
TypeScript
Raw Normal View History

2018-04-17 07:01:06 -05:00
import { Redis } from '../lib/redis'
import * as apicache from 'apicache'
2018-04-17 07:01:06 -05:00
// Ensure Redis is initialized
Redis.Instance.init()
const defaultOptions = {
redisClient: Redis.Instance.getClient(),
appendKey: () => Redis.Instance.getPrefix(),
statusCodes: {
exclude: [ 404, 403 ]
}
2018-04-17 07:01:06 -05:00
}
const cacheRoute = (extraOptions = {}) => apicache.options({
...defaultOptions,
...extraOptions
}).middleware
2018-04-17 07:01:06 -05:00
// ---------------------------------------------------------------------------
export {
2018-07-24 07:35:11 -05:00
cacheRoute
2018-04-17 07:01:06 -05:00
}