-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f922ce9
commit a08b39c
Showing
334 changed files
with
40,831 additions
and
1,761 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,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}`); | ||
}); | ||
}); |
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 +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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.