import fs from "node:fs"; import path from "node:path"; import cors from "@fastify/cors"; import { renderToStaticMarkup } from "react-dom/server"; import { estaticos } from "../src"; import { ambiente } from "./ambiente"; import { gerar } from "./listar_arquivos"; // biome-ignore lint/style/useImportType: import React, {} from "react"; import fastifyStatc from "@fastify/static"; import Fastify, {} from "fastify"; const { PORTA, PREFIXO } = ambiente; const _iframe = String(Math.random()); const criarHtml = (entrada: { // biome-ignore lint/complexity/noBannedTypes: [key: string]: string | {}; }): React.JSX.Element[] => { const retorno = [] as React.JSX.Element[]; for (const [k, v] of Object.entries(entrada)) { if (typeof v === "string") { retorno.push(

{v}

, ); } else { retorno.push(
{k} {criarHtml(v)}
, ); } } return retorno; }; gerar.then(() => { const fastify = Fastify({ logger: true, ignoreTrailingSlash: true, }); //cors fastify.register(cors, { origin: "*", }); fastify.route({ method: "GET", url: "/", handler: (req, res) => { res.redirect(`${PREFIXO}/`); }, }); fastify.route({ method: "GET", url: `${PREFIXO}/`, handler: async (request, reply) => { const html = ( Arquivos Estáticos {" "}

Arquivos Estáticos

{criarHtml(estaticos("relativo"))}