const express = require("express");
const router = express.Router();
const { createSignedUploadURL, downloadFiles, renameKeys, deleteFiles } = require("../media/media");
const {
  generateSignedUploadUrls: createSignedUploadURLImgproxy,
  getThumbnailUrls: getThumbnailUrlsImgproxy,
  getOriginalImageByDocumentId: getOriginalImageByDocumentIdImgproxy,
  downloadFiles: downloadFilesImgproxy,
  moveFiles: moveFilesImgproxy,
  deleteFiles: deleteFilesImgproxy
} = require("../media/imgproxy-media");
const validateFirebaseIdTokenMiddleware = require("../middleware/validateFirebaseIdTokenMiddleware");
const withUserGraphQLClientMiddleware = require("../middleware/withUserGraphQLClientMiddleware");

router.use(validateFirebaseIdTokenMiddleware);
router.use(withUserGraphQLClientMiddleware);

router.post("/sign", createSignedUploadURL);
router.post("/download", downloadFiles);
router.post("/rename", renameKeys);
router.post("/delete", deleteFiles);

router.post("/imgproxy/sign", createSignedUploadURLImgproxy);
router.post("/imgproxy/thumbnails", getThumbnailUrlsImgproxy);
router.post("/imgproxy/download", downloadFilesImgproxy);
router.post("/imgproxy/rename", moveFilesImgproxy);
router.post("/imgproxy/delete", deleteFilesImgproxy);
router.post("/imgproxy/original", getOriginalImageByDocumentIdImgproxy);

module.exports = router;
