import type { FastifyPluginCallbackTypebox } from '@fastify/type-provider-typebox' import type { Kysely } from 'kysely' import type { DB } from '../../shared/types.db.ts' import fp from 'fastify-plugin' const dbPlugin: FastifyPluginCallbackTypebox<{ kysely: Kysely }> = (fastify, { kysely }, done) => { fastify.decorate('db', kysely) fastify.addHook('onClose', () => kysely.destroy()) done() } export default fp(dbPlugin, { fastify: '5.x', name: 'dbPlugin', })