For express we have an example, wondering if anyone's done similar for fastify yet.
https://github.com/remix-run/remix/blob/main/templates/express/server.js#L60
#Has anyone got v2 dev --no-restart/manual mode working on fastify?
1 messages · Page 1 of 1 (latest)
Usually you want to do a singleton for database connections to make sure that doesn’t happen. There are examples in things like the indie stack for how to make a singleton for a database client. It involves registering it to the global space and checking if it exists globally before creating a new database
I believe this is what you may want
hmm interesting thanks. I was using this, but I thought because the app server with v2 dev completely restarts by default, this couldn't work
Ah sorry, I assumed because the —no-restart flag you weren’t using a singleton and that was causing the too many connections
the fastify adapter exports both the remixFastifyPlugin, and the actual createRequestHandler, meaning you can do exactly what the express template is doing in the interim until i can update the plugin
https://github.com/mcansh/remix-fastify/blob/main/packages/remix-fastify/src/index.ts#L3
nice thanks Logan