im dumb
This commit is contained in:
23
projects/common/src/utils/api-utils.ts
Normal file
23
projects/common/src/utils/api-utils.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import ky from "ky";
|
||||
|
||||
type ApiHealth = {
|
||||
online: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the health of the api server.
|
||||
*
|
||||
* @param url the url of the api
|
||||
*/
|
||||
export async function getApiHealth(url: string): Promise<ApiHealth> {
|
||||
try {
|
||||
await ky.get(url);
|
||||
return {
|
||||
online: true,
|
||||
};
|
||||
} catch {
|
||||
return {
|
||||
online: false,
|
||||
};
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user