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

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);
};
