import fp from "fastify-plugin"; import { logSpa } from "./logger.js"; export default fp( async ( server: any, { spa, silent = false }: { spa: boolean | string; silent?: boolean }, ) => { if (!spa) return; const fallbackFile = typeof spa === "boolean" ? "index.html" : spa; if (!silent) logSpa(fallbackFile); const spaHandler = async (_: any, reply: any) => reply.sendFile(fallbackFile); server.setNotFoundHandler(spaHandler); }, );