<?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: Muchhal Sagar </title>
    <description>The latest articles on DEV Community by Muchhal Sagar  (@sagarmuchhal).</description>
    <link>https://dev.to/sagarmuchhal</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%2F2221398%2F5071431f-78d9-4497-96ac-a7a2466ff678.png</url>
      <title>DEV Community: Muchhal Sagar </title>
      <link>https://dev.to/sagarmuchhal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sagarmuchhal"/>
    <language>en</language>
    <item>
      <title>Mastering AWS Cloud with Free Tier: Unlocking the Power of Cloud Computing at No Cost</title>
      <dc:creator>Muchhal Sagar </dc:creator>
      <pubDate>Wed, 29 Jan 2025 17:16:17 +0000</pubDate>
      <link>https://dev.to/sagarmuchhal/mastering-aws-cloud-with-free-tier-unlocking-the-power-of-cloud-computing-at-no-cost-3imo</link>
      <guid>https://dev.to/sagarmuchhal/mastering-aws-cloud-with-free-tier-unlocking-the-power-of-cloud-computing-at-no-cost-3imo</guid>
      <description>&lt;p&gt;Amazon Web Services (AWS) is a comprehensive cloud computing platform that offers a broad set of services like computing power, storage, databases, machine learning, and more. Whether you're a developer, business, or aspiring cloud engineer, AWS provides an excellent way to dive into cloud computing without having to spend a dime, thanks to its Free Tier.&lt;/p&gt;

&lt;p&gt;In this blog, we'll explore how you can leverage AWS's Free Tier to gain hands-on experience with its cloud infrastructure. Whether you're building a prototype, testing ideas, or simply learning, the Free Tier is a valuable resource for all levels. Let's dive into some key AWS Free Tier services and how you can make the most out of them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is AWS Free Tier?&lt;/strong&gt;&lt;br&gt;
The AWS Free Tier is a program that allows users to use AWS services for free, up to certain limits, for 12 months from the account creation date. After the 12-month period, or if usage exceeds the free usage limits, the standard pay-as-you-go service charges apply. The Free Tier is designed to help new users and startups get started with AWS without incurring costs right away.&lt;/p&gt;

