import { checkUser } from "@/contexts/auth";
import { NextFunction, Request, Response, Router } from "express";
import { listArticlesController } from "../../../../contexts/catalog/infrastructure/express/controllers";

export const catalogRouter = (appRouter: Router) => {
  const catalogRoutes: Router = Router({ mergeParams: true });

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

  appRouter.use("/catalog", catalogRoutes);
};
