• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cameri / nostream / 26382712021

25 May 2026 04:09AM UTC coverage: 62.715% (-2.4%) from 65.119%
26382712021

Pull #627

github

web-flow
Merge 96e29866f into 54139ed49
Pull Request #627: test(integration): verify response content-types across HTTP routes

1757 of 3168 branches covered (55.46%)

Branch coverage included in aggregate %.

4036 of 6069 relevant lines covered (66.5%)

7.99 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

46.43
/src/cache/client.ts
1
import { createClient, RedisClientOptions } from 'redis'
1✔
2
import { CacheClient } from '../@types/cache'
3
import { createLogger } from '../factories/logger-factory'
1✔
4

5
const logger = createLogger('cache-client')
1✔
6

7
const redactRedisUrlCredentials = (url: string): string => {
1✔
8
  try {
×
9
    const parsedUrl = new URL(url)
×
10

11
    if (!parsedUrl.username && !parsedUrl.password) {
×
12
      return url
×
13
    }
14

15
    parsedUrl.username = parsedUrl.username ? '***' : ''
×
16
    parsedUrl.password = parsedUrl.password ? '***' : ''
×
17

18
    return parsedUrl.toString()
×
19
  } catch {
20
    return url
×
21
  }
22
}
23

24
export const getCacheConfig = (): RedisClientOptions => {
1✔
25
  const password = process.env.REDIS_PASSWORD
4✔
26

27
  if (process.env.REDIS_URI) {
4✔
28
    return {
1✔
29
      url: process.env.REDIS_URI,
30
      ...(password ? { password } : {}),
1!
31
    }
32
  }
33

34
  const host = process.env.REDIS_HOST
3✔
35
  const port = process.env.REDIS_PORT
3✔
36

37
  if (password) {
3✔
38
    const username = process.env.REDIS_USER ?? 'default'
2✔
39

40
    return {
2✔
41
      url: `redis://${host}:${port}`,
42
      username,
43
      password,
44
    }
45
  }
46

47
  return {
1✔
48
    url: `redis://${host}:${port}`,
49
  }
50
}
51

52
let instance: CacheClient | undefined = undefined
1✔
53

54
export const getCacheClient = (): CacheClient => {
1✔
55
  if (!instance) {
×
56
    const config = getCacheConfig()
×
57
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
58
    const { password: _, ...loggableConfig } = config
×
59
    logger('config: %o', {
×
60
      ...loggableConfig,
61
      ...(loggableConfig.url ? { url: redactRedisUrlCredentials(loggableConfig.url) } : {}),
×
62
    })
63
    instance = createClient(config)
×
64
  }
65

66
  return instance
×
67
}
68

69
export const closeCacheClient = async (): Promise<void> => {
1✔
70
  if (instance?.isOpen) {
1!
71
    await instance.disconnect()
×
72
    instance = undefined
×
73
  }
74
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc