<?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: Martin Isonguyo</title>
    <description>The latest articles on DEV Community by Martin Isonguyo (@isonguyom).</description>
    <link>https://dev.to/isonguyom</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%2F546238%2F3e3453fd-8550-4473-aa07-3a7881da6c19.jpeg</url>
      <title>DEV Community: Martin Isonguyo</title>
      <link>https://dev.to/isonguyom</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/isonguyom"/>
    <language>en</language>
    <item>
      <title>Why I Want to Be a Front-End Developer and How HNG Will Help Me Achieve My Goals</title>
      <dc:creator>Martin Isonguyo</dc:creator>
      <pubDate>Thu, 30 Jan 2025 16:22:57 +0000</pubDate>
      <link>https://dev.to/isonguyom/why-i-want-to-be-a-front-end-developer-and-how-hng-will-help-me-achieve-my-goals-452d</link>
      <guid>https://dev.to/isonguyom/why-i-want-to-be-a-front-end-developer-and-how-hng-will-help-me-achieve-my-goals-452d</guid>
      <description>&lt;h2&gt;
  
  
  Why Frontend Development
&lt;/h2&gt;

&lt;p&gt;Technology has always fascinated me, but it was my curiosity about the workings of the web that led me to frontend development. Coming from a marine engineering background, I soon realised the need for more innovative solutions in the maritime industry. This inspired me to transition fully into tech, where I could blend creativity with problem-solving to build impactful solutions.&lt;/p&gt;

&lt;p&gt;Frontend development excites me because it allows me to bridge the gap between complex problems and user-friendly solutions.  My goal is to continue refining my skills to build seamless, efficient, and engaging web experiences.&lt;/p&gt;

&lt;h2&gt;
  
  
  How HNG Can Help
&lt;/h2&gt;

&lt;p&gt;The HNG Internship is an incredible opportunity to improve my skills through real-world projects, mentorship, and collaboration. It provides a structured environment where I can learn industry best practices, work on team-based tasks, and gain hands-on experience with modern frontend technologies.&lt;/p&gt;

&lt;p&gt;One of the key benefits of HNG is its exposure to high-demand frameworks like React, and Next.js. By learning from experienced developers and participating in real-life challenges, I’ll sharpen my problem-solving skills and improve my ability to write clean, maintainable code. Additionally, networking with like-minded individuals will expand my professional connections and open doors for future career opportunities.&lt;/p&gt;

&lt;h2&gt;
  
  
  My Goals for the HNG Internship
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Strengthen My Frontend Development Skills:&lt;/strong&gt; I aim to become proficient in building scalable and responsive applications. By actively engaging in tasks and seeking feedback from mentors, I’ll refine my ability to create efficient user interfaces.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Contribute to Real-World Projects:&lt;/strong&gt; During the internship, I plan to collaborate on projects that align with my interests in maritime digitalization. By leveraging Vue.js, I’ll work on interactive applications that solve real problems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Build a Strong Professional Network:&lt;/strong&gt; Connecting with fellow developers and industry experts will be crucial for my growth. I’ll actively participate in discussions, share my learnings, and seek mentorship opportunities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Improve My Problem-Solving Abilities:&lt;/strong&gt; Through coding challenges and debugging exercises, I’ll enhance my ability to write optimized code and solve frontend development issues efficiently.&lt;/p&gt;

&lt;p&gt;For businesses looking to build dynamic web applications, they can Hire &lt;a href="https://hng.tech/hire/vuejs-developers" rel="noopener noreferrer"&gt;Vue.js Developers&lt;/a&gt; to create seamless user experiences. The demand for frontend developers continues to grow, and this internship is the perfect platform to refine my skills and contribute to impactful projects.&lt;/p&gt;

&lt;p&gt;In conclusion, my journey into frontend development is fueled by a passion for creating digital solutions that enhance industries like maritime technology. With HNG’s structured training, mentorship, and real-world experience, I am confident that I will achieve my goal of becoming a skilled frontend developer ready to tackle industry challenges.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>The distinctions between React and Vue</title>
      <dc:creator>Martin Isonguyo</dc:creator>
      <pubDate>Sat, 29 Jun 2024 09:46:22 +0000</pubDate>
      <link>https://dev.to/isonguyom/the-distinctions-between-react-and-vue-2b3i</link>
      <guid>https://dev.to/isonguyom/the-distinctions-between-react-and-vue-2b3i</guid>
      <description>&lt;p&gt;Frontend development is a technical skill that involves using various technical tools to create the interactive part of a website or web application.&lt;br&gt;
A front-end developer achieves this by using languages like HTML, CSS, and JavaScript.&lt;br&gt;
HTML is a markup language used to develop a website's structure. CSS is responsible for the website's beauty, while JavaScript is used to program its behavior.&lt;br&gt;
Various frameworks enable a front-end developer to build user-friendly and responsive websites. Some of these frameworks are React and Vuejs. &lt;/p&gt;




&lt;h2&gt;
  
  
  What is React?
&lt;/h2&gt;

&lt;p&gt;React is a JavaScript web framework for building interactive web interfaces. React is a component-based framework that allows developers to create reusable components. It functions by creating a virtual DOM of the real DOM, which it uses to efficiently update changes without re-rendering the entire page of a website.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is Vue?
&lt;/h2&gt;

&lt;p&gt;Vue is also a component-based JavaScript web framework that allows the creation of beautiful web user interfaces. Its key feature is its reactive data binding system. This allows developers to create dynamic and interactive web interfaces by automatically updating the DOM when the underlying data changes. &lt;/p&gt;




&lt;h2&gt;
  
  
  React vs Vue.
