"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.faqUpload = exports.FAQ_ALLOWED_MIMES = void 0; exports.ensureFaqUploadDir = ensureFaqUploadDir; const multer_1 = __importDefault(require("multer")); const path_1 = __importDefault(require("path")); const fs_1 = __importDefault(require("fs")); const uuid_1 = require("uuid"); const MAX_BYTES = 10 * 1024 * 1024; exports.FAQ_ALLOWED_MIMES = new Set([ 'image/jpeg', 'image/png', 'image/gif', 'image/webp', 'video/mp4', 'video/webm', ]); function ensureFaqUploadDir() { const dir = path_1.default.resolve(process.cwd(), 'data', 'faq-uploads'); fs_1.default.mkdirSync(dir, { recursive: true }); return dir; } const storage = multer_1.default.diskStorage({ destination(_req, _file, cb) { cb(null, ensureFaqUploadDir()); }, filename(_req, file, cb) { const ext = path_1.default.extname(file.originalname).slice(0, 20); cb(null, `${(0, uuid_1.v4)()}${ext}`); }, }); exports.faqUpload = (0, multer_1.default)({ storage, limits: { fileSize: MAX_BYTES, files: 1 }, fileFilter(_req, file, cb) { if (exports.FAQ_ALLOWED_MIMES.has(file.mimetype)) { cb(null, true); } else { cb(new Error('File type not allowed for FAQ media')); } }, }); //# sourceMappingURL=faqUpload.js.map