UNPKG

@replyke/express

Version:

Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.

36 lines (35 loc) 1.19 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.upload = void 0; const multer_1 = __importDefault(require("multer")); const storage = multer_1.default.memoryStorage(); // Store files in memory as Buffer const limits = { fileSize: 100 * 1024 * 1024 }; // Limit file size to 100MB // const fileFilter = ( // _: ExReq, // file: Express.Multer.File, // cb: FileFilterCallback // ) => { // const allowedMimeTypes = [ // "image/jpeg", // "image/jpg", // "image/png", // "image/webp", // "application/pdf", // ]; // if (!allowedMimeTypes.includes(file.mimetype)) { // console.error("Invalid file type: " + file.mimetype); // // Use a custom error message and pass `null` as the first argument if type error persists. // const error = new Error("Invalid file type"); // cb(error as any, false); // TypeScript needs explicit casting here // return; // } // cb(null, true); // }; exports.upload = (0, multer_1.default)({ storage, limits, // fileFilter, });