&lt;/h2&gt;

&lt;p&gt;Vue and React share many similarities in their purpose and mode of operation. However, several distinctions between them make each ideal for specific business scenarios.&lt;/p&gt;




&lt;h2&gt;
  
  
  Similarities
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;They are both JavaScript web frameworks.&lt;/li&gt;
&lt;li&gt;They employ a component-based approach. &lt;/li&gt;
&lt;li&gt;The virtual DOM system is used for efficient rendering of pages.&lt;/li&gt;
&lt;li&gt;They have a large community. &lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Differences
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Vue is easier to learn for beginners compared to React.&lt;/li&gt;
&lt;li&gt;React uses the JSX approach for development, while Vue uses a template-based system.&lt;/li&gt;
&lt;li&gt;Vue is a lighter-weight framework more suitable for small and medium-scale projects than React.&lt;/li&gt;
&lt;li&gt;React has a larger community and offers more job opportunities than Vue.&lt;/li&gt;
&lt;li&gt;Vue has an in-built state management system, while React relies on libraries.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;React and Vue are very efficient JavaScript frameworks. In deciding which one to use for your projects, balance your skill sets and the project's demands.&lt;/p&gt;

</description>
      <category>hng</category>
      <category>react</category>
      <category>vue</category>
      <category>webdev</category>
    </item>
    <item>
      <title>HOW TO BUILD A MEVN APP WITH VITE FRONTEND (PART 3)</title>
      <dc:creator>Martin Isonguyo</dc:creator>
      <pubDate>Mon, 21 Aug 2023 15:43:54 +0000</pubDate>
      <link>https://dev.to/isonguyom/how-to-build-a-mevn-app-with-vite-frontend-part-3-j9m</link>
      <guid>https://dev.to/isonguyom/how-to-build-a-mevn-app-with-vite-frontend-part-3-j9m</guid>
      <description>&lt;h2&gt;
  
  
  CONFIGURE APP FOR PRODUCTION
&lt;/h2&gt;

&lt;p&gt;Congratulations! You have successfully developed your MEVN CRUD application, but we need to do some configuration to run it in a production environment.&lt;br&gt;
First, go to your &lt;code&gt;vite.config.js&lt;/code&gt; file in your &lt;code&gt;client&lt;/code&gt; folder and add the following to &lt;code&gt;defineConfig&lt;/code&gt; method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;build: {
    // generate manifest.json in outDir
    manifest: true,
    rollupOptions: {
      // overwrite default .html entry
      input: './src/main.js',
    },
  },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This instructs Vite to generate a Manifest file when building our frontend, with &lt;code&gt;src/main.js&lt;/code&gt; serving as the entry point.&lt;/p&gt;

&lt;p&gt;We must now update our &lt;code&gt;index.html.ejs&lt;/code&gt; to allow us to switch rendering between development and production. &lt;code&gt;ejs&lt;/code&gt; template engine makes this task easy to accomplish; it allows us to embed executable Javascript code in our HTML file.&lt;br&gt;
Go to your &lt;code&gt;index.html.ejs&lt;/code&gt; file in your &lt;code&gt;views&lt;/code&gt; folder and replace the content with the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;

&amp;lt;head&amp;gt;
  &amp;lt;meta charset="UTF-8" /&amp;gt;
  &amp;lt;link rel="icon" href="/favicon.ico" /&amp;gt;
  &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0" /&amp;gt;
  &amp;lt;title&amp;gt;Vite + MEVN&amp;lt;/title&amp;gt;
  &amp;lt;% if (environment==='production' ) { %&amp;gt;
    &amp;lt;link rel="stylesheet" href="&amp;lt;%= manifest['src/main.css'].file %&amp;gt;" /&amp;gt;
    &amp;lt;% } %&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;
  &amp;lt;div id="app"&amp;gt;&amp;lt;/div&amp;gt;

  &amp;lt;% if (environment==='production' ) { %&amp;gt;
    &amp;lt;script type="module" src="&amp;lt;%= manifest['src/main.js'].file %&amp;gt;"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;% } else { %&amp;gt;
      &amp;lt;script type="module" src="http://localhost:5173/@vite"&amp;gt;&amp;lt;/script&amp;gt;
      &amp;lt;script type="module" src="http://localhost:5173/src/main.js"&amp;gt;&amp;lt;/script&amp;gt;
      &amp;lt;% } %&amp;gt;
&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Some JavaScript conditions have been added between &lt;code&gt;&amp;lt;% %&amp;gt;&lt;/code&gt; tags that &lt;code&gt;ejs&lt;/code&gt; must execute to decide which stylesheets and scripts to execute.&lt;/p&gt;

&lt;p&gt;Head over to your &lt;code&gt;server&lt;/code&gt; folder and replace the contents of &lt;code&gt;homeRouter.js&lt;/code&gt;file with the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//homeRouter.js
import express from "express";
import path from "path";
import { fileURLToPath } from "url";
import fs from "fs/promises";

const router = express.Router();
const __filename = fileURLToPath(import.meta.url);

const __dirname = path.dirname(__filename);

const environment = process.env.NODE_ENV;

router.get("/*", async (_req, res) =&amp;gt; {
  const data = {
    environment,
    manifest: await parseManifest(),
  };

  res.render(
    path.join(__dirname, "../../client/views", "index.html.ejs"),
    data
  );
});

const parseManifest = async () =&amp;gt; {
  if (environment !== "production") return {};

  const manifestPath = path.join(
    __dirname,
    "../../client",
    "dist",
    "manifest.json"
  );
  const manifestFile = await fs.readFile(manifestPath);

  return JSON.parse(manifestFile);
};

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

