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

safe-global / safe-client-gateway / 12631213015

06 Jan 2025 10:54AM UTC coverage: 90.148% (-0.1%) from 90.284%
12631213015

Pull #2222

github

PooyaRaki
fix review comments
Pull Request #2222: Add Authentication to Redis

2831 of 3516 branches covered (80.52%)

Branch coverage included in aggregate %.

6 of 7 new or added lines in 2 files covered. (85.71%)

13 existing lines in 8 files now uncovered.

9641 of 10319 relevant lines covered (93.43%)

468.37 hits per line

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

94.44
/src/datasources/cache/cache.module.ts
1
import { Global, Module } from '@nestjs/common';
118✔
2
import { createClient } from 'redis';
118✔
3
import { IConfigurationService } from '@/config/configuration.service.interface';
118✔
4
import { CacheService } from '@/datasources/cache/cache.service.interface';
118✔
5
import { RedisCacheService } from '@/datasources/cache/redis.cache.service';
118✔
6
import { CacheReadiness } from '@/domain/interfaces/cache-readiness.interface';
118✔
7
import { ILoggingService, LoggingService } from '@/logging/logging.interface';
118✔
8
import { CacheKeyPrefix } from '@/datasources/cache/constants';
118✔
9

10
export type RedisClientType = ReturnType<typeof createClient>;
11

12
async function redisClientFactory(
13
  configurationService: IConfigurationService,
14
  loggingService: ILoggingService,
15
): Promise<RedisClientType> {
16
  const redisUser = configurationService.get<string>('redis.user');
20✔
17
  const redisPass = configurationService.get<string>('redis.pass');
20✔
18
  const redisHost = configurationService.getOrThrow<string>('redis.host');
20✔
19
  const redisPort = configurationService.getOrThrow<string>('redis.port');
20✔
20
  const client: RedisClientType = createClient({
20✔
21
    url: `redis://${redisHost}:${redisPort}`,
22
    username: redisUser,
23
    password: redisPass,
24
  });
25
  client.on('error', (err) =>
20✔
NEW
26
    loggingService.error(`Redis client error: ${err}`),
×
27
  );
28
  await client.connect();
20✔
29
  return client;
20✔
30
}
31

32
@Global()
33
@Module({
34
  providers: [
35
    {
36
      provide: 'RedisClient',
37
      useFactory: redisClientFactory,
38
      inject: [IConfigurationService, LoggingService],
39
    },
40
    { provide: CacheService, useClass: RedisCacheService },
41
    { provide: CacheReadiness, useExisting: CacheService },
42
    { provide: CacheKeyPrefix, useValue: '' },
43
  ],
44
  exports: [CacheService, CacheReadiness],
45
})
46
export class CacheModule {}
118✔
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

© 2025 Coveralls, Inc