mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2024-12-02 05:19:17 -06:00
25 lines
513 B
TypeScript
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
|
|
}
|