&lt;/div&gt;



&lt;p&gt;A new path has been created for our home page router to render from the manifest file in production environment.&lt;/p&gt;

&lt;p&gt;If you did the optional section in Part 2, you must create a file path for your production assets so they can load in a production environment.&lt;br&gt;
Add the following to your &lt;code&gt;index.js&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// index.js
---
const distPath = path.join(path.resolve(), "../client/dist"); // production assets file path

---

// Create route
// Assets path based on the environment running
if (process.env.NODE_ENV === "production") {
  app.use("/", express.static(distPath));
} else {
  app.use("/", express.static(publicPath));
  app.use("/src", assetsRouter);
}
---
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your final &lt;code&gt;index.js&lt;/code&gt; file should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// index.js
import express from "express";
import mongoose from "mongoose";
import cors from "cors";
import bodyParser from "body-parser";
import dotenv from "dotenv";
import path from "path";
import TodoListRoutes from "./routes/api/TodoList.js";
import homeRouter from "./routes/homeRouter.js"
import assetsRouter from "./routes/assestsRouter.js";

const app = express();
const publicPath = path.join(path.resolve(), "../client/public"); // public assets file path
const distPath = path.join(path.resolve(), "../client/dist"); // production assets file path

dotenv.config();

app.use(cors()); // to allow cross origin requests
app.use(bodyParser.json()); // to convert the request into JSON
app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/xwww-

// Connect to database
mongoose
  .connect(process.env.MONGO_URI, {
    useNewUrlParser: true,
    useUnifiedTopology: true,
  })
  .then(() =&amp;gt; console.log("MongoDB database Connected..."))
  .catch((err) =&amp;gt; console.log(err));



// Create route
// Assets path based on the environment running
if (process.env.NODE_ENV === "production") {
  app.use("/", express.static(distPath));
} else {
  app.use("/", express.static(publicPath));
  app.use("/src", assetsRouter);
}
app.use("/api/todoList", TodoListRoutes);
app.use(homeRouter);

