Skip to content

Commit

Permalink
chore: add api host variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Timeraa committed Dec 23, 2023
1 parent 3caefa9 commit 6981f3d
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions apps/statuspage/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,25 @@ let pingResultsLast5Minutes: { timestamp: number; value: number }[] = [];
const pingJob = new CronJob("*/30 * * * * *", async () => {
let duration = 0;

const result = await ky.get("https://api.premid.app/ping", {
hooks: {
beforeRequest: [
() => {
duration = performance.now();
},
],
afterResponse: [
(_, _1, result) => {
if (result.ok) duration = Math.floor(performance.now() - duration);
},
],
},
timeout: 5000,
throwHttpErrors: false,
});
const result = await ky.get(
process.env.API_HOST ?? "https://api.premid.app/ping",
{
hooks: {
beforeRequest: [
() => {
duration = performance.now();
},
],
afterResponse: [
(_, _1, result) => {
if (result.ok) duration = Math.floor(performance.now() - duration);
},
],
},
timeout: 5000,
throwHttpErrors: false,
}
);

if (!result.ok)
return log("Failed to ping API! %d %s", result.status, result.statusText);
Expand Down

0 comments on commit 6981f3d

Please sign in to comment.