Skip to content

Commit

Permalink
Merge pull request HimanshuNarware#353 from Omi006/review_form
Browse files Browse the repository at this point in the history
review-form store in backend
  • Loading branch information
panwar8279 authored May 18, 2024
2 parents d21ef16 + 234478b commit f6b87d5
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 7 deletions.
2 changes: 1 addition & 1 deletion backend/src/config/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const mongoose = require("mongoose");

require("dotenv").config();

const DB_URI = process.env.MONGODB_URI || "mongodb://localhost:27017"
const DB_URI = process.env.MONGODB_URI || "mongodb://0.0.0.0:27017"

const connectToDB = async () => {
try {
Expand Down
16 changes: 14 additions & 2 deletions backend/src/controllers/specialController.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require("dotenv").config();
const mongoose = require("mongoose")
const reviewForm = require("../models/reviewForm");

const {transporter, mailOptions} = require("../config/nodemailer");

Expand Down Expand Up @@ -39,7 +40,18 @@ const sendMail = async (req, res) => {
text: generateEmailText({ name, email, review }),
html: generateEmailBody({ name, email, review })
});

const newReview = new reviewForm({
name,
email,
msg: review,
});
console.log(newReview)
try {
await newReview.save();
//console.log("SAVED DATA")
} catch (error) {
//console.log("ERROR IS SAVING DATA")
}
return res.status(200).json({ success: true });
}
catch (error) {
Expand Down
18 changes: 18 additions & 0 deletions backend/src/models/reviewForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const mongoose = require("mongoose");

const reviewFormSchema = new mongoose.Schema({
name: {
type: String,
required: true,
},
email: {
type: String,
required: true,
},
msg: {
type: String,
required: true
}
});

module.exports = mongoose.model("reviewForm", reviewFormSchema);
20 changes: 16 additions & 4 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"bootstrap": "^5.3.2",
"cheerio": "^1.0.0-rc.12",
"darkmode-js": "^1.5.7",
"dotenv": "^16.4.5",
"express": "^4.18.2",
"mongodb": "^6.2.0",
"pagination": "^0.4.6",
Expand Down

0 comments on commit f6b87d5

Please sign in to comment.