import fp from "fastify-plugin"; import staticPlugin from "@fastify/static"; import { resolve } from "path"; import { logDir } from "./logger.js"; export default fp( async ( server: any, { basePath, index, dirs, dirname = "", silent = false, }: { basePath?: string; index?: string | boolean; dirs: string[]; dirname?: string; silent?: boolean; }, ) => { const prefix = basePath; const root = dirs.map((dir) => resolve(dirname, dir)); if (!silent) root.forEach(logDir); server.register(staticPlugin, { prefix, root, index }); }, );