&lt;p&gt;There are three types of Free Tier offerings:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Always Free: Services that are available for free indefinitely, subject to usage limits.&lt;/li&gt;
&lt;li&gt;12-Month Free: Services that are free for 12 months after signing up.&lt;/li&gt;
&lt;li&gt;Trials: Services available for a limited time (usually 30 days) after activation.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Key AWS Free Tier Services to Explore&lt;/strong&gt;&lt;br&gt;
Let's take a look at some of the most popular AWS Free Tier services you can explore:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;1. Amazon EC2 (Elastic Compute Cloud)&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Free Tier Limit: 750 hours per month of a t2.micro or t3.micro instance for 12 months.&lt;/li&gt;
&lt;li&gt;What You Can Do: EC2 is AWS's virtual server offering. With 750 hours per month, you can run a Linux or Windows-based virtual machine for the entire month at no charge, perfect for hosting small web applications, testing, or learning server management.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;2. Amazon S3 (Simple Storage Service)&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Free Tier Limit: 5GB of Standard Storage, 20,000 GET requests, and 2,000 PUT requests.&lt;/li&gt;
&lt;li&gt;What You Can Do: S3 is a scalable object storage service. You can store files like images, videos, backups, and logs. You can also experiment with versioning, lifecycle policies, and data encryption without incurring costs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;3. Amazon RDS (Relational Database Service)&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Free Tier Limit: 750 hours per month of db.t2.micro instance for MySQL, PostgreSQL, MariaDB, Oracle, or SQL Server.&lt;/li&gt;
&lt;li&gt;What You Can Do: If you're building applications that require a relational database, RDS is a great option. With the Free Tier, you can run a database for testing or development purposes. You can even set up multi-AZ deployments to learn about high availability in databases.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;4. AWS Lambda&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Free Tier Limit: 1 million free requests and 400,000 GB-seconds of compute time per month.&lt;/li&gt;
&lt;li&gt;What You Can Do: Lambda lets you run code without provisioning or managing servers. You pay only for the compute time you use. Use it to experiment with serverless architectures, create event-driven applications, or set up cron jobs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;5. Amazon CloudFront&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Free Tier Limit: 50GB data transfer out and 2,000,000 HTTP/HTTPS requests per month.&lt;/li&gt;
&lt;li&gt;What You Can Do: CloudFront is AWS's Content Delivery Network (CDN). With the Free Tier, you can distribute content like images, videos, and web assets worldwide with low latency and high transfer speeds. It's perfect for testing how CDNs work and optimizing your website's performance.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;6. Amazon DynamoDB&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Free Tier Limit: 25GB of storage, up to 200 million requests per month, and 2.5 read and write capacity units.&lt;/li&gt;
&lt;li&gt;What You Can Do: DynamoDB is a fully managed NoSQL database service. You can build and scale applications without worrying about the underlying infrastructure. The Free Tier allows you to explore DynamoDB’s features, including automatic scaling and on-demand backups.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>nocost</category>
      <category>serverless</category>
    </item>
    <item>
      <title>Mastering Jest: A Guide to Efficient JavaScript Testing</title>
      <dc:creator>Muchhal Sagar </dc:creator>
      <pubDate>Mon, 16 Dec 2024 17:10:33 +0000</pubDate>
      <link>https://dev.to/sagarmuchhal/mastering-jest-a-guide-to-efficient-javascript-testing-pl2</link>
      <guid>https://dev.to/sagarmuchhal/mastering-jest-a-guide-to-efficient-javascript-testing-pl2</guid>
      <description>&lt;p&gt;Jest is a popular javascript testing framework (also known as jest is open sourch testing framework) designed to ensure correctness of any codebase. it allows you to write test with an approchable familiar and featured-rich API that gives you result quickly. jest is well-documented, reqiuires lottle configuration and can be extended to match your requirments.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Features of Jest:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;zero configuration:&lt;/strong&gt; jest work out of the box with minimal setup.&lt;br&gt;
&lt;strong&gt;Fast and effecient:&lt;/strong&gt; parralel test execution speeds up tetsing process.&lt;br&gt;
&lt;strong&gt;Snapshot testing:&lt;/strong&gt; compare and capture UI Snapshot.&lt;br&gt;
&lt;strong&gt;Built-in Mocks and spies:&lt;/strong&gt; Simplyfies mocking dependencies.&lt;br&gt;
&lt;strong&gt;Code Coverage:&lt;/strong&gt; generate detailed code reports.&lt;br&gt;
&lt;strong&gt;Extenshive community Supports:&lt;/strong&gt; a large ecosystem of plugins and tools.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installing Jest&lt;/strong&gt;&lt;br&gt;
you can install jest in your project using nom or yarn.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# using npm
npm install --save-dev jest

$ using yarn
yarn add -dev jest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For typescript Projects, also install the types:&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 @types/jest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Writing Your first Test&lt;/strong&gt;&lt;br&gt;
create a new file, sum.test.js, in your projrct&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// sum.js
function sum(a, b) {
  return a + b;
}
module.exports = sum;

// sum.test.js
const sum = require('./sum');

