mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2024-12-02 05:19:17 -06:00
cea093bca5
We don't need to start it at this point And it could lead to issues when nodejs is compiling peertube using sync calls
29 lines
705 B
TypeScript
29 lines
705 B
TypeScript
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
|
|
import { ApiCache, APICacheOptions } from './shared'
|
|
|
|
const defaultOptions: APICacheOptions = {
|
|
excludeStatus: [
|
|
HttpStatusCode.FORBIDDEN_403,
|
|
HttpStatusCode.NOT_FOUND_404
|
|
]
|
|
}
|
|
|
|
function cacheRoute (duration: string) {
|
|
const instance = new ApiCache(defaultOptions)
|
|
|
|
return instance.buildMiddleware(duration)
|
|
}
|
|
|
|
function cacheRouteFactory (options: APICacheOptions) {
|
|
const instance = new ApiCache({ ...defaultOptions, ...options })
|
|
|
|
return instance.buildMiddleware.bind(instance)
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
export {
|
|
cacheRoute,
|
|
cacheRouteFactory
|
|
}
|