import type { FastifyInstance } from "fastify"
import fastifyPlugin from "fastify-plugin"
import rateLimit from "@fastify/rate-limit"
import configService from "@c/config/configService"

export default fastifyPlugin(async (fastify: FastifyInstance) => {
  const opts = configService.getFastifyRateLimits()
  fastify.log.info("Fastify Ratelimiter with opts " + JSON.stringify(opts))
  await fastify.register(rateLimit, { ...opts, global: true })
})
