import fastifyStatic from '@fastify/static'; import fastify from 'fastify'; import { fastifyRenderRouter } from '../renderer/fastify'; import { getPath, isDev, port } from './shared'; const IS_PRERENDER = true; export async function fastifyServer() { const app = fastify({ logger: { prettyPrint: isDev, }, }); if (isDev || !IS_PRERENDER) { app.register(fastifyRenderRouter, { isProduction: !isDev }); } else { app.register(fastifyStatic, { root: getPath('dist/client'), }); } app.listen(port); } if (require.main === module) { fastifyServer(); }