test('adds 1 + 2 to equal 3', () =&amp;gt; {
  expect(sum(1, 2)).toBe(3);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the test using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx jest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If everything is set up correctly, Jest will output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PASS  ./sum.test.js
  ✓ adds 1 + 2 to equal 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>jest</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>A Roadmap to Growth in the IT Industry</title>
      <dc:creator>Muchhal Sagar </dc:creator>
      <pubDate>Thu, 21 Nov 2024 02:26:55 +0000</pubDate>
      <link>https://dev.to/sagarmuchhal/a-roadmap-to-growth-in-the-it-industry-3bom</link>
      <guid>https://dev.to/sagarmuchhal/a-roadmap-to-growth-in-the-it-industry-3bom</guid>
      <description>&lt;p&gt;In today’s fast-paced digital era, the Information Technology (IT) field is brimming with opportunities. Whether you're a fresh graduate or a seasoned professional, growing in the IT industry requires continuous learning, strategic planning, and leveraging emerging technologies. In this blog, we’ll explore actionable steps, essential skills, and innovative strategies to thrive in this competitive yet rewarding field.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🌟 Introduction: Why Growth in IT is Essential&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The IT sector powers almost every industry today. From healthcare to entertainment, IT professionals are pivotal in shaping the future. But staying stagnant is not an option. With constant advancements like AI, blockchain, and cloud computing, adapting to change is key to sustaining and growing in the IT domain.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;📈 1. Understanding the IT Landscape&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before diving into growth strategies, it's crucial to understand the vast IT ecosystem.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Core Domains:&lt;/strong&gt; Software Development, Networking, Cybersecurity, Data Science, and AI.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Emerging Trends:&lt;/strong&gt; DevOps, Blockchain, Quantum Computing, and IoT.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Key Insight:&lt;/strong&gt; Identify your interests and align them with future trends.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;🧠 2. Continuous Learning: The Fuel for Growth&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The IT field evolves rapidly, making continuous learning non-negotiable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Steps to Stay Updated&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Enroll in Online Courses:&lt;/strong&gt; Platforms like Coursera, Udemy, and Pluralsight offer certifications in trending technologies.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Attend Webinars &amp;amp; Conferences:&lt;/strong&gt; Gain insights from industry leaders.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Follow Tech Blogs &amp;amp; Podcasts:&lt;/strong&gt; Stay updated with platforms like Medium, TechCrunch, and Smashing Magazine.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;⚙️ 3. Building a Diverse Skill Set&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To stand out, mix technical expertise with soft skills.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Technical Skills:&lt;/strong&gt; Programming (Python, JavaScript), Databases (SQL, MongoDB), and tools like Docker or Kubernetes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Soft Skills:&lt;/strong&gt; Communication, problem-solving, and adaptability.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;🌐 4. Networking and Building Connections&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Growth isn’t just about skills—it’s also about who you know.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Join Communities:&lt;/strong&gt; Engage on GitHub, Stack Overflow, and Reddit forums.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Leverage LinkedIn:&lt;/strong&gt; Showcase your work, connect with peers, and stay visible to recruiters.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Participate in Hackathons:&lt;/strong&gt; Showcase your skills while solving real-world problems.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;💼 5. Gaining Practical Experience&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Employers value hands-on experience over theoretical knowledge.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Internships:&lt;/strong&gt; Start with internships to build a portfolio.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Freelance Projects:&lt;/strong&gt; Explore platforms like Upwork and Fiverr to diversify your skill set.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Contribute to Open Source:&lt;/strong&gt; Collaborate on GitHub projects to gain real-world exposure.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;🎯 6. Mastering Personal Branding&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Your online presence can make or break your growth.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Build a Portfolio Website:&lt;/strong&gt; Showcase your projects and skills.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write Blogs:&lt;/strong&gt; Share knowledge on Medium or personal blogs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Be Active on GitHub:&lt;/strong&gt; Keep repositories updated with your work.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;🚀 7. Aim for Leadership Roles&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Technical expertise alone isn’t enough for long-term growth.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Upskill with Management Courses:&lt;/strong&gt; Learn project management tools like Jira and methodologies like Agile or Scrum.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mentorship:&lt;/strong&gt; Mentor juniors to enhance your leadership capabilities.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Growth in IT requires a blend of hard work, smart decisions, and continuous adaptation. Take small but consistent steps—learn, build, connect, and showcase. Remember, in the IT world, your learning curve determines your earning curve.&lt;/p&gt;

</description>
      <category>growth</category>
      <category>roadmap</category>
    </item>
    <item>
      <title>Securing Node.js Applications with Helmet</title>
      <dc:creator>Muchhal Sagar </dc:creator>
      <pubDate>Tue, 12 Nov 2024 17:18:45 +0000</pubDate>
      <link>https://dev.to/sagarmuchhal/securing-nodejs-applications-with-helmet-3m85</link>
      <guid>https://dev.to/sagarmuchhal/securing-nodejs-applications-with-helmet-3m85</guid>
      <description>&lt;p&gt;As the web grows more complex, securing your applications from vulnerabilities becomes increasingly important. One of the simplest and most effective ways to enhance security in your Node.js applications is by using Helmet.&lt;/p&gt;

&lt;p&gt;In this blog post, we will walk you through how to integrate Helmet into your Node.js application to secure HTTP headers, ensuring your app is protected from some common web security issues.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Helmet?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Helmet is a collection of middleware functions for Node.js that helps secure your app by setting various HTTP headers. These headers can prevent a range of attacks, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cross-Site Scripting (XSS)&lt;/li&gt;
&lt;li&gt;Clickjacking&lt;/li&gt;
&lt;li&gt;HTTP Response Splitting&lt;/li&gt;
&lt;li&gt;MIME Type Sniffing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Helmet doesn't protect against all vulnerabilities but helps reduce the attack surface by improving the security of HTTP responses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting Up Your Project&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Initialize the Project&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Start by creating a new directory and initializing your Node.js project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir helmet-node-app
cd helmet-node-app
npm init -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Install Dependencies&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now, install express for the web framework and helmet for security. Additionally, install TypeScript, ts-node, and the necessary type definitions for TypeScript:&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 express helmet
npm install --save-dev typescript ts-node @types/express @types/node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Create the Application&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create the &lt;code&gt;src&lt;/code&gt; folder and a file &lt;code&gt;src/index.ts&lt;/code&gt;. Add the following code to set up a simple Express server with Helmet to secure HTTP headers:&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, { Request, Response } from 'express';
import helmet from 'helmet';

const app = express();

// Use Helmet to secure HTTP headers
app.use(helmet());

app.get('/', (req: Request, res: Response) =&amp;gt; {
    res.send('Hello, secure world!');
});

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4: Configure TypeScript&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create a &lt;code&gt;tsconfig.json&lt;/code&gt; file for TypeScript settings:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "compilerOptions": {
    "target": "ES6",
    "module": "CommonJS",
    "outDir": "./dist",
    "esModuleInterop": true
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules"]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 6: Run the Application&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With everything set up, run the application using the following command:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Your app should now be running at &lt;a href="http://localhost:3000" rel="noopener noreferrer"&gt;http://localhost:3000&lt;/a&gt;, displaying:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello, secure world!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means your Node.js app is up and running with enhanced security provided by Helmet.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GitHub Repository&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can find the complete source code for this project on GitHub:&lt;br&gt;
&lt;a href="https://github.com/muchhalsagar/helmet-node-app/" rel="noopener noreferrer"&gt;Helmet-Node-App&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to use Cookie Consent in a React App with react-cookie-consent</title>
      <dc:creator>Muchhal Sagar </dc:creator>
      <pubDate>Tue, 29 Oct 2024 17:00:29 +0000</pubDate>
      <link>https://dev.to/sagarmuchhal/how-to-use-cookie-consent-in-a-react-app-with-react-cookie-consent-3j8n</link>
      <guid>https://dev.to/sagarmuchhal/how-to-use-cookie-consent-in-a-react-app-with-react-cookie-consent-3j8n</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
Privacy and data protection are essential considerations for modern websites, so adding a cookie consent banner to your React app ensures compliance with data privacy regulations, like GDPR. In this tutorial, we’ll use the &lt;code&gt;react-cookie-consent&lt;/code&gt; library to easily add a cookie consent banner to our application and customize it to give users control over cookie preferences.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Set Up Your React Project&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you haven’t set up a React project yet, create one with the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app cookie-consent-demo
cd cookie-consent-demo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Install react-cookie-consent&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;react-cookie-consent&lt;/code&gt; library simplifies adding a cookie consent banner to your app. Install it using npm or yarn:&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 react-cookie-consent
# or
yarn add react-cookie-consent
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Basic Implementation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once you have the library installed, go to your main app file (usually &lt;code&gt;App.js&lt;/code&gt; or &lt;code&gt;App.tsx&lt;/code&gt;) and add the cookie consent component. Here’s a basic setup:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from "react";
import CookieConsent from "react-cookie-consent";

function App() {
  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;h1&amp;gt;Welcome to My Website&amp;lt;/h1&amp;gt;
      {/* Basic Cookie Consent */}
      &amp;lt;CookieConsent
        location="bottom"
        buttonText="I understand"
        cookieName="myWebsiteCookieConsent"
        style={{ background: "#2B373B" }}
        buttonStyle={{ color: "#4e503b", fontSize: "13px" }}
        expires={150}
      &amp;gt;
        This website uses cookies to enhance your browsing experience.{" "}
        &amp;lt;a href="/privacy-policy" style={{ color: "#f5e042" }}&amp;gt;
          Learn more
        &amp;lt;/a&amp;gt;
      &amp;lt;/CookieConsent&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4: Customizing the Consent Banner&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To make the consent banner more engaging or add options like "Accept All" and "Decline," you can extend the component.&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;CookieConsent
  location="bottom"
  enableDeclineButton
  declineButtonText="Decline"
  buttonText="Accept All"
  cookieName="myWebsiteCookieConsent"
  style={{ background: "#000" }}
  buttonStyle={{ color: "#fff", fontSize: "14px" }}
  declineButtonStyle={{
    color: "#fff",
    background: "#c0392b",
    fontSize: "14px",
  }}
  expires={365}
  onAccept={() =&amp;gt; {
    console.log("Cookies accepted");
  }}
  onDecline={() =&amp;gt; {
    console.log("Cookies declined");
  }}
&amp;gt;
  We use cookies to improve user experience. By clicking "Accept All," you consent to the use of cookies.
&amp;lt;/CookieConsent&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Adding a cookie consent banner is crucial for user privacy and regulatory compliance, and &lt;code&gt;react-cookie-consent&lt;/code&gt; makes it easy to implement. You can further customize the banner to align with your website's design and messaging and respond to user choices for enhanced control over cookie-based features.&lt;/p&gt;

</description>
      <category>cookie</category>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Step-by-Step Guide to Deploying Node.js on AWS Free Tier</title>
      <dc:creator>Muchhal Sagar </dc:creator>
      <pubDate>Thu, 17 Oct 2024 16:53:09 +0000</pubDate>
      <link>https://dev.to/sagarmuchhal/step-by-step-guide-to-deploying-nodejs-on-aws-free-tier-4icj</link>
      <guid>https://dev.to/sagarmuchhal/step-by-step-guide-to-deploying-nodejs-on-aws-free-tier-4icj</guid>
      <description>&lt;p&gt;Deploying a Node.js application on AWS can be an economical choice, especially when utilizing the Free Tier. This guide will help you set up your application on an EC2 instance without incurring costs, using PM2 for process management.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A completed Node.js application&lt;/li&gt;
&lt;li&gt;An AWS account (ensure you're eligible for the Free Tier)&lt;/li&gt;
&lt;li&gt;Basic knowledge of Git, Node.js, and AWS services&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Set Up Your AWS Environment&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Create an EC2 Instance:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to the &lt;a href="https://aws.amazon.com/console/" rel="noopener noreferrer"&gt;AWS Management Console&lt;/a&gt; and navigate to the EC2 service.&lt;/li&gt;
&lt;li&gt;Click on "Launch Instance."&lt;/li&gt;
&lt;li&gt;Choose an Amazon Machine Image (AMI): Select "Amazon Linux 2 AMI (HVM), SSD Volume Type" for a lightweight option that works well with the Free Tier.&lt;/li&gt;
&lt;li&gt;Select Instance Type: Choose t2.micro, which is eligible for the Free Tier.&lt;/li&gt;
&lt;li&gt;Configure Instance Details: You can leave the defaults or modify as needed.&lt;/li&gt;
&lt;li&gt;Add Storage: The default 8 GB should suffice for small applications.&lt;/li&gt;
&lt;li&gt;Configure Security Group and Add rules to allow HTTP (port 80) and SSH (port 22) traffic.&lt;/li&gt;
&lt;li&gt;Launch the instance and download the key pair (PEM file) for SSH access.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Connect to Your EC2 Instance&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. SSH into Your Instance:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open your terminal or command prompt and connect to your instance:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh -i "your-key-pair.pem" ec2-user@your-instance-public-dns
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Update Package Manager:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Once connected, update the package manager:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo yum update -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Install Node.js and Git&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Install Node.js and npm:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install Node.js and npm from the NodeSource repository:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -
sudo yum install -y nodejs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Install Git:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install Git:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo yum install git -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4: Deploy Your Node.js Application&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Clone Your Repository:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Navigate to your desired directory and clone your Node.js application:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone your-repo-url.git
cd your-repo-directory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Install Dependencies:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inside your project directory, install the necessary packages:
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Set Environment Variables (if needed):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a &lt;code&gt;.env&lt;/code&gt; file in your project root to store environment variables:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo "YOUR_ENV_VARIABLE=value" &amp;gt;&amp;gt; .env
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Start Your Application Using PM2:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install PM2 globally:
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Start your application:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pm2 start app.js --name your-app-name

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;To ensure PM2 restarts your app on server reboot, run:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pm2 startup
pm2 save
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 5: Access Your Application&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open a web browser and navigate to your EC2 instance's public DNS or IP address to see your application live.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 6: Monitor and Maintain Your Application&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Logging: PM2 provides built-in logging. You can view logs using:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pm2 logs your-app-name

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Performance Monitoring: Use AWS CloudWatch to monitor your instance's health and performance metrics.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aws</category>
      <category>node</category>
      <category>ec2</category>
      <category>devops</category>
    </item>
    <item>
      <title>Step-by-Step Guide to Deploying Node.js on AWS Free Tier</title>
      <dc:creator>Muchhal Sagar </dc:creator>
      <pubDate>Thu, 17 Oct 2024 16:53:09 +0000</pubDate>
      <link>https://dev.to/sagarmuchhal/step-by-step-guide-to-deploying-nodejs-on-aws-free-tier-2cko</link>
      <guid>https://dev.to/sagarmuchhal/step-by-step-guide-to-deploying-nodejs-on-aws-free-tier-2cko</guid>
      <description>&lt;p&gt;Deploying a Node.js application on AWS can be an economical choice, especially when utilizing the Free Tier. This guide will help you set up your application on an EC2 instance without incurring costs, using PM2 for process management.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A completed Node.js application&lt;/li&gt;
&lt;li&gt;An AWS account (ensure you're eligible for the Free Tier)&lt;/li&gt;
&lt;li&gt;Basic knowledge of Git, Node.js, and AWS services&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Set Up Your AWS Environment&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Create an EC2 Instance:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to the &lt;a href="https://aws.amazon.com/console/" rel="noopener noreferrer"&gt;AWS Management Console&lt;/a&gt; and navigate to the EC2 service.&lt;/li&gt;
&lt;li&gt;Click on "Launch Instance."&lt;/li&gt;
&lt;li&gt;Choose an Amazon Machine Image (AMI): Select "Amazon Linux 2 AMI (HVM), SSD Volume Type" for a lightweight option that works well with the Free Tier.&lt;/li&gt;
&lt;li&gt;Select Instance Type: Choose t2.micro, which is eligible for the Free Tier.&lt;/li&gt;
&lt;li&gt;Configure Instance Details: You can leave the defaults or modify as needed.&lt;/li&gt;
&lt;li&gt;Add Storage: The default 8 GB should suffice for small applications.&lt;/li&gt;
&lt;li&gt;Configure Security Group and Add rules to allow HTTP (port 80) and SSH (port 22) traffic.&lt;/li&gt;
&lt;li&gt;Launch the instance and download the key pair (PEM file) for SSH access.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Connect to Your EC2 Instance&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. SSH into Your Instance:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open your terminal or command prompt and connect to your instance:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh -i "your-key-pair.pem" ec2-user@your-instance-public-dns
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Update Package Manager:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Once connected, update the package manager:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo yum update -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Install Node.js and Git&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Install Node.js and npm:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install Node.js and npm from the NodeSource repository:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -
sudo yum install -y nodejs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Install Git:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install Git:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo yum install git -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4: Deploy Your Node.js Application&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Clone Your Repository:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Navigate to your desired directory and clone your Node.js application:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone your-repo-url.git
cd your-repo-directory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Install Dependencies:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inside your project directory, install the necessary packages:
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Set Environment Variables (if needed):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a &lt;code&gt;.env&lt;/code&gt; file in your project root to store environment variables:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo "YOUR_ENV_VARIABLE=value" &amp;gt;&amp;gt; .env
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Start Your Application Using PM2:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install PM2 globally:
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Start your application:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pm2 start app.js --name your-app-name

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;To ensure PM2 restarts your app on server reboot, run:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pm2 startup
pm2 save
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 5: Access Your Application&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open a web browser and navigate to your EC2 instance's public DNS or IP address to see your application live.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 6: Monitor and Maintain Your Application&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Logging: PM2 provides built-in logging. You can view logs using:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pm2 logs your-app-name

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Performance Monitoring: Use AWS CloudWatch to monitor your instance's health and performance metrics.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aws</category>
      <category>node</category>
      <category>ec2</category>
      <category>devops</category>
    </item>
    <item>
      <title>Getting Started with Docker and Node.js</title>
      <dc:creator>Muchhal Sagar </dc:creator>
      <pubDate>Wed, 16 Oct 2024 17:40:18 +0000</pubDate>
      <link>https://dev.to/sagarmuchhal/getting-started-with-docker-and-nodejs-5ef1</link>
      <guid>https://dev.to/sagarmuchhal/getting-started-with-docker-and-nodejs-5ef1</guid>
      <description>&lt;p&gt;Docker simplifies application deployment by packaging code and its dependencies into containers. In this blog, we’ll walk through the steps to containerize a simple Node.js application using Docker.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Create a Simple Node.js Application&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Set Up the Project Directory&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create a new directory for your Node.js app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir my-node-app
cd my-node-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Initialize a Node.js Application&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Run the following command to create a package.json file:&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;&lt;strong&gt;3. Install Express&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Install Express to create a simple web server:&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 express
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Create an app.js File&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create a file named app.js 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;const express = require('express');
const app = express();
const PORT = process.env.PORT || 3000;

app.get('/', (req, res) =&amp;gt; {
    res.send('Hello, Docker!');
});

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

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;Step 2: Create a Dockerfile&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Create a Dockerfile&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the project directory, create a file named Dockerfile (no extension) and add the following content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Use the official Node.js image as a base
FROM node:14

# Set the working directory
WORKDIR /usr/src/app

# Copy package.json and package-lock.json
COPY package*.json ./

# Install dependencies
RUN npm install

# Copy the rest of the application code
COPY . .

# Expose the application port
EXPOSE 3000

# Command to run the application
CMD ["node", "app.js"]

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

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;Step 3: Build the Docker Image&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Run the following command in the terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker build -t my-node-app .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;Step 4: Run the Docker Container&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After building the image, run the container:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -p 3000:3000 my-node-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, you can access your Node.js application at &lt;a href="http://localhost:3000" rel="noopener noreferrer"&gt;http://localhost:3000&lt;/a&gt;.&lt;/p&gt;

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