<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Vishwanath </title>
    <description>The latest articles on DEV Community by Vishwanath  (@vishwanath231).</description>
    <link>https://dev.to/vishwanath231</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F722087%2F16f1ae73-1403-4825-9b7e-bda37ca90e57.jpg</url>
      <title>DEV Community: Vishwanath </title>
      <link>https://dev.to/vishwanath231</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vishwanath231"/>
    <language>en</language>
    <item>
      <title>MERN FOLDERS &amp; FILES STRUCTURE</title>
      <dc:creator>Vishwanath </dc:creator>
      <pubDate>Tue, 19 Jul 2022 08:14:00 +0000</pubDate>
      <link>https://dev.to/vishwanath231/mern-folders-files-structure-d4k</link>
      <guid>https://dev.to/vishwanath231/mern-folders-files-structure-d4k</guid>
      <description>&lt;p&gt;This article tells about MERN Stack folders and files structure, How to name folders and files! first, know that. Lots of beginner developers' mistakes were backend and frontend folders were created in different locations which was a big mistake. When you deploy your project problem will come, First we create the folder and the folder name is MERN-STRUCTURE. Inside the folder create two sub-folders Backend and frontend folders.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn7v4uno1o80ug8rwuw9r.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn7v4uno1o80ug8rwuw9r.jpg" alt="MERN FOLDER STRUCTURE"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;we use backend and frontend separate folders, and the backend folder was the server connection and database connection and controls the data and rest APIs. The frontend folder was UI components and .env files were environment variables using server and help to secret port number and database name and secret keys. .gitignore file was ignored in the node_modules folder and .env files, why use gitignore files? The gitignore file helps to store particular files and folders in the GitHub repository.&lt;/p&gt;

&lt;h4&gt;
  
  
  BACKEND FOLDERS STRUCTURE
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6sej3ch4c55sz16ninpq.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6sej3ch4c55sz16ninpq.jpg" alt="Backend Folder Structure"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Backend folder inside the lots of sub-folders like this, Config folder was database configuration. The controller folder was the control data and the rest APIs. Middleware folder was authenticated middleware and error middleware, routes folder was rest APIs and router the location. server file important to all files is a configuration in the server file.&lt;/p&gt;

&lt;h4&gt;
  
  
  FRONTEND FOLDER STRUCTURE
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo1ytajuug9b6xx6xz0h3.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo1ytajuug9b6xx6xz0h3.jpg" alt="Frontend Folder Stucture"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The frontend folder was UI components and easy to display the data and easy way to understand the client. I have used React for the frontend library and React is reduce your code and reusability. Redux is a tool for state management using reactjs.&lt;/p&gt;




&lt;p&gt;THANKS FOR READING THIS ARTICLE ❤️&lt;/p&gt;

</description>
      <category>structure</category>
      <category>webdev</category>
    </item>
    <item>
      <title>React UseEffect()</title>
      <dc:creator>Vishwanath </dc:creator>
      <pubDate>Wed, 13 Jul 2022 14:13:31 +0000</pubDate>
      <link>https://dev.to/vishwanath231/react-useeffect-4khn</link>
      <guid>https://dev.to/vishwanath231/react-useeffect-4khn</guid>
      <description>&lt;p&gt;This article tells about React UseEffect(), This central concept react with lifecycle components to render your code.&lt;/p&gt;

&lt;h4&gt;
  
  
  UseEffect Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
UseEffect(() =&amp;gt; {
----------your code -----------
},[])

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;UseEffect really helps to render your code and your code inside the UseEffect hooks. First run, in UseEffect hooks after running the codes.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to learn Solidity</title>
      <dc:creator>Vishwanath </dc:creator>
      <pubDate>Sat, 09 Jul 2022 13:25:03 +0000</pubDate>
      <link>https://dev.to/vishwanath231/how-to-learn-solidity-3ilj</link>
      <guid>https://dev.to/vishwanath231/how-to-learn-solidity-3ilj</guid>
      <description></description>
      <category>blockchain</category>
      <category>solidity</category>
    </item>
    <item>
      <title>NODEMAILER USING NODE</title>
      <dc:creator>Vishwanath </dc:creator>
      <pubDate>Sat, 09 Jul 2022 10:23:36 +0000</pubDate>
      <link>https://dev.to/vishwanath231/nodemailer-using-node-4a1n</link>
      <guid>https://dev.to/vishwanath231/nodemailer-using-node-4a1n</guid>
      <description>&lt;p&gt;This article discusses how to configure nodemailer in your code. Quickly understand the code and implement your code. Let's start&lt;/p&gt;

