import { html, useCtx } from "sosse"; import React, { Fragment } from "react"; import render from "preact-render-to-string"; import { Express } from "express"; import { otion } from "sosse/otion"; import { css } from "otion"; import { htmlData } from "sosse/uni"; import { SsrInjectCounter, SuspenseInjectCounter, LazyInjectCounter, Box, HydrateColorContext, } from "../injects"; import { ColorContext } from "../context"; const ctx = useCtx(); export const homeRoute = async function (app: Express) { globalThis.count = globalThis.count || 1; // Home route app.get("/", (req, res) => res.send( otion(() => { htmlData({ count: globalThis.count }); return html({ title: "Hello world", head: render( ), bodyAttrs: { class: css({ selectors: { "& > #app": { width: "40rem", margin: "auto", }, }, }), }, body: render(

hello visitor {globalThis.count++}

) + ctx.assets.index.html, ctx, }); }) ) ); };