import { Router } from "express";
import { requireAuth } from "../../middleware/auth.js";
import { asyncHandler } from "../../middleware/errorHandler.js";
import * as controller from "./controller.js";

export const friendsRouter = Router();

friendsRouter.use(requireAuth);

friendsRouter.get("/", asyncHandler(controller.list));
friendsRouter.get("/requests", asyncHandler(controller.requests));
friendsRouter.get("/search", asyncHandler(controller.search));
friendsRouter.post("/requests", asyncHandler(controller.sendRequest));
friendsRouter.post("/requests/:id/accept", asyncHandler(controller.accept));
friendsRouter.post("/requests/:id/decline", asyncHandler(controller.decline));
friendsRouter.delete("/:id", asyncHandler(controller.unfriend));
friendsRouter.post("/:id/block", asyncHandler(controller.block));
