aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/redis.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2018-07-25 22:01:25 +0200
committerRigel Kent <sendmemail@rigelk.eu>2018-07-25 22:01:25 +0200
commitc1e791bad0b079af67398f6407221e6dcbb573dd (patch)
tree82e5944b4458dd35aa482a38f6b650eb93bb89ad /server/lib/redis.ts
parent5f7021c33d31c5255b995ae0ff86b5bbea4ea4b9 (diff)
downloadPeerTube-c1e791bad0b079af67398f6407221e6dcbb573dd.tar.gz
PeerTube-c1e791bad0b079af67398f6407221e6dcbb573dd.tar.zst
PeerTube-c1e791bad0b079af67398f6407221e6dcbb573dd.zip
expliciting type checks and predicates (server only)
Diffstat (limited to 'server/lib/redis.ts')
-rw-r--r--server/lib/redis.ts15
1 files changed, 8 insertions, 7 deletions
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
6 6
7type CachedRoute = { 7type CachedRoute = {
8 body: string, 8 body: string,
9 contentType?: string 9 contentType: string
10 statusCode?: string 10 statusCode: string
11} 11}
12 12
13class Redis { 13class Redis {
@@ -75,11 +75,12 @@ class Redis {
75 } 75 }
76 76
77 setCachedRoute (req: express.Request, body: any, lifetime: number, contentType?: string, statusCode?: number) { 77 setCachedRoute (req: express.Request, body: any, lifetime: number, contentType?: string, statusCode?: number) {
78 const cached: CachedRoute = { 78 const cached: CachedRoute = Object.assign({}, {
79 body: body.toString(), 79 body: body.toString()
80 contentType, 80 },
81 statusCode: statusCode.toString() 81 (contentType) ? { contentType } : null,
82 } 82 (statusCode) ? { statusCode: statusCode.toString() } : null
83 )
83 84
84 return this.setObject(this.buildCachedRouteKey(req), cached, lifetime) 85 return this.setObject(this.buildCachedRouteKey(req), cached, lifetime)
85 } 86 }