2023-05-24 16:17:30 +02:00
|
|
|
import { building } from "$app/environment";
|
2023-03-12 04:25:53 +01:00
|
|
|
import type { LayoutServerLoad } from "./$types";
|
|
|
|
import { apiFetch } from "$lib/api/fetch";
|
2023-03-20 15:57:16 +01:00
|
|
|
import type { MetaResponse } from "$lib/api/responses";
|
2023-03-12 04:25:53 +01:00
|
|
|
|
2023-03-21 15:32:51 +01:00
|
|
|
export const load = (async () => {
|
2023-03-12 04:25:53 +01:00
|
|
|
try {
|
|
|
|
return await apiFetch<MetaResponse>("/meta", {});
|
|
|
|
} catch (e) {
|
2023-05-24 16:17:30 +02:00
|
|
|
console.warn("error fetching meta endpoint:", e);
|
|
|
|
|
|
|
|
if (building) {
|
|
|
|
// just return an empty object--this only affects the three static pages, nothing else, so it's fine
|
|
|
|
return {
|
|
|
|
git_repository: "",
|
|
|
|
git_commit: "",
|
|
|
|
users: {
|
|
|
|
total: 0,
|
|
|
|
active_month: 0,
|
|
|
|
active_week: 0,
|
|
|
|
active_day: 0,
|
|
|
|
},
|
|
|
|
members: 0,
|
|
|
|
require_invite: false,
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
throw e;
|
|
|
|
}
|
2023-03-12 04:25:53 +01:00
|
|
|
}
|
|
|
|
}) satisfies LayoutServerLoad;
|