import { PluginFastifyInstance } from "types"
import get from "./route.user.get"
import getAll from "./route.user.getAll"
import patch from "./route.user.patch"
import patchOwn from "./route.user.patchOwn"
import patchLastProject from "./route.user.patchLastProject"
import post from "./route.user.post"
import remove from "./route.user.remove"
import hardDelete from "./route.user.hardDelete"
import restore from "./route.user.restore"

const registerRoutes = async (fastify: PluginFastifyInstance) => {
  await fastify.get("/user/all", getAll(fastify))
  await fastify.get("/user/:_id", get(fastify))
  await fastify.patch("/user/:_id", patch(fastify))
  await fastify.patch("/user/self", patchOwn(fastify))
  await fastify.patch("/user/:_id/restore", restore(fastify))
  await fastify.post("/user", post(fastify))
  await fastify.delete("/user/:_id", remove(fastify))
  await fastify.delete("/user/:_id/hard", hardDelete(fastify))
  await fastify.patch(
    "/user/last-project/:projectId",
    patchLastProject(fastify),
  )
}

export default registerRoutes
