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

safe-global / safe-client-gateway / 8163567413

05 Mar 2024 10:01PM UTC coverage: 93.185% (-0.09%) from 93.274%
8163567413

push

github

web-flow
Read CA path only if set (#1255)

This sets the `ca` parameter for the SSL configuration only if it's non-empty.

If `caPath` is empty or non-existent, its value is then `undefined` (under the SSL configuration).

1722 of 2092 branches covered (82.31%)

Branch coverage included in aggregate %.

0 of 2 new or added lines in 1 file covered. (0.0%)

3 existing lines in 3 files now uncovered.

6387 of 6610 relevant lines covered (96.63%)

346.16 hits per line

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

41.18
/src/datasources/db/postgres-database.module.ts
1
import * as postgres from 'postgres';
82✔
2
import { Module } from '@nestjs/common';
82✔
3
import { PostgresDatabaseShutdownHook } from '@/datasources/db/postgres-database.shutdown.hook';
82✔
4
import { IConfigurationService } from '@/config/configuration.service.interface';
82✔
5
import { PostgresDatabaseMigrationHook } from '@/datasources/db/postgres-database.migration.hook';
82✔
6
import * as fs from 'fs';
82✔
7

8
function dbFactory(configurationService: IConfigurationService): postgres.Sql {
NEW
9
  const caPath = configurationService.get<string>('db.postgres.ssl.caPath');
×
10
  const ca: string | undefined =
NEW
11
    caPath && caPath.length > 0 ? fs.readFileSync(caPath, 'utf8') : undefined;
×
12

UNCOV
13
  const sslConfig = configurationService.getOrThrow('db.postgres.ssl.enabled')
×
14
    ? {
15
        requestCert: configurationService.getOrThrow(
16
          'db.postgres.ssl.requestCert',
17
        ),
18
        rejectUnauthorized: configurationService.getOrThrow(
19
          'db.postgres.ssl.rejectUnauthorized',
20
        ),
21
        ca,
22
      }
23
    : false;
24
  return postgres({
×
25
    host: configurationService.getOrThrow('db.postgres.host'),
26
    port: configurationService.getOrThrow('db.postgres.port'),
27
    db: configurationService.getOrThrow('db.postgres.database'),
28
    user: configurationService.getOrThrow('db.postgres.username'),
29
    password: configurationService.getOrThrow('db.postgres.password'),
30
    ssl: sslConfig,
31
  });
32
}
33

34
@Module({
35
  providers: [
36
    {
37
      provide: 'DB_INSTANCE',
38
      useFactory: dbFactory,
39
      inject: [IConfigurationService],
40
    },
41
    PostgresDatabaseShutdownHook,
42
    PostgresDatabaseMigrationHook,
43
  ],
44
  exports: ['DB_INSTANCE'],
45
})
46
export class PostgresDatabaseModule {}
82✔
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