mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2024-11-24 17:50:25 -06:00
f2eb23cd87
- reduce http status codes list to potentially useful codes - convert more codes to typed ones - factorize html generator for error responses
29 lines
659 B
TypeScript
29 lines
659 B
TypeScript
import { Redis } from '../lib/redis'
|
|
import * as apicache from 'apicache'
|
|
import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes'
|
|
|
|
// Ensure Redis is initialized
|
|
Redis.Instance.init()
|
|
|
|
const defaultOptions = {
|
|
redisClient: Redis.Instance.getClient(),
|
|
appendKey: () => Redis.Instance.getPrefix(),
|
|
statusCodes: {
|
|
exclude: [
|
|
HttpStatusCode.FORBIDDEN_403,
|
|
HttpStatusCode.NOT_FOUND_404
|
|
]
|
|
}
|
|
}
|
|
|
|
const cacheRoute = (extraOptions = {}) => apicache.options({
|
|
...defaultOptions,
|
|
...extraOptions
|
|
}).middleware
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
export {
|
|
cacheRoute
|
|
}
|