Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
SapanaDashoni15 committed Jan 21, 2025
1 parent f922ce9 commit a08b39c
Show file tree
Hide file tree
Showing 334 changed files with 40,831 additions and 1,761 deletions.
47 changes: 46 additions & 1 deletion Backend/app.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,55 @@
import express from "express";
import { config } from "dotenv";
import cors from "cors";
import { sendEmail } from "./utils/sendEmail.js";

const app = express();
const router = express.Router();

config({ path: "./config.env" });

app.use(
cors({
origin: [process.env.FRONTEND_URL],
methods: ["POST"],
credentials: true,
})
);

app.use(express.json());
app.use(express.urlencoded({ extended: true }));

router.post("/send/mail", async (req, res, next) => {
const { name, email, message } = req.body;
if (!name || !email || !message) {
return next(
res.status(400).json({
success: false,
message: "Please provide all details",
})
);
}
try {
await sendEmail({
email: "learnersapana100@gmail.com",
subject: "GYM WEBSITE CONTACT",
message,
userEmail: email,
});
res.status(200).json({
success: true,
message: "Message Sent Successfully.",
});
} catch (error) {
res.status(500).json({
success: false,
message: " Internal Server Error",
});
}
});

app.use(router);

app.listen(process.env.PORT, () => {
console.log(`Server listening at port ${process.env.PORT}`);
});
});
8 changes: 7 additions & 1 deletion Backend/config.env
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
PORT=4000
PORT=4000
FRONTEND_URL=http://localhost:5173
SMPT_HOST=smpt.gmail.com
SMPT_PORT=465
SMPT_SERVICE=Gmail
SMPT_MAIL=sapanadashoni@gmail.com
SMPT_PASSWORD=uuqx kgjt rfhp zqhg
19 changes: 12 additions & 7 deletions Backend/node_modules/.package-lock.json

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

278 changes: 0 additions & 278 deletions Backend/node_modules/dotenv/CHANGELOG.md

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

Loading

0 comments on commit a08b39c

Please sign in to comment.