app.listen(process.env.PORT, () =&amp;gt;
  console.log(`App is running on http://localhost:${process.env.PORT}`)
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lastly, go to to &lt;code&gt;package.json&lt;/code&gt; file in your &lt;code&gt;server&lt;/code&gt; folder and add the following scripts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"start": "set NODE_ENV=production&amp;amp;&amp;amp; node index.js --ignore ../client/",
     "build": "npm run build --prefix ../client/"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run &lt;code&gt;npm run build&lt;/code&gt;, then &lt;code&gt;npm start&lt;/code&gt;. Your app will run on &lt;code&gt;http://localhost:3000/&lt;/code&gt; in production mode. Hurray! Your app is ready for deployment.&lt;/p&gt;




&lt;h2&gt;
  
  
  BONUS: HOW TO DEPLOY A NODE.JS APPLICATION ON RENDER
&lt;/h2&gt;

&lt;p&gt;You'll want to see your application live on the internet now that it's ready for deployment. There are a few platforms that provide free Node.js application deployment, but Render is one of the simplest to set up. Render is a unified cloud that allows you to build and host all of your apps and websites while offering free TLS certificates, a global CDN, DDoS protection, private networks, and Git auto deployments.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a new Github repo and push your code to it. Ensure to add your &lt;code&gt;dist&lt;/code&gt; folder to the staging area and gitignore your &lt;code&gt;.env&lt;/code&gt; file.&lt;/li&gt;
&lt;li&gt;Sign up or sign in to &lt;a href="https://dashboard.render.com/"&gt;render dashboard&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Click on &lt;code&gt;New +&lt;/code&gt; on the top right corner and click &lt;code&gt;Web Service&lt;/code&gt;.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2wZ6XFbM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x0qf0gbv9f7ed10b6noc.png" alt="Click Web Service" width="800" height="461"&gt;
&lt;/li&gt;
&lt;li&gt;Under &lt;code&gt;Github&lt;/code&gt;, on the right, click on &lt;code&gt;Configure account&lt;/code&gt;.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--db_x6DHF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4wnbzi4odiqb8li2aw8s.png" alt="Configure account" width="800" height="598"&gt;
&lt;/li&gt;
&lt;li&gt;Under &lt;code&gt;Repository Access&lt;/code&gt;, select your repo and click on &lt;code&gt;Save&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Click on the &lt;code&gt;Connect&lt;/code&gt; button beside the repository name.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TIwpjBYT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hjv5usxumr1uw6pdh4c6.png" alt="Connect repo" width="800" height="592"&gt;
&lt;/li&gt;
&lt;li&gt;Configure your deployment details as shown in the image below and click on &lt;code&gt;Create Web Service&lt;/code&gt;.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PDL28_o6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y2pnweuyf2zxtkqur2v0.png" alt="Deployment configuration" width="800" height="1132"&gt;
&lt;/li&gt;
&lt;li&gt;After deployment, click the link in the top left corner to visit your live website.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ygvX_tHz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xjc6zqeibq1igo5kxxde.png" alt="Deployment link" width="800" height="271"&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  Add .env file to render
&lt;/h3&gt;

&lt;p&gt;After publishing your app, your database data will refuse to load. This is because you did not add your &lt;code&gt;.env&lt;/code&gt; file to Github to avoid exposing your database details to the public. To add your &lt;code&gt;.env&lt;/code&gt; file to render, follow these steps:&lt;/p&gt;

&lt;p&gt;Step 1. Navigate to your render dashboard and click on your deployed app name.&lt;/p&gt;

&lt;p&gt;Step 2. Click on &lt;code&gt;Environment&lt;/code&gt; on the left menu and scroll to &lt;code&gt;Secret Files&lt;/code&gt;. Click on &lt;code&gt;Add Secret File&lt;/code&gt; button.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HeoLCanQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ivsf9gda3qdtw4d1qt30.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HeoLCanQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ivsf9gda3qdtw4d1qt30.png" alt="Secret file" width="800" height="685"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Step 3. Input &lt;code&gt;.env&lt;/code&gt; under &lt;code&gt;Filename&lt;/code&gt; and click on the Contents input field.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PH6bfaAl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ne1rv0ajp0sy7bkvhhdy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PH6bfaAl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ne1rv0ajp0sy7bkvhhdy.png" alt="Filename" width="800" height="746"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Step 4. In the displayed dialogue box, add your &lt;code&gt;.env&lt;/code&gt; file content in the File Contents textarea and click on &lt;code&gt;Done&lt;/code&gt; button.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3KsmC2h6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5mhtii5jv8bzv7arcbvr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3KsmC2h6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5mhtii5jv8bzv7arcbvr.png" alt="Add file content" width="800" height="746"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Step 5. Click on Save Changes to complete the process.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WnfpKoi4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/05s4ypyri57jc1cwyylt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WnfpKoi4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/05s4ypyri57jc1cwyylt.png" alt="Save changes" width="800" height="746"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;CONCLUSION&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Full-stack development is the dream of every developer. In this tutorial, we have been able to build a full-stack web application using the MEVN stack. The tutorial is primarily for web developers interested in the MEVN stack, but it is also helpful to any web developer who wants to understand how a full-stack web application works.&lt;br&gt;
The best way to learn any web development stack is by building applications using it. Build as many challenging projects as you can. It will help prepare you for the job market because there are a lot of opportunities for MEVN developers.&lt;/p&gt;

&lt;p&gt;If you have any questions or additions, please leave them in the comment section below.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>vite</category>
      <category>vue</category>
      <category>node</category>
    </item>
    <item>
      <title>HOW TO BUILD A MEVN APP WITH VITE FRONTEND (PART 2)</title>
      <dc:creator>Martin Isonguyo</dc:creator>
      <pubDate>Thu, 17 Aug 2023 10:46:51 +0000</pubDate>
      <link>https://dev.to/isonguyom/how-to-build-a-mevn-app-with-vite-frontend-part-2-2lh8</link>
      <guid>https://dev.to/isonguyom/how-to-build-a-mevn-app-with-vite-frontend-part-2-2lh8</guid>
      <description>&lt;h2&gt;
  
  
  Setting up Vue frontend with Vite
&lt;/h2&gt;

&lt;p&gt;We will use Vite build tool to create our frontend (client). To begin, make sure you're in the root directory &lt;code&gt;mevn-crud&lt;/code&gt; and not the &lt;code&gt;server&lt;/code&gt; folder.&lt;br&gt;
Execute these commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm create vite@latest client -- --template vue
cd client
npm install
npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Visit &lt;a href="http://localhost:5173/"&gt;http://localhost:5173/&lt;/a&gt; to see the default interface, which looks like the image below.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yUW8Rl_a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9a0w7lzktvewh6i13saq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yUW8Rl_a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9a0w7lzktvewh6i13saq.png" alt="Default Vue+Vite Interface" width="513" height="618"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Terminate your frontend, go to your &lt;code&gt;server&lt;/code&gt; folder, and run &lt;code&gt;npm run dev&lt;/code&gt;. It will run the client on &lt;code&gt;http://localhost:5173/&lt;/code&gt; and the server on &lt;code&gt;http://localhost:3000/&lt;/code&gt;. We are able to run two commands with the help of &lt;code&gt;concurrently&lt;/code&gt;, which we installed at the beginning of the tutorial.&lt;/p&gt;


&lt;h2&gt;
  
  
  Backend Integration
&lt;/h2&gt;

&lt;p&gt;Now the server and client are running on different ports. We want our applications to interact with each other and for our frontend to be accessible only through the server's port. To be able to run our app in both development and production environments, we will need a template engine. We will use &lt;code&gt;ejs&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Navigate to your &lt;code&gt;client&lt;/code&gt; folder and install ejs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install ejs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After installing the ejs template engine, rename &lt;code&gt;index.html&lt;/code&gt; to &lt;code&gt;index.html.ejs&lt;/code&gt;. Create a &lt;code&gt;views&lt;/code&gt; folder in the &lt;code&gt;client&lt;/code&gt; directory and move the renamed file into it.&lt;/p&gt;

&lt;p&gt;Go to your &lt;code&gt;server&lt;/code&gt; folder and also install the &lt;code&gt;ejs&lt;/code&gt; engine using the command above.&lt;/p&gt;

&lt;p&gt;We will need a router for our home page. Create a new file, &lt;code&gt;homeRouter.js&lt;/code&gt; inside &lt;code&gt;routes&lt;/code&gt; folder. Copy and paste the following code into your new file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// homeRouter.js
import express from "express";

const router = express.Router();

router.get("/*", (_req, res) =&amp;gt; {
  res.render("../../client/views/index.html.ejs");
});

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

&lt;/div&gt;



&lt;p&gt;Attach the &lt;code&gt;homeRouter.js&lt;/code&gt; file to the app by importing it into &lt;code&gt;index.js&lt;/code&gt; file. Add the following to &lt;code&gt;index.js&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;---
import homeRouter from "./routes/homeRouter.js";

---

// Create routes
app.use(homeRouter);
---
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To finalise our integration, go to &lt;code&gt;index.hmtl.ejs&lt;/code&gt; and replace&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script type="module" src="/src/main.js"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;with the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      &amp;lt;script type="module" src="http://localhost:5173/@vite"&amp;gt;&amp;lt;/script&amp;gt;
      &amp;lt;script type="module" src="http://localhost:5173/src/main.js"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run &lt;code&gt;npm run dev&lt;/code&gt; in your &lt;code&gt;server&lt;/code&gt; folder, then visit &lt;code&gt;http://localhost:3000/&lt;/code&gt; to confirm the application is properly integrated. If everything went fine, your application will look like the image below.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hbCWWs6h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lvhyddxfmqiwsc0it08f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hbCWWs6h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lvhyddxfmqiwsc0it08f.png" alt="Assets not load" width="491" height="616"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Notice that the Vite and Vue logos refused to load. This is because our server could not access the locations of the images. The next section will show you how to set up routes for your images and other assets. It is an optional section; you can ignore it and go to Building CRUD application frontend section.&lt;/p&gt;


&lt;h2&gt;
  
  
  Optional: Set up routes for frontend assets
&lt;/h2&gt;

&lt;p&gt;Add the following code to your &lt;code&gt;index.js&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//index.js
import path from "path";

---

const publicPath = path.join(path.resolve(), "../client/public");

---

// Create routes
app.use("/", express.static(publicPath));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We have successfully loaded our Vite logo, but the Vue logo refuses to load. Our Vue logo is not located in the &lt;code&gt;public&lt;/code&gt; directory, so we will need a special route for all assets whose path starts with &lt;code&gt;/src&lt;/code&gt;.&lt;br&gt;
Create a file named &lt;code&gt;assetsRouter.js&lt;/code&gt; in your &lt;code&gt;routes&lt;/code&gt; folder and add the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//assetsRouter.js
import express from "express";

const router = express.Router();

const supportedAssets = ["svg", "png", "jpg", "png", "jpeg", "mp4", "ogv"];

const assetExtensionRegex = () =&amp;gt; {
  const formattedExtensionList = supportedAssets.join("|");

  return new RegExp(`/.+\.(${formattedExtensionList})$`);
};

router.get(assetExtensionRegex(), (req, res) =&amp;gt; {
  res.redirect(303, `http://localhost:5173/src${req.path}`);
});

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

&lt;/div&gt;



&lt;p&gt;Attach it to your &lt;code&gt;index.js&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//index.js
import assetsRouter from "./routes/assestsRouter.js";

---

// Create routes
app.use("/src", assetsRouter);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All images now load successfully.&lt;/p&gt;




&lt;h2&gt;
  
  
  Building CRUD application frontend
&lt;/h2&gt;

&lt;p&gt;You have come a long way; truly, you deserve the accolades.&lt;/p&gt;

&lt;p&gt;We have successfully loaded our frontend on our server, but we need to ensure that our client can actually interact with our server. We will create a simple frontend that will consume our CRUD API.&lt;/p&gt;

&lt;p&gt;We will use &lt;code&gt;axios&lt;/code&gt; to consume our API, so install &lt;code&gt;axios&lt;/code&gt; in your &lt;code&gt;client&lt;/code&gt; folder.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i axios
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Go to your &lt;code&gt;src&lt;/code&gt; folder and delete the &lt;code&gt;components&lt;/code&gt; folder and everything in it. Replace the contents of your &lt;code&gt;App.vue&lt;/code&gt; file with the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;template&amp;gt;
  &amp;lt;main&amp;gt;
    &amp;lt;h1 class="title"&amp;gt;MEVN CRUD APP&amp;lt;/h1&amp;gt;

    &amp;lt;form @submit.prevent="addTodo" method="post"&amp;gt;
      &amp;lt;input class="input" v-model="title" type="text" name="name" placeholder="Enter todo" /&amp;gt;
      &amp;lt;input class="input" v-model="description" type="text" name="description" placeholder="Enter Description" /&amp;gt;
      &amp;lt;button type="submit" class="submit-btn"&amp;gt;Add Todo&amp;lt;/button&amp;gt;
    &amp;lt;/form&amp;gt;
    &amp;lt;div class="todo-wrapper"&amp;gt;
      &amp;lt;h2 class="caption"&amp;gt;Todo List&amp;lt;/h2&amp;gt;
      &amp;lt;div v-if="todos.length &amp;lt; 1"&amp;gt;Todo list is empty&amp;lt;/div&amp;gt;
      &amp;lt;ul v-else&amp;gt;
        &amp;lt;li class="todo-item" v-for="(todo, i) in todos" :key="todo._id"&amp;gt;
          &amp;lt;div class="todo"&amp;gt;
            &amp;lt;h3 class="todo-title"&amp;gt;{{ todo.title }}&amp;lt;/h3&amp;gt;
            &amp;lt;span class="todo-description"&amp;gt;{{ todo.description }}&amp;lt;/span&amp;gt;
          &amp;lt;/div&amp;gt;

          &amp;lt;div class="update-form" id="updateForm"&amp;gt;
            &amp;lt;input type="text" name="updateTitle" id="updateTodo" v-model="updateTitle" /&amp;gt;
            &amp;lt;br /&amp;gt;
            &amp;lt;input type="text" name="updateDescription" id="updateTodo" v-model="updateDescription" /&amp;gt;
          &amp;lt;/div&amp;gt;
          &amp;lt;div class="todo-btns"&amp;gt;
            &amp;lt;button type="button" class="edit-btn" @click="updateTodo($event, todo._id, i, todo)"&amp;gt;
              Edit
            &amp;lt;/button&amp;gt;
            &amp;lt;button type="button" class="del-btn" @click="delTodo(todo._id, i)"&amp;gt;
              Delete
            &amp;lt;/button&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/li&amp;gt;
      &amp;lt;/ul&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/main&amp;gt;
&amp;lt;/template&amp;gt;

&amp;lt;script&amp;gt;
import axios from "axios";

export default {
  name: "App",
  data() {
    return {
      title: "",
      description: "",
      todos: [],
      updateTitle: "",
      updateDescription: "",
    };
  },
  mounted() {
    this.getTodos();
  },
  methods: {
    async getTodos() {
      const res = await axios.get("/api/todoList");
      this.todos = res.data;
    },

    async addTodo() {
      const res = await axios.post("api/todoList/", {
        title: this.title,
        description: this.description,
      });
      this.title = "";
      this.description = "";
    },

    async delTodo(id) {
      await axios.delete(`api/todoList/${id}`);
    },

    async updateTodo(event, id, i, todo) {
      const updateForm = document.getElementsByClassName("update-form");
      const updateFormArray = [...updateForm];
      updateFormArray.forEach(async (el) =&amp;gt; {
        if (updateFormArray.indexOf(el) === i) {
          if (!el.classList.contains("active")) {
            el.classList.add("active");
            this.updateTitle = todo.title;
            this.updateDescription = todo.description;
            event.target.innerHTML = "Save";
          } else {
            const res = await axios.put(`api/todoList/${id}`, {
              title: this.updateTitle,
              description: this.updateDescription,
            });
            event.target.innerHTML = "Edit";
            el.classList.remove("active");
            this.updateTitle = "";
            this.updateDescription = "";
          }
        }
      });
    },
  },
  watch: {
    todos() {
      this.getTodos(); // Watch todos list for any change
    },
  },
};
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then replace your &lt;code&gt;style.css&lt;/code&gt; file content with this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  padding: 40px 5%;
}

