import { Router } from "express";
import multer from "multer";
import { archivosRateLimiter } from "../middlewares/rateLimiter";
import { downloadFile } from "../controllers/downloadController";
import { uploadOrganizationFile } from "../controllers/uploadOrganizationController";
import { verifyToken } from "../middlewares/auth";

const upload = multer(); // memoria

const router = Router();

router.post(
    "/upload-by-organization",
    verifyToken,
    archivosRateLimiter,
    upload.array("files"),
    uploadOrganizationFile
);

// GET /archivos/download/:nombre  (nombre = objectName guardado en DB)
router.get("/download/:nombre", archivosRateLimiter, downloadFile);

export default router;
