import { Elysia } from "elysia"; import { html } from "@elysiajs/html"; import { staticPlugin } from "@elysiajs/static"; import { AppShell } from "./src/frontend/AppShell"; import { app } from "./src/backend"; const index = new Elysia() .use(html()) .onRequest(({ request }) => { console.log(`Request ${request.method} ${request.url}`); }) .onAfterHandle(({ request, responseValue }) => { if (request.headers.get("shell-loaded") === "true") { return responseValue; // Return the
element if the AppShell has already been loaded } return AppShell(responseValue); // Return the
element wrapped by the AppShell }) .use(staticPlugin({ assets: './src/public', prefix: '/public' })) .use(app) .listen(3000); console.log( `🦊 Elysia is running at ${index.server?.hostname}:${index.server?.port}` );