1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-03 17:59:37 +02:00

Add plugin static files cache

This commit is contained in:
Chocobozzz 2019-07-23 09:48:48 +02:00 committed by Chocobozzz
parent 7663e55a2c
commit a8b666e9f1
6 changed files with 36 additions and 20 deletions

View file

@ -19,18 +19,14 @@ async function generateRandomString (size: number) {
return raw.toString('hex')
}
interface FormattableToJSON { toFormattedJSON (args?: any) }
function getFormattedObjects<U, T extends FormattableToJSON> (objects: T[], objectsTotal: number, formattedArg?: any) {
const formattedObjects: U[] = []
objects.forEach(object => {
formattedObjects.push(object.toFormattedJSON(formattedArg))
})
interface FormattableToJSON<U, V> { toFormattedJSON (args?: U): V }
function getFormattedObjects<U, V, T extends FormattableToJSON<U, V>> (objects: T[], objectsTotal: number, formattedArg?: U) {
const formattedObjects = objects.map(o => o.toFormattedJSON(formattedArg))
return {
total: objectsTotal,
data: formattedObjects
} as ResultList<U>
} as ResultList<V>
}
const getServerActor = memoizee(async function () {