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

safe-global / safe-client-gateway / 13541491615

26 Feb 2025 10:12AM UTC coverage: 90.703% (-0.09%) from 90.792%
13541491615

Pull #2378

github

hectorgomezv
Remove test:e2e:cov temporarily
Pull Request #2378: refactor: confirmation refinement

3050 of 3701 branches covered (82.41%)

Branch coverage included in aggregate %.

59 of 73 new or added lines in 2 files covered. (80.82%)

24 existing lines in 11 files now uncovered.

10423 of 11153 relevant lines covered (93.45%)

503.58 hits per line

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

95.0
/src/datasources/network/network.module.ts
1
import { Global, Module } from '@nestjs/common';
106✔
2
import { IConfigurationService } from '@/config/configuration.service.interface';
106✔
3
import { FetchNetworkService } from '@/datasources/network/fetch.network.service';
106✔
4
import { NetworkService } from '@/datasources/network/network.service.interface';
106✔
5
import { NetworkResponse } from '@/datasources/network/entities/network.response.entity';
6
import {
106✔
7
  NetworkRequestError,
8
  NetworkResponseError,
9
} from '@/datasources/network/entities/network.error.entity';
10
import type { Raw } from '@/validation/entities/raw.entity';
11

12
export type FetchClient = <T>(
13
  url: string,
14
  options: RequestInit,
15
) => Promise<NetworkResponse<T>>;
16

17
/**
18
 * Use this factory to create a {@link FetchClient} instance
19
 * that can be used to make HTTP requests.
20
 */
21
function fetchClientFactory(
22
  configurationService: IConfigurationService,
23
): FetchClient {
24
  const requestTimeout = configurationService.getOrThrow<number>(
8✔
25
    'httpClient.requestTimeout',
26
  );
27

28
  return async <T>(
8✔
29
    url: string,
30
    options: RequestInit,
31
  ): Promise<NetworkResponse<T>> => {
32
    let urlObject: URL | null = null;
8✔
33
    let response: Response | null = null;
8✔
34

35
    try {
8✔
36
      urlObject = new URL(url);
8✔
37
      response = await fetch(url, {
6✔
38
        ...options,
39
        signal: AbortSignal.timeout(requestTimeout),
40
        keepalive: true,
41
      });
42
    } catch (error) {
43
      throw new NetworkRequestError(urlObject, error);
4✔
44
    }
45

46
    // We validate data so don't need worry about casting `null` response
47
    const data = (await response.json().catch(() => null)) as Raw<T>;
4✔
48

49
    if (!response.ok) {
2✔
50
      throw new NetworkResponseError(urlObject, response, data);
2✔
51
    }
52

UNCOV
53
    return {
×
54
      status: response.status,
55
      data,
56
    };
57
  };
58
}
59

60
/**
61
 * A {@link Global} Module which provides HTTP support via {@link NetworkService}
62
 * Feature Modules don't need to import this module directly in order to inject
63
 * the {@link NetworkService}.
64
 *
65
 * This module should be included in the "root" application module
66
 */
67
@Global()
68
@Module({
69
  providers: [
70
    {
71
      provide: 'FetchClient',
72
      useFactory: fetchClientFactory,
73
      inject: [IConfigurationService],
74
    },
75
    { provide: NetworkService, useClass: FetchNetworkService },
76
  ],
77
  exports: [NetworkService],
78
})
79
export class NetworkModule {}
106✔
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