import type { FastifyInstance } from "fastify"
import {
  getBlockedLogins,
  resetLoginBlock,
  resetAllLoginBlocks,
} from "./route.admin.cache"
import deploy from "./route.deploy"
import login from "./route.user.login"
import checkToken from "./route.user.checkToken"
import getAllCollections from "./route.collection.getAll"
import deleteCollections from "./route.collection.remove"

const registerRoutes = async (fastify: FastifyInstance) => {
  await fastify.get("/system/deploy", deploy(fastify))

  await fastify.post("/user/login", login(fastify))
  await fastify.get("/user/check-token", checkToken(fastify))

  await fastify.get("/admin/cache/blocks", getBlockedLogins(fastify))
  await fastify.delete("/admin/cache/blocks/:key", resetLoginBlock(fastify))
  await fastify.delete("/admin/cache/blocks", resetAllLoginBlocks(fastify))

  await fastify.get("/admin/collections/all", getAllCollections(fastify))
  await fastify.delete("/admin/collections", deleteCollections(fastify))
}
export default registerRoutes
