37 lines
913 B
TypeScript
37 lines
913 B
TypeScript
import { Hono } from "hono";
|
|
import { Layout } from "./layout.js";
|
|
import type InfoAPI from "../../../types/api/info";
|
|
import Config from "../../../config/peas.config.js";
|
|
import { getCookie } from "hono/cookie";
|
|
import { Locale } from "../../lib/locale.js";
|
|
import { isSignin } from "../../lib/token.js";
|
|
|
|
const Home = new Hono();
|
|
|
|
Home.get("/", async (c) => {
|
|
if (await isSignin(getCookie(c, "token") ?? "") === false) {
|
|
return c.redirect("/signin");
|
|
}
|
|
|
|
const InfoReq = await fetch(`${Config.server.origin}/api/info`, {
|
|
method: "POST",
|
|
cache: "no-store",
|
|
});
|
|
if (!InfoReq.ok) {
|
|
return c.status(500);
|
|
}
|
|
|
|
const InfoRes: InfoAPI = await InfoReq.json();
|
|
|
|
return c.html(
|
|
<Layout
|
|
title={`${Locale({ text: "Home" }, c.get("language"))} - ${InfoRes.server.name}`}
|
|
noindex
|
|
>
|
|
|
|
</Layout>
|
|
);
|
|
})
|
|
|
|
export default Home;
|