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

safe-global / safe-core-sdk / 15116558277

19 May 2025 03:06PM UTC coverage: 78.36% (+0.07%) from 78.287%
15116558277

Pull #1216

github

web-flow
Merge 85efb9f0c into 82cfd46b2
Pull Request #1216: feat(api-kit): Api keys integration

256 of 402 branches covered (63.68%)

Branch coverage included in aggregate %.

20 of 27 new or added lines in 4 files covered. (74.07%)

72 existing lines in 2 files now uncovered.

910 of 1086 relevant lines covered (83.79%)

4.72 hits per line

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

16.67
/packages/api-kit/src/utils/httpRequests.ts
1
export enum HttpMethod {
1✔
2
  Get = 'get',
1✔
3
  Post = 'post',
1✔
4
  Delete = 'delete'
1✔
5
}
6

7
export interface HttpRequest {
8
  url: string
9
  method: HttpMethod
10
  body?: any
11
}
12

13
export async function sendRequest<T>(
1✔
14
  { url, method, body }: HttpRequest,
15
  apiKey: string
16
): Promise<T> {
17
  const fetch = await (typeof window === 'undefined'
×
18
    ? import('node-fetch').then((m) => m.default)
×
19
    : Promise.resolve(window.fetch))
20

NEW
21
  const response = await fetch(url, {
×
22
    method,
23
    headers: {
24
      Accept: 'application/json',
25
      'Content-Type': 'application/json',
26
      Authorization: `${apiKey}`
27
    },
28
    body: JSON.stringify(body)
29
  })
30

31
  let jsonResponse: any
NEW
32
  try {
×
UNCOV
33
    jsonResponse = await response.json()
×
34
  } catch (error) {
UNCOV
35
    if (!response.ok) {
×
UNCOV
36
      throw new Error(response.statusText)
×
37
    }
38
  }
39

40
  if (response.ok) {
×
41
    return jsonResponse as T
×
42
  }
UNCOV
43
  if (jsonResponse.data) {
×
UNCOV
44
    throw new Error(jsonResponse.data)
×
45
  }
46
  if (jsonResponse.detail) {
×
UNCOV
47
    throw new Error(jsonResponse.detail)
×
48
  }
49
  if (jsonResponse.message) {
×
UNCOV
50
    throw new Error(jsonResponse.message)
×
51
  }
52
  if (jsonResponse.nonFieldErrors) {
×
UNCOV
53
    throw new Error(jsonResponse.nonFieldErrors)
×
54
  }
55
  if (jsonResponse.delegate) {
×
UNCOV
56
    throw new Error(jsonResponse.delegate)
×
57
  }
58
  if (jsonResponse.safe) {
×
UNCOV
59
    throw new Error(jsonResponse.safe)
×
60
  }
61
  if (jsonResponse.delegator) {
×
UNCOV
62
    throw new Error(jsonResponse.delegator)
×
63
  }
64
  throw new Error(response.statusText)
×
65
}
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