Skip to content

Commit

Permalink
Revert "Revert "filtered out any domains not configured (#946)"" (#963)
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity authored Jun 4, 2024
1 parent 7546512 commit 08fc1b5
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 92 deletions.
25 changes: 21 additions & 4 deletions fern/apis/vercel/definition/v9/domains.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,40 @@ types:
ListDomainsResponse:
properties:
domains: list<Domain>
GetConfigResponse:
properties:
misconfigured: boolean

Domain:
properties:
name: string
verified: boolean

service:
base-path: /v9/projects/{projectId}
path-parameters:
projectId: string
base-path: /v9
auth: true
endpoints:
getConfig:
docs: |
See Vercel's docs over here: https://vercel.com/docs/rest-api/endpoints/domains#get-a-domain's-configuration
method: GET
path: /domains/{domain}/config
path-parameters:
domain: string
request:
name: GetConfigRequest
query-parameters:
teamId:
type: string
docs: The team id to filter by
response: GetConfigResponse
list:
docs: |
See Vercel's docs over here: https://vercel.com/docs/rest-api/endpoints/domains#list-all-the-domains
method: GET
path: /domains
path: /projects/{projectId}/domains
path-parameters:
projectId: string
request:
name: ListDomainsRequest
query-parameters:
Expand Down
2 changes: 1 addition & 1 deletion packages/healthchecks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"devDependencies": {
"@fern-api/fdr-sdk": "workspace:*",
"@fern-fern/vercel": "0.0.3",
"@fern-fern/vercel": "0.0.7",
"@types/jest": "^29.5.11",
"@types/node": "^18.7.18",
"@types/yargs": "^17.0.32",
Expand Down
20 changes: 17 additions & 3 deletions packages/healthchecks/src/getDocsURLs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { VercelClient } from "@fern-fern/vercel";
import { Domain } from "@fern-fern/vercel/api/resources/v9";

const VERCEL = new VercelClient({
token: process.env.VERCEL_TOKEN ?? "",
Expand All @@ -23,9 +24,22 @@ export async function getAllFernDocsWebsites(): Promise<string[]> {
teamId: "team_6FKOM5nw037hv8g2mTk3gaH7",
withGitRepoInfo: false,
});
const verifiedDomains = listDomainsResponse.domains
.filter((customDomain) => customDomain.verified)
.map((customDomain) => customDomain.name)
const domainsConfigured = await Promise.all(
listDomainsResponse.domains.map(async (customDomain) => ({
value: customDomain,
isConfigured: await isDomainConfigured(customDomain),
})),
);
const verifiedDomains = domainsConfigured
.filter((customDomain) => customDomain.value.verified && customDomain.isConfigured)
.map((customDomain) => customDomain.value.name)
.filter((domain) => !DOMAINS_TO_SKIP.includes(domain));
return [...CUSTOM_SUBPATHS, ...verifiedDomains];
}

async function isDomainConfigured(customDomain: Domain) {
const getConfigResponse = await VERCEL.v9.domains.getConfig(customDomain.name, {
teamId: "team_6FKOM5nw037hv8g2mTk3gaH7",
});
return !getConfigResponse.misconfigured;
}
Loading

0 comments on commit 08fc1b5

Please sign in to comment.