Skip to content

Commit

Permalink
Merge pull request #39 from DeterminateSystems/preflight
Browse files Browse the repository at this point in the history
Add checkin behavior which preflights the IDS backend
  • Loading branch information
lucperkins committed Jun 3, 2024
2 parents 9d66d2c + c22367f commit fe64ba3
Show file tree
Hide file tree
Showing 7 changed files with 321 additions and 12 deletions.
18 changes: 18 additions & 0 deletions dist/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

118 changes: 114 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

Empty file added src/Untitled-1
Empty file.
36 changes: 36 additions & 0 deletions src/check-in.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
export type CheckIn = {
status: StatusSummary | null;
options: { [k: string]: Feature };
};

export type StatusSummary = {
page: Page;
incidents: Incident[];
scheduled_maintenances: Maintenance[];
};

export type Page = {
name: string;
url: string;
};

export type Incident = {
name: string;
status: string;
impact: string;
shortlink: string;
};

export type Maintenance = {
name: string;
status: string;
impact: string;
shortlink: string;
scheduled_for: string;
scheduled_until: string;
};

export type Feature = {
variant: boolean | string;
payload?: string;
};
20 changes: 15 additions & 5 deletions src/ids-host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class IdsHost {
this.prioritizedURLs = urls;
}

async getRootUrl(): Promise<URL> {
async getDynamicRootUrl(): Promise<URL | undefined> {
const idsHost = process.env["IDS_HOST"];
if (idsHost !== undefined) {
try {
Expand All @@ -64,12 +64,22 @@ export class IdsHost {
}

if (url === undefined) {
url = new URL(DEFAULT_IDS_HOST);
return undefined;
} else {
// This is a load-bearing `new URL(url)` so that callers can't mutate
// getRootUrl's return value.
return new URL(url);
}
}

async getRootUrl(): Promise<URL> {
const url = await this.getDynamicRootUrl();

if (url === undefined) {
return new URL(DEFAULT_IDS_HOST);
}

// This is a load-bearing `new URL(url)` so that callers can't mutate
// getRootUrl's return value.
return new URL(url);
return url;
}

async getDiagnosticsUrl(): Promise<URL | undefined> {
Expand Down
Loading

0 comments on commit fe64ba3

Please sign in to comment.