2022-11-10 00:12:34 +05:30
|
|
|
import type { PageServerLoad } from "./$types";
|
2023-01-25 22:41:11 +05:30
|
|
|
import axios from "axios";
|
|
|
|
import { Agent } from "https";
|
|
|
|
import { env } from "$env/dynamic/private";
|
2022-11-10 00:12:34 +05:30
|
|
|
|
2023-01-25 22:41:11 +05:30
|
|
|
const agent = new Agent({
|
|
|
|
family: 4
|
|
|
|
});
|
2022-12-30 22:32:49 +05:30
|
|
|
|
2023-01-25 22:41:11 +05:30
|
|
|
export const load = (async () => {
|
|
|
|
const meta = {
|
|
|
|
title: "Home",
|
|
|
|
description: "Open source development and hosted services."
|
|
|
|
}
|
2023-01-06 15:58:16 +05:30
|
|
|
|
2023-01-25 22:41:11 +05:30
|
|
|
try {
|
|
|
|
const res = await axios(env.KUMA_URL, { httpsAgent: agent });
|
2023-01-06 15:58:16 +05:30
|
|
|
|
2023-01-25 22:41:11 +05:30
|
|
|
if (res.status === 200) {
|
|
|
|
return { announcements: res.data, ...meta };
|
|
|
|
} else {
|
|
|
|
return { error: true, message: "Error: " + res.status };
|
2022-12-30 22:32:49 +05:30
|
|
|
}
|
2023-01-25 22:41:11 +05:30
|
|
|
} catch (err) {
|
|
|
|
return { error: true, message: "Error: " + err };
|
2022-12-30 22:32:49 +05:30
|
|
|
}
|
2023-01-25 22:41:11 +05:30
|
|
|
}) satisfies PageServerLoad;
|