&lt;p&gt;Setup folder structure like this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvcbmgfwmcsm0bk7572hr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvcbmgfwmcsm0bk7572hr.png" alt="folder structure" width="178" height="233"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Packages
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;express&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;nodemailer&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;dotenv&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;colors&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;npm i express nodemailer dotenv colors&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Create backend folder and inside folder create file is server.js,&lt;br&gt;
Like this backend/server.js&lt;/p&gt;
&lt;h4&gt;
  
  
  backend/server.js
&lt;/h4&gt;

&lt;p&gt;In this section, we create the express app server, and listen port is 5000.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import express from 'express';
import dotenv from 'dotenv';
import colors from 'colors';
import Router from './router.js';


dotenv.config();

const app = express();

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

app.use('/api/contact', Router);


const PORT = process.env.PORT || 5000;

app.listen(PORT, () =&amp;gt; {
    console.log(`server running ${process.env.NODE_ENV} mode on port ${process.env.PORT}`.yellow.underline);
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  backend/router.js
&lt;/h4&gt;

&lt;p&gt;In this section configure the nodemailer and post your email, to email, subject, and message in the route &lt;code&gt;http://localhost:5000/api/contact&lt;/code&gt;. Using the &lt;strong&gt;Postman&lt;/strong&gt; really helps test your API. Easily find errors and nodemailer working or not&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import express from 'express';
const router  = express.Router();
import nodemailer from 'nodemailer';


router.post('/', (req, res) =&amp;gt; {

    const { fromEmail, toEmail, subject, message } = req.body;

    const output = `
        &amp;lt;div style="font-family:'Sen',sans-serif;"&amp;gt;
            &amp;lt;h3&amp;gt;Subject&amp;lt;/h3&amp;gt;
            &amp;lt;p style="margin-left: 1rem;"&amp;gt;${subject}&amp;lt;/p&amp;gt;
            &amp;lt;h3&amp;gt;Message&amp;lt;/h3&amp;gt;
            &amp;lt;p style="margin-left: 1rem;"&amp;gt;${message}&amp;lt;/p&amp;gt;
        &amp;lt;/div&amp;gt;
    `;

    // create reusable transporter object using the default SMTP transport
    let transporter = nodemailer.createTransport({
        service: 'gmail',
        port: 465,
        secure: true, // use SSL // true for 465, false for other ports
        auth: {
            user: `${fromEmail}`, // generated ethereal user
            pass: '---------'  // generated ethereal password
        },
        tls:{
            rejectUnAuthorized:true
        }

    });

    // setup email data with unicode symbols
    let mailOptions = {
        from: `"Contact" &amp;lt;${fromEmail}&amp;gt;`, // sender address
        to: `${toEmail}`, // list of receivers
        subject: `${subject}`, // Subject line
        text: `${message}`, // plain text body
        html: output // html body
    };

    // send mail with defined transport object
    transporter.sendMail(mailOptions, (error, info) =&amp;gt; {
        if (error) {
            return res.status(401).json({
                msg: error
            });
        }
        // console.log('Message sent: %s', info.messageId);   
        // console.log('Preview URL: %s', nodemailer.getTestMessageUrl(info));

        if (info) {
            return res.status(200).json({
                msg:`Message has been sent ${toEmail}`
            });
        }
    });

})



export default router;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I trust this article helps your code and understand the configure the nodemailer.&lt;/p&gt;

&lt;p&gt;Thanks for reading this article ❤&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/vishwanath231"&gt;Github&lt;/a&gt; | &lt;a href="https://twitter.com/vishwanath231"&gt;Twitter&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
