import { checkUser } from "@/contexts/auth";
import {
  createGetProfileController,
  createUpdateProfileController,
} from "@/contexts/profile/infrastructure";
import { NextFunction, Request, Response, Router } from "express";

export const profileRouter = (appRouter: Router) => {
  const profileRoutes: Router = Router({ mergeParams: true });

  profileRoutes.get("/", checkUser, (req: Request, res: Response, next: NextFunction) =>
    createGetProfileController(res.locals["context"]).execute(req, res, next)
  );

  profileRoutes.put("/", checkUser, (req: Request, res: Response, next: NextFunction) =>
    createUpdateProfileController(res.locals["context"]).execute(req, res, next)
  );

  appRouter.use("/profile", profileRoutes);
};
