houseofruqaapi / config /cloudinary.js
ShieldX's picture
Upload 13 files
c0fb352 verified
raw
history blame contribute delete
869 Bytes
// config/cloudinary.js
import { v2 as cloudinary } from 'cloudinary';
import { CloudinaryStorage } from 'multer-storage-cloudinary';
import multer from 'multer';
import dotenv from 'dotenv';
dotenv.config();
// Configure Cloudinary with your credentials
cloudinary.config({
cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
api_key: process.env.CLOUDINARY_API_KEY,
api_secret: process.env.CLOUDINARY_API_SECRET,
});
// Setup the storage engine
const storage = new CloudinaryStorage({
cloudinary: cloudinary,
params: {
folder: 'house-of-ruqa-products', // The folder name inside your Cloudinary account
allowedFormats: ['jpeg', 'png', 'jpg', 'webp'],
transformation: [{ width: 1000, crop: 'limit' }], // Prevents massive file sizes
},
});
// Export the multer middleware so we can use it in our routes
export const upload = multer({ storage });