X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fredis.ts;h=e547537c33ca602755df4bdaef3e1886f3564fc7;hb=c1e791bad0b079af67398f6407221e6dcbb573dd;hp=06a34006012f5e0e6ae96a2e56ff23e16d1af5f9;hpb=5f7021c33d31c5255b995ae0ff86b5bbea4ea4b9;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/redis.ts b/server/lib/redis.ts index 06a340060..e547537c3 100644 --- a/server/lib/redis.ts +++ b/server/lib/redis.ts @@ -6,8 +6,8 @@ import { CONFIG, USER_PASSWORD_RESET_LIFETIME, VIDEO_VIEW_LIFETIME } from '../in type CachedRoute = { body: string, - contentType?: string - statusCode?: string + contentType: string + statusCode: string } class Redis { @@ -75,11 +75,12 @@ class Redis { } setCachedRoute (req: express.Request, body: any, lifetime: number, contentType?: string, statusCode?: number) { - const cached: CachedRoute = { - body: body.toString(), - contentType, - statusCode: statusCode.toString() - } + const cached: CachedRoute = Object.assign({}, { + body: body.toString() + }, + (contentType) ? { contentType } : null, + (statusCode) ? { statusCode: statusCode.toString() } : null + ) return this.setObject(this.buildCachedRouteKey(req), cached, lifetime) }