import { Html } from "@elysiajs/html";
import { Elysia, NotFoundError } from "elysia";

import { Home } from "../frontend/home";
import { Blog } from "../frontend/blog";
import { NotFound } from "../frontend/not-found";


export const app = new Elysia()
    .onError(({ error }) => {
        if(error instanceof NotFoundError) {
            return <NotFound />;
        }
        return error;
    })
    .get("/", () => { return <Home /> })
    .get("/:path", ({ path }) => {
        if(path === "/blog") {
            return <Blog />;
        }
        throw new NotFoundError();
    })
