Skip to content

Commit

Permalink
chore(monitoring): rename var
Browse files Browse the repository at this point in the history
  • Loading branch information
kishore03109 committed Jun 27, 2024
1 parent 837714d commit 04e6caf
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/monitoring/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface IsomerHostedDomain {
type: typeof IsomerHostedDomainType[keyof typeof IsomerHostedDomainType]
}

type keyCdnZoneAlias = {
type KeyCdnZoneAlias = {
name: string
}

Expand All @@ -48,11 +48,11 @@ interface ReportCard {
caaRecord: string[]
}

function isKeyCdnZoneAlias(object: unknown): object is keyCdnZoneAlias {
return "name" in (object as keyCdnZoneAlias)
function isKeyCdnZoneAlias(object: unknown): object is KeyCdnZoneAlias {
return "name" in (object as KeyCdnZoneAlias)
}

function isKeyCdnResponse(object: unknown): object is keyCdnZoneAlias[] {
function isKeyCdnResponse(object: unknown): object is KeyCdnZoneAlias[] {
if (!object) return false
if (Array.isArray(object)) return object.every(isKeyCdnZoneAlias)
return false
Expand All @@ -79,12 +79,15 @@ export default class MonitoringService {
Authorization: `Basic ${btoa(`${keyCdnApiKey}:`)}`,
},
}),
(error) => new MonitoringError(`Failed to fetch zones: ${error}`)
(error) =>
new MonitoringError(`Failed to fetch zones from KeyCDN: ${error}`)
)
.map((response) => response.data.data.zonealiases)
.andThen((data) => {
if (!isKeyCdnResponse(data)) {
return errAsync(new MonitoringError("Failed to parse response"))
return errAsync(
new MonitoringError("Failed to parse response from KeyCDN")
)
}

const domains = data
Expand Down

0 comments on commit 04e6caf

Please sign in to comment.