Added backend folder structure.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
const cloudinary = require("cloudinary").v2;
|
||||
const fs = require("fs");
|
||||
|
||||
const uploadOnCloudinary = async (localFilePath) => {
|
||||
try {
|
||||
if (!localFilePath) return null;
|
||||
|
||||
const responce = await cloudinary.uploader.upload(localFilePath, {
|
||||
resource_type: "auto",
|
||||
});
|
||||
|
||||
// console.log("File is uploaded successfully");
|
||||
fs.unlinkSync(localFilePath, () => {
|
||||
console.log("file removed successfully");
|
||||
});
|
||||
return responce.url;
|
||||
} catch (error) {
|
||||
fs.unlinkSync(localFilePath);
|
||||
console.log("file removed successfully");
|
||||
return null;
|
||||
}
|
||||
};
|
||||
module.exports = { uploadOnCloudinary };
|
||||
@@ -0,0 +1,25 @@
|
||||
const nodemailer = require("nodemailer");
|
||||
|
||||
const sendEmail = async (options) => {
|
||||
const transporter = await nodemailer.createTransport({
|
||||
service: "gmail",
|
||||
host: process.env.HOST,
|
||||
port: process.env.EMAIL_PORT,
|
||||
secure: false,
|
||||
auth: {
|
||||
user: process.env.SMPT_MAIL, // senders email
|
||||
pass: process.env.SMPT_PASSWORD, // app passoword created for your app by using step :: google account> manage your google account >security>enable two step verification > search app password and create password for your app
|
||||
},
|
||||
});
|
||||
|
||||
const mailOptions = {
|
||||
from: "",
|
||||
to: options.email,
|
||||
subject: options.subject,
|
||||
text: options.message,
|
||||
};
|
||||
|
||||
await transporter.sendMail(mailOptions);
|
||||
};
|
||||
|
||||
module.exports = sendEmail;
|
||||
Reference in New Issue
Block a user