-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #276 from nishant0708/profile-page
Feat:Profile page For Canteen #253
- Loading branch information
Showing
13 changed files
with
341 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,26 @@ | ||
const config = require("cloudinary").config; | ||
const uploader = require("cloudinary").uploader; | ||
const dotenv = require("dotenv"); | ||
const cloudinary = require('cloudinary').v2; | ||
const dotenv = require('dotenv'); | ||
dotenv.config(); | ||
|
||
const cloudinaryConfig = (req, res, next) => { | ||
config({ | ||
cloudinary.config({ | ||
cloud_name: process.env.CLOUDINARY_CLOUD_NAME, | ||
api_key: process.env.CLOUDINARY_API_KEY, | ||
api_secret: process.env.CLOUDINARY_API_SECRET, | ||
}); | ||
next(); | ||
}; | ||
module.exports = { cloudinaryConfig, uploader }; | ||
|
||
const uploadImage = async (filePath) => { | ||
try { | ||
const result = await cloudinary.uploader.upload(filePath, { | ||
folder: 'canteen_images', // Specify the folder where images should be uploaded | ||
}); | ||
return result; | ||
} catch (error) { | ||
throw new Error('Error uploading image to Cloudinary'); | ||
} | ||
}; | ||
|
||
module.exports = { cloudinaryConfig, uploadImage }; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
const multer = require("multer"); | ||
const multer = require('multer'); | ||
const storage = multer.memoryStorage(); | ||
const multerUploads = multer({ storage }).single("image"); | ||
const multerUploads = multer({ | ||
storage, | ||
limits: { fileSize: 50 * 1024 * 1024 } // Set limit to 50MB | ||
}).single("image"); | ||
|
||
module.exports = multerUploads; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.