/*
 * Eventbus Plugin
 *
 * Adds a globally available event emitter to the fastify instance
 */
import type { FastifyInstance } from "fastify"
import fastifyPlugin from "fastify-plugin"
import eventMap from "./eventBusEventMap"
import EventEmitter from "@c/events/eventEmitter"

export default fastifyPlugin(async (fastify: FastifyInstance) => {
  const eventbus = new EventEmitter(eventMap)
  fastify.decorate("eventbus", eventbus)
})
