This file contains hidden or 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
| let transporter = nodemailer.createTransport({ | |
| host: "smtp.ethereal.email", | |
| port: 587, | |
| secure: false, // true for 465, false for other ports | |
| auth: { | |
| user: `${process.env.REACT_APP_EMAIL}`, // generated ethereal user | |
| pass: `${process.env.REACT_APP_EMAIL_PASS}`, // generated ethereal password | |
| }, | |
| }); |
This file contains hidden or 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
| const nodemailer = require('nodemailer'); | |
| exports.sendEmail = async (req, res) => { | |
| try { | |
| const outputMessage = ` | |
| <h1>Mail Details</h1> | |
| <ul> | |
| <li>First Name: ${req.body.firstname}</li> | |
| <li>Last Name: ${req.body.lastname}</li> | |
| <li>Email: ${req.body.emailaddress}</li> |
This file contains hidden or 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
| const express = require("express"); | |
| const ContactController = require("../Controller/ContactController"); | |
| const router = express.Router(); | |
| router.route("/").post(ContactController.sendEmail); | |
| module.exports = router; |
This file contains hidden or 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
| const express = require("express"); | |
| const path = require("path"); | |
| const ContactRoute = require("./Routes/ContactRoute"); | |
| const app = express(); | |
| //middleware | |
| app.use(express.static(path.resolve(__dirname, "../client/build"))); | |
| app.use(express.json()); | |
| app.use(express.urlencoded({ extended: true })); |
This file contains hidden or 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
| const express = require('express'); | |
| const path = require('path'); | |
| const dotenv = require('dotenv'); | |
| const ContactRoute = require('./Routes/ContactRoute'); | |
| const app = express(); | |
| dotenv.config(); | |
| //middleware | |
| app.use(express.static(path.resolve(__dirname, '../client/build'))); |
This file contains hidden or 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
| import { useState, createContext, useContext } from "react"; | |
| const AuthContext = createContext(); | |
| function AuthProvider({ children }) { | |
| const [loggedIn, setLoggedIn] = useState(false); | |
| const login = () => { | |
| setLoggedIn(true); | |
| }; | |
| const logout = () => { |
This file contains hidden or 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
| import React from "react"; | |
| import { Navigate, Outlet } from "react-router-dom"; | |
| import { useAuth } from "../Context/AuthContex"; | |
| const ProtectedRoutes = () => { | |
| const { loggedIn } = useAuth(); | |
| return loggedIn ? <Outlet /> : <Navigate to="/" />; | |
| }; |
This file contains hidden or 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
| <Router> | |
| <Navbar /> | |
| <Routes> | |
| <Route exact path="/" element={<Home />} /> | |
| <Route exact path="/product" element={<Product />} /> | |
| <Route exact element={<ProtectedRoutes />}> | |
| <Route exact path="/dashboard" element={<Dashboard />} /> | |
| </Route> | |
| <Route exact path="*" element={<Error404 />} /> | |
| </Routes> |
This file contains hidden or 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
| "roles": [ | |
| { | |
| "id": 1, | |
| "name": "Manager" | |
| }, | |
| { | |
| "id": 2, | |
| "name": "Engineer" | |
| }, | |
| { |
This file contains hidden or 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
| `mongodb+srv://${process.env.MONGO_USERNAME}:${process.env.MONGO_PASSWORD}@myFirstDatabase?retryWrites=true&w=majority` |