main {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

.title {
  text-align: center;
  margin-bottom: 30px;
}

.input {
  padding: 20px;
  display: block;
  width: 100%;
  margin: 0 auto 10px;
}

.submit-btn {
  display: block;
  padding: 20px;
  border: 0;
  background-color: green;
  color: white;
  width: 100%;
  margin: 20px auto 0;
  cursor: pointer;
}

.todo-wrapper {
  margin-top: 50px;
}

.todo-wrapper .caption {
  margin-bottom: 15px;
}

.todo-item {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: rgb(207, 236, 207);
  padding: 10px;
}

.todo-item:nth-child(even) {
  background-color: white;
}

.todo-title {
  margin-bottom: 7px;
}

.todo-btns button {
  padding: 10px;
  cursor: pointer;
  border: 0;
}

.edit-btn {
  background-color: green;
  color: white;
  margin-right: 7px;
}

.del-btn {
  background-color: red;
  color: white;
}

.update-form {
  position: absolute;
  display: none;
}

.update-form input {
  padding: 7px;
  border: 0;
}

.update-form.active {
  display: block;
}

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

&lt;/div&gt;



&lt;p&gt;Run your app. You should be able to load, create, update, and delete from your frontend if everything went well.&lt;/p&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;We have successfully developed our MEVN Crud App. In this part, we were able to set up our Vue frontend with Vite build tool and also integrate it with our backend. Finally, we created the frontend of our application, where we consume the API we created in Part 1.&lt;/p&gt;

&lt;p&gt;Part 3 of this series will cover the configuration needed for our application to be production-ready. It also comes with a bonus you won't want to miss.&lt;/p&gt;

&lt;p&gt;Github Repository: &lt;a href="https://github.com/isonguyom/mevn-crud"&gt;https://github.com/isonguyom/mevn-crud&lt;/a&gt;&lt;br&gt;
Live Demo: &lt;a href="https://mevn-crud.onrender.com/"&gt;https://mevn-crud.onrender.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you have any questions or additions, please leave them in the comment section below.&lt;/p&gt;

</description>
      <category>mevn</category>
      <category>node</category>
      <category>vue</category>
      <category>vite</category>
    </item>
    <item>
      <title>HOW TO BUILD A MEVN APP WITH VITE FRONTEND (PART 1)</title>
      <dc:creator>Martin Isonguyo</dc:creator>
      <pubDate>Mon, 07 Aug 2023 15:56:26 +0000</pubDate>
      <link>https://dev.to/isonguyom/mevn-257p</link>
      <guid>https://dev.to/isonguyom/mevn-257p</guid>
      <description>&lt;p&gt;Full-stack web development describes the process of building the frontend and backend of a web application. It uses several technologies to accomplish this task; these technologies are collectively referred to as full-stack web development stack. There are several full-stack web development stacks, but we will be discussing the MEVN stack.&lt;/p&gt;

&lt;p&gt;This is a three-part tutorial; try to understand each step and have fun while at it. See you on the other side!&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;WHAT IS MEVN?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;MEVN is a full-stack JavaScript web development stack that comprises MongoDB, Express.js, VueJS, and NodeJS. It has grown in popularity in recent times, and it is a highly scalable stack. Its scalability makes it a great choice for developers building small projects and enterprise-level applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MongoDB&lt;/strong&gt; is a document-based database that stores data in a JSON-like format.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Express.js&lt;/strong&gt; is a lightweight Node.js web application framework. It provides robust features and utilities that make building APIs and routing easy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vue.js&lt;/strong&gt; is a modern progressive frontend JavaScript framework used for building user-friendly interfaces. It is designed to be approachable and easy to integrate for building interactive and dynamic web applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Node.js&lt;/strong&gt; is a server-side JavaScript runtime environment that allows developers to run JavaScript code on the server. It is asynchronous, event-driven, and highly scalable for developing servers and databases.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;WHAT IS VITE?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Vite is a build tool and development server that allows for quick and efficient frontend development. It is frequently used with modern frontend frameworks such as Vue.js, React, and Svelte.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;BUILDING OUR APPLICATION&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;We will be building a simple MEVN CRUD app. First, create a project directory and name it &lt;code&gt;mevn-crud&lt;/code&gt;. This is where all the magic will be done, and I am rooting for you.&lt;/p&gt;




&lt;h2&gt;
  
  
  Create server (backend) with Node.js and Express.js.
&lt;/h2&gt;

&lt;p&gt;Inside your project directory, create a folder named &lt;code&gt;server&lt;/code&gt; and navigate into it on your terminal.&lt;/p&gt;

&lt;p&gt;Initialise npm:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm init -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To use ECMAScript modules, add &lt;code&gt;"type": "module"&lt;/code&gt; to your generated &lt;code&gt;package.json&lt;/code&gt; file. Your &lt;code&gt;package.json&lt;/code&gt; should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "name": "server",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "type": "module",
  "scripts": {
    "test": "echo \"Error: no test specified\" &amp;amp;&amp;amp; exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

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

&lt;/div&gt;



&lt;p&gt;Install necessary dependencies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i express mongoose body-parser cors dotenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will also need &lt;code&gt;nodemon&lt;/code&gt; and &lt;code&gt;concurrently&lt;/code&gt; for a better development experience. Nodemon reloads the server automatically whenever there is a change in any server file. Concurrently, enable us to run multiple node commands together.&lt;/p&gt;

&lt;p&gt;Install &lt;code&gt;nodemon&lt;/code&gt; and &lt;code&gt;concurrently&lt;/code&gt; as dev dependencies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --save-dev nodemon concurrently
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Update &lt;code&gt;scripts&lt;/code&gt; in &lt;code&gt;package.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
    "dev:server": "nodemon index.js --ignore ../client/",
    "dev:client": "npm run dev --prefix ../client/",
    "dev": "concurrently \"npm run dev:server\" \"npm run dev:client\""
  },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We need an entry point for our server now that we have finished installing our dependencies and configuring our &lt;code&gt;package.json&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;Create a new file called &lt;code&gt;index.js&lt;/code&gt; and add the following code to it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// index.js
import express from "express";

const app = express();
const PORT = 3000;

app.get("/", (req, res) =&amp;gt; {
  res.send("Hello World");
});

app.listen(PORT, () =&amp;gt; {
  console.log(`App is running on http://localhost:${PORT}`);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run &lt;code&gt;npm run dev:server&lt;/code&gt; in your &lt;code&gt;server&lt;/code&gt; folder to start your server, and visit &lt;code&gt;http://localhost:3000/&lt;/code&gt;, where you will see &lt;code&gt;Hello, World!&lt;/code&gt; displayed.&lt;/p&gt;

&lt;p&gt;Kudos! Your server is set.&lt;/p&gt;




&lt;h2&gt;
  
  
  Setup MongoDB database and connect the server using mongoose
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1.&lt;/strong&gt; Create an account or sign in to &lt;a href="https://www.mongodb.com/atlas/database"&gt;MongoDB Atlas&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2.&lt;/strong&gt; On the &lt;code&gt;Deploy your database&lt;/code&gt; page, select the &lt;code&gt;M0 free&lt;/code&gt; plan, allow other default settings, and click on the &lt;code&gt;Create&lt;/code&gt; button.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--J5ahtt6a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uilzin8mlt218be120wu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--J5ahtt6a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uilzin8mlt218be120wu.png" alt="Deploy your database page" width="800" height="760"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3.&lt;/strong&gt; Highlight the &lt;code&gt;Username and Password&lt;/code&gt; option if it is not already highlighted. Specify a username and password and click on &lt;code&gt;Create User&lt;/code&gt; button. &lt;em&gt;Keep your password safe; you will need it later.&lt;/em&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XBmuDgwa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6fves1os9627fq2g4nss.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XBmuDgwa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6fves1os9627fq2g4nss.png" alt="Username and password setup" width="800" height="503"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4.&lt;/strong&gt; Scroll down and highlight &lt;code&gt;My Local Environment&lt;/code&gt;. Input &lt;code&gt;0.0.0.0/0&lt;/code&gt; under IP address and click on the &lt;code&gt;Add Entry&lt;/code&gt; button. This will allow access to your Atlas cluster from anywhere. Click on &lt;code&gt;Finish and Close&lt;/code&gt; when you are done and go to overview.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hP1mivKN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e9njimp1w6g0fe77we7t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hP1mivKN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e9njimp1w6g0fe77we7t.png" alt="Allow access setting" width="800" height="503"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5.&lt;/strong&gt; Locate and click on the connect button under your cluster.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5AsDSLFA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qc1ycv38r24flagywykh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5AsDSLFA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qc1ycv38r24flagywykh.png" alt="Connect cluster" width="800" height="421"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6.&lt;/strong&gt; On the displayed menu, click on &lt;code&gt;Drivers&lt;/code&gt; under &lt;code&gt;Choose Your Application&lt;/code&gt;. Copy the Mongo URL, which starts with &lt;code&gt;mongodb+srv&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 7.&lt;/strong&gt; Go back to your application and create a &lt;code&gt;.env&lt;/code&gt; file in your &lt;code&gt;server&lt;/code&gt; folder and add &lt;code&gt;MONGO_URI&lt;/code&gt; and &lt;code&gt;PORT&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MONGO_URI='&amp;lt;mongdb_uri&amp;gt;'
PORT=3000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Ensure that you replace the password in your &lt;code&gt;mongdb_uri&lt;/code&gt; with the user password you generated.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Step 8.&lt;/strong&gt; Replace your &lt;code&gt;index.js&lt;/code&gt; code with the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// index.js
import express from "express";
import mongoose from "mongoose";
import cors from "cors";
import bodyParser from "body-parser";
import dotenv from "dotenv";

const app = express();
dotenv.config();

app.use(cors()); // to allow cross origin requests
app.use(bodyParser.json()); // to convert the request into JSON
app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/xwww-

// Connect to database
mongoose
  .connect(process.env.MONGO_URI, {
    useNewUrlParser: true,
    useUnifiedTopology: true,
  })
  .then(() =&amp;gt; console.log("MongoDB database Connected..."))
  .catch((err) =&amp;gt; console.log(err));

app.listen(process.env.PORT, () =&amp;gt;
  console.log(`App is running on http://localhost:${process.env.PORT}`)
);

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

&lt;/div&gt;



&lt;p&gt;Run &lt;code&gt;npm run dev:server&lt;/code&gt; to check if everything is working fine. &lt;code&gt;MongoDB database Connected...&lt;/code&gt; will be printed on your terminal if the server is properly connected to Mongo Atlas.&lt;/p&gt;




&lt;h2&gt;
  
  
  Create a basic schema with mongoose
&lt;/h2&gt;

&lt;p&gt;Create a &lt;code&gt;models&lt;/code&gt; folder inside your &lt;code&gt;server&lt;/code&gt; folder and create a &lt;code&gt;Todo.js&lt;/code&gt; file inside it. Add the following code to create a schema:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Schema, model } from "mongoose";

const TodoSchema = new Schema({
  title: {
    type: String,
    required: true,
  },
  description: {
    type: String,
    required: true,
  },
});

const Todo = model("todo", TodoSchema);

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

&lt;/div&gt;






&lt;h2&gt;
  
  
  Create API routes
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;TodoList.js&lt;/code&gt; inside &lt;code&gt;/routes/api&lt;/code&gt; folder in the &lt;code&gt;server&lt;/code&gt; folder. Use the following code to create CRUD API endpoints:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//TodoList.js
import { Router } from "express";
import Todo from "../../models/Todo.js";

const router = Router();

router
  .route("/")

// Get all todos in the database
  .get(async (_req, res) =&amp;gt; {
    try {
      const todoList = await Todo.find();
      if (!todoList) throw new Error("No Todo List found");
      res.status(200).json(todoList);
    } catch (error) {
      res.status(500).json({ message: error.message });
    }
  })

  //Post request creates a new todo in the database
  .post(async (req, res) =&amp;gt; {
    const newTodo = new Todo(req.body); // create a new instance of the Todo model
    try {
      const todo = await newTodo.save(); // Save created todo
      if (!todo) throw new Error("Something went wrong saving the Todo");
      res.status(200).json(todo);
    } catch (error) {
      res.status(500).json({ message: error.message });
    }
  });

router
  .route("/:id")

  // Update the todo with the given id
  .put(async (req, res) =&amp;gt; {
    const { id } = req.params;
    try {
      const updated = await Todo.findByIdAndUpdate(id, { ...req.body });
      if (!updated) throw Error("Something went wrong ");
      res.status(200).json(updated);
    } catch (error) {
      res.status(500).json({ message: error.message });
    }
  })

  // Delete the todo with the given id
  .delete(async (req, res) =&amp;gt; {
    const { id } = req.params;
    try {
      const removed = await Todo.findByIdAndDelete(id);
      if (!removed) throw Error("Something went wrong ");
      res.status(200).json(removed);
    } catch (error) {
      res.status(500).json({ message: error.message });
    }
  })

  // Get the todo with the given id
  .get(async (req, res) =&amp;gt; {
    const { id } = req.params;
    try {
      const todo = await Todo.findById(id);
      if (!todo) throw new Error("No Todo found");
      res.status(200).json(todo);
    } catch (error) {
      res.status(500).json({ message: error.message });
    }
  });

export default router;

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

&lt;/div&gt;



&lt;p&gt;Import the &lt;code&gt;TodoList.js&lt;/code&gt; file into the &lt;code&gt;index.js&lt;/code&gt; file and create an API route for it. Add the following code to &lt;code&gt;index.js&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// index.js

import TodoListRoutes from "./routes/api/TodoList.js";

---

// Create routes
app.use("/api/todoList", TodoListRoutes);

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

&lt;/div&gt;



&lt;p&gt;Use any preferred API testing tool, like Insomnia, to test your API. Ensure all requests (POST, GET, PUT, and DELETE) are working.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Summary&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Wow! You've made great strides. You have successfully created a Node.js/Express.js CRUD app with a Mongo Atlas connection. Take a break and return for Part 2, where we will set up our Vue3 client (frontend) to consume our API.&lt;/p&gt;

&lt;p&gt;Github Repository: &lt;a href="https://github.com/isonguyom/mevn-crud"&gt;https://github.com/isonguyom/mevn-crud&lt;/a&gt;&lt;br&gt;
Live Demo: &lt;a href="https://mevn-crud.onrender.com/"&gt;https://mevn-crud.onrender.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you have any questions or additions, please leave them in the comment section below.&lt;/p&gt;

</description>
      <category>mevn</category>
      <category>node</category>
      <category>mongodb</category>
      <category>express</category>
    </item>
  </channel>
</rss>
