<?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: Arowolo Ebine</title>
    <description>The latest articles on DEV Community by Arowolo Ebine (@arosebine).</description>
    <link>https://dev.to/arosebine</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%2F888106%2Fe15d58e2-b30c-4249-a948-3816e45a1659.JPG</url>
      <title>DEV Community: Arowolo Ebine</title>
      <link>https://dev.to/arosebine</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/arosebine"/>
    <language>en</language>
    <item>
      <title>Securing Node.js in Production: Expert Practices for Every Developer</title>
      <dc:creator>Arowolo Ebine</dc:creator>
      <pubDate>Thu, 21 Mar 2024 07:48:19 +0000</pubDate>
      <link>https://dev.to/arosebine/securing-nodejs-in-production-expert-practices-for-every-developer-3amb</link>
      <guid>https://dev.to/arosebine/securing-nodejs-in-production-expert-practices-for-every-developer-3amb</guid>
      <description>&lt;p&gt;As web development keeps evolving, ensuring the security of your Node.js application becomes critical. This detailed guide steps beyond elementary suggestions, offering a closer look at advanced security techniques for Node.js setups.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Operating Without Root Privileges: A Must-Do
Running Node.js or any web server as a root user poses a significant security risk. A single exploit could grant attackers complete control over the server. Instead, configure your environment to run with minimal privileges.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Implementation Insight:&lt;/p&gt;

&lt;p&gt;Creating a dedicated user for your Node.js application restricts potential damage in the event of a compromise.&lt;/p&gt;

&lt;h1&gt;
  
  
  Creating a non-root user for Node.js service
&lt;/h1&gt;

&lt;p&gt;adduser --disabled-login nodejsUser&lt;br&gt;
Switch to this user before starting your application to ensure it runs with limited permissions.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Keeping NPM Libraries Up-to-Date: The First Line of Defense
Dependencies in the Node.js ecosystem can be a double-edged sword. While they significantly accelerate development, they can also introduce vulnerabilities.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Implementation Insight:&lt;/p&gt;

&lt;p&gt;Use npm audit for a quick vulnerability scan and fix issues automatically with npm audit fix. Integrate Snyk for continuous monitoring and protection.&lt;/p&gt;

&lt;h1&gt;
  
  
  Updating packages and fixing vulnerabilities
&lt;/h1&gt;

&lt;p&gt;npm update &amp;amp;&amp;amp; npm audit fix&lt;br&gt;
Snyk Integration:&lt;/p&gt;

&lt;p&gt;Snyk offers a proactive approach to dependency security, scanning for vulnerabilities and providing fixes or workarounds.&lt;/p&gt;

&lt;h1&gt;
  
  
  Installing Snyk CLI and scanning your project
&lt;/h1&gt;

&lt;p&gt;npm install -g snyk&lt;br&gt;
snyk auth&lt;br&gt;
snyk test&lt;br&gt;
Automate this process in your CI/CD pipeline to ensure continuous security.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Customizing Cookie Names: Obscuring Tech Stack Details
Default cookie names can inadvertently disclose your application’s underlying technologies, making it easier for attackers to tailor their exploits.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Implementation Insight:&lt;/p&gt;

&lt;p&gt;Change default session cookie names to something unique and unrelated to the technology or framework used.&lt;/p&gt;

&lt;p&gt;const express = require('express');&lt;br&gt;
const session = require('express-session')&lt;br&gt;
app.use(session({&lt;br&gt;
  // set a custom name for the session cookie&lt;br&gt;
  name: 'siteSessionId',&lt;br&gt;
  // a secure secret key for session encryption&lt;br&gt;
  secret: 'complex_secret_key',&lt;br&gt;
  // Additional session configurations...&lt;br&gt;
}));&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Implementing Secure HTTP Headers with Helmet: Bolstering Defense
Secure HTTP headers are crucial for protecting your app from various types of attacks like XSS, clickjacking, and other cross-site injections.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Implementation Insight:&lt;/p&gt;

&lt;p&gt;Helmet.js is a middleware that sets secure HTTP headers out of the box. Customize it to suit your application’s needs.&lt;/p&gt;

&lt;p&gt;The helmet() middleware automatically removes unsafe headers and adds new ones, including X-XSS-Protection, X-Content-Type-Options, Strict-Transport-Security, and X-Frame-Options. These enforce best practices and help protect your application from common attacks.&lt;/p&gt;

&lt;p&gt;const helmet = require('helmet');&lt;/p&gt;

&lt;p&gt;app.use(helmet({&lt;br&gt;
  // Custom helmet configuration here&lt;br&gt;
}));&lt;br&gt;
Regularly review your headers’ security using tools like the Mozilla Observatory.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Rate Limiting: Preventing Abuse
Rate limiting is essential for protecting your application against brute-force attacks and DDoS by limiting the number of requests a user can make in a given timeframe.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Implementation Insight:&lt;/p&gt;

&lt;p&gt;Utilize libraries like express-rate-limit for easy rate-limiting setup.&lt;/p&gt;

&lt;p&gt;const rateLimit = require('express-rate-limit');&lt;/p&gt;

&lt;p&gt;const limiter = rateLimit({&lt;br&gt;
  windowMs: 15 * 60 * 1000, // 15 minutes&lt;br&gt;
  max: 100, // Limit each IP to 100 requests per windowMs&lt;br&gt;
});&lt;/p&gt;

&lt;p&gt;app.use(limiter);&lt;br&gt;
Configure thresholds based on normal user behavior and adjust as necessary.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Enforcing Strong Authentication Policies: Beyond Passwords
Authentication mechanisms are often targeted by attackers. Implementing robust authentication methods is critical for securing user accounts.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Implementation Insight:&lt;/p&gt;

&lt;p&gt;Implement bcrypt for secure password hashing.&lt;br&gt;
Enforce password complexity requirements.&lt;br&gt;
Utilize multi-factor authentication (MFA) to add another layer of security.&lt;br&gt;
const bcrypt = require('bcrypt');&lt;br&gt;
const saltRounds = 10;&lt;/p&gt;

&lt;p&gt;// Hashing a password&lt;br&gt;
bcrypt.hash('userPassword', saltRounds, function(err, hash) {&lt;br&gt;
  // Store hash in your password database.&lt;br&gt;
});&lt;br&gt;
Educate users on the importance of strong passwords and provide support for MFA.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Minimizing Error Details: Avoiding Information Leakage
Verbose error messages can provide attackers with insights into your application’s architecture, facilitating targeted attacks.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Implementation Insight:&lt;/p&gt;

&lt;p&gt;Ensure that production environments do not expose stack traces or detailed error messages to users.&lt;/p&gt;

&lt;p&gt;app.use((err, req, res, next) =&amp;gt; {&lt;br&gt;
  res.status(500).json({ error: "Internal Server Error" });&lt;br&gt;
});&lt;br&gt;
Log detailed errors server-side for debugging, keeping user-facing messages generic.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Vigilant Monitoring: Keeping an Eye on Your Application
Monitoring is crucial for detecting and responding to security incidents in real time.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Implementation Insight:&lt;/p&gt;

&lt;p&gt;Integrate Application Performance Monitoring (APM) tools to track application behavior and identify anomalies indicative of security breaches.&lt;/p&gt;

&lt;p&gt;const apmTool = require('apm-tool-of-choice');&lt;/p&gt;

&lt;p&gt;apmTool.start({&lt;br&gt;
  // Configuration options&lt;br&gt;
});&lt;br&gt;
Choose a tool that suits your stack and provides comprehensive insights into both performance and security aspects.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Embracing HTTPS-Only Policy: Encrypting Data in Transit
HTTPS ensures that data between your server and the user is encrypted, protecting it from eavesdropping and man-in-the-middle attacks.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Implementation Insight:&lt;/p&gt;

&lt;p&gt;Redirect all HTTP traffic to HTTPS and ensure that cookies are set with the Secure attribute.&lt;/p&gt;

&lt;p&gt;app.use((req, res, next) =&amp;gt; {&lt;br&gt;
  if (!req.secure) {&lt;br&gt;
    return res.redirect(&lt;code&gt;https://${req.headers.host}${req.url}&lt;/code&gt;);&lt;br&gt;
  }&lt;br&gt;
  next();&lt;br&gt;
});&lt;br&gt;
Use tools like Let’s Encrypt to obtain free SSL/TLS certificates.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Validating User Input: Shielding Against Injection
Validating and sanitizing user input is fundamental to preventing injection attacks, such as SQL injection, XSS, and more.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Implementation Insight:&lt;/p&gt;

&lt;p&gt;Employ libraries express-validator to define validation rules for user inputs.&lt;/p&gt;

&lt;p&gt;const { body, validationResult } = require('express-validator');&lt;/p&gt;

&lt;p&gt;app.post('/register', [&lt;br&gt;
  body('email').isEmail(),&lt;br&gt;
  body('password').isLength({ min: 5 })&lt;br&gt;
], (req, res) =&amp;gt; {&lt;br&gt;
  const errors = validationResult(req);&lt;br&gt;
  if (!errors.isEmpty()) {&lt;br&gt;
    return res.status(400).json({ errors: errors.array() });&lt;br&gt;
  }&lt;/p&gt;

&lt;p&gt;// Proceed with registration logic&lt;br&gt;
});&lt;br&gt;
Define strict validation rules based on the expected format of the data.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Leveraging Security Linters
Use tools to automatically spot potential security risks in your code.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Short Implementation Guide:&lt;/p&gt;

&lt;p&gt;Choose a Linter: ESLint, combined with the eslint-plugin-security, offers a focused approach to identifying security risks in Node.js code.&lt;br&gt;
Setup: Install ESLint and the security plugin.&lt;br&gt;
Configure ESLint: Modify your .eslintrc to use the security plugin.&lt;br&gt;
Scan Your Code: Execute ESLint to uncover and address security concerns.&lt;br&gt;
Integrate with Development Workflow: Embed linting into your regular development practices to catch and rectify issues promptly.&lt;br&gt;
npm install eslint eslint-plugin-security --save-dev&lt;br&gt;
{&lt;br&gt;
  "extends": ["eslint:recommended", "plugin:security/recommended"],&lt;br&gt;
  "plugins": ["security"]&lt;br&gt;
}&lt;br&gt;
npx eslint .&lt;br&gt;
By integrating security linters into your workflow, following user input validation, you create an additional layer of defense, ensuring your code is not only safe from common injection attacks but also from other potential vulnerabilities identified through static code analysis.&lt;/p&gt;

&lt;p&gt;Conclusion&lt;br&gt;
Securing a Node.js application is an ongoing process that involves multiple layers of defense. By implementing the practices outlined in this guide, you can significantly enhance the security posture of your Node.js applications. Stay informed about the latest security threats and continuously update your security practices to protect against evolving risks.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to Implement a CI/CD pipeline with GitHub Actions in four simple steps In Your Repo.</title>
      <dc:creator>Arowolo Ebine</dc:creator>
      <pubDate>Tue, 27 Feb 2024 12:46:04 +0000</pubDate>
      <link>https://dev.to/arosebine/how-to-implement-a-cicd-pipeline-with-github-actions-in-four-simple-steps-39fe</link>
      <guid>https://dev.to/arosebine/how-to-implement-a-cicd-pipeline-with-github-actions-in-four-simple-steps-39fe</guid>
      <description>&lt;p&gt;How to Implement a CI/CD pipeline with GitHub Actions in your repository.&lt;/p&gt;

&lt;p&gt;Continuous Integration / Continuous Delivery (CI/CD) has long been—and continues to be—the domain of DevOps experts. But with the introduction of native CI/CD to GitHub in 2019 via GitHub Actions, it’s easier than ever to bring CI/CD directly into your workflow right from your repository.&lt;/p&gt;

&lt;p&gt;If you’re using Git, GitHub, and GitHub Actions to build a CI/CD pipeline, you should have confidence in your code.&lt;/p&gt;

&lt;p&gt;I’m going to walk you through exactly how to build your own CI/CD pipeline, right from your repository on GitHub.&lt;/p&gt;

&lt;p&gt;A CI pipeline runs when code changes and should make sure all of your changes work with the rest of the code when it’s integrated. It should also compile your code, run tests, and check that it’s functional. A CD pipeline goes one step further and deploys the built code into production.&lt;/p&gt;

&lt;p&gt;There are plenty of guided options with pre-built CI workflows you can leverage, per your technology requirements. But you can also build your own CI workflow from scratch if you want to.&lt;/p&gt;

&lt;p&gt;To begin building your CI/CD pipeline, open the GitHub Actions tab in your repository’s top navigation bar. You should see a list of CI/CD and workflow automation templates that match the technology of your project.&lt;/p&gt;

&lt;p&gt;For your project, you'll leverage a few different CI/CD workflows to test, build, stage, and deploy your code. These include:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;A development workflow:&lt;/strong&gt; This workflow runs through a few different jobs whenever a pull request is opened, edited, synchronized, or reopened. These jobs include setting up Node, installing npm packages and dependencies, running npm test, and cycling through a number of lint jobs too&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;** A CodeQL Analysis workflow:** This workflow runs a series of CodeQL security tests on our code after we merge it to the main branch to ensure there are no known vulnerabilities. This involves YAML.file. It’s super simple, but effective and something I’d highly recommend.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;A deployment workflow:&lt;/strong&gt; This workflow deploys any UI component changes to our production website.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;A release and build workflow:&lt;/strong&gt; This workflow runs tests and enforces lint after releasing code changes to Docker and building the application. It also deploys the final code to our production environment, cuts a release using a similar structure to the automated release notes, bundles the site into a container and publishes to ghcr. From there, it bumps the version number and tag in the repository.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Building a Secure REST API in Node.js: Best Practices for Web Developers</title>
      <dc:creator>Arowolo Ebine</dc:creator>
      <pubDate>Tue, 27 Feb 2024 11:58:16 +0000</pubDate>
      <link>https://dev.to/arosebine/building-a-secure-rest-api-in-nodejs-best-practices-for-web-developers-5bj2</link>
      <guid>https://dev.to/arosebine/building-a-secure-rest-api-in-nodejs-best-practices-for-web-developers-5bj2</guid>
      <description>&lt;p&gt;What is a REST API?&lt;br&gt;
Before we dive into the nitty-gritty of securing a REST API in Node.js, let’s start by understanding what a REST API is. REST, or Representational State Transfer, is an architectural style for designing networked applications. A REST API is a set of rules and conventions used for building and interacting with web services. It operates based on principles such as statelessness, client-server communication, and the use of uniform resource identifiers (URIs).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Securing Your REST API in Node.js&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
Step 1: Setting Up Your Development Environment&lt;br&gt;
Before we begin, ensure you have Node.js and npm (Node Package Manager) installed on your system. You can download them from the official Node.js website. Additionally, consider using a version control system like Git to track your code changes.&lt;/p&gt;

&lt;p&gt;Step 2: &lt;strong&gt;Installing Necessary Packages&lt;/strong&gt;&lt;br&gt;
To create a secure REST API in Node.js, you will need various packages. Let’s start by installing them using npm:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm init -y&lt;/code&gt;&lt;br&gt;
npm install express mongoose body-parser cors helmet jsonwebtoken&lt;br&gt;
Here’s a brief overview of the packages:&lt;/p&gt;

&lt;p&gt;express: A web framework for creating RESTful APIs.&lt;/p&gt;

&lt;p&gt;mongoose: An Object Data Modeling (ODM) library for MongoDB.&lt;/p&gt;

&lt;p&gt;body-parser: Middleware for parsing request bodies.&lt;/p&gt;

&lt;p&gt;cors: Middleware for enabling Cross-Origin Resource Sharing.&lt;/p&gt;

&lt;p&gt;helmet: Middleware for adding security headers.&lt;/p&gt;

&lt;p&gt;jsonwebtoken: A package for working with JSON Web Tokens (JWT) to implement authentication.&lt;/p&gt;

&lt;p&gt;Step 3:** Building the Express Application**&lt;br&gt;
Create a new file called app.js and set up your Express application:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;const express = require('express');&lt;br&gt;
const mongoose = require('mongoose');&lt;br&gt;
const bodyParser = require('body-parser');&lt;br&gt;
const cors = require('cors');&lt;br&gt;
const helmet = require('helmet');&lt;br&gt;
const app = express();&lt;br&gt;
const port = process.env.PORT || 3000;&lt;br&gt;
// Connect to your MongoDB database (replace with your database URL)&lt;br&gt;
mongoose.connect('mongodb://localhost/secure-rest-api', { useNewUrlParser: true, useUnifiedTopology: true });&lt;br&gt;
app.use(bodyParser.json());&lt;br&gt;
app.use(cors());&lt;br&gt;
app.use(helmet());&lt;br&gt;
app.listen(port, () =&amp;gt; {&lt;br&gt;
  console.log(&lt;/code&gt;Server is running on port ${port}`);&lt;br&gt;
});&lt;br&gt;
Defining Your REST API Routes&lt;br&gt;
In the development of a secure REST API, defining routes is a fundamental step. Create a directory called routes and include route files for different aspects of your API. For example, let's start with a userRoutes.js file:&lt;/p&gt;

&lt;p&gt;const express = require('express');&lt;br&gt;
const router = express.Router();&lt;br&gt;
// Define your user-related routes here&lt;br&gt;
module.exports = router;&lt;br&gt;
To use these route files in your main app.js, require and use them as follows:&lt;/p&gt;

&lt;p&gt;const userRoutes = require('./routes/userRoutes');&lt;br&gt;
app.use('/users', userRoutes);&lt;br&gt;
Implementing Authentication with JSON Web Tokens (JWT)&lt;br&gt;
Securing your REST API involves authenticating users. We’ll use JSON Web Tokens (JWT) to achieve this. Below is a simplified example of how to create and verify JWTs:&lt;br&gt;
`&lt;br&gt;
Create a file called auth.js:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;const jwt = require('jsonwebtoken');&lt;br&gt;
const generateToken = (user) =&amp;gt; {&lt;br&gt;
  const secret = 'your-secret-key';&lt;br&gt;
  return jwt.sign({ userId: user._id }, secret, { expiresIn: '1h' });&lt;br&gt;
};&lt;br&gt;
const verifyToken = (token) =&amp;gt; {&lt;br&gt;
  const secret = 'your-secret-key';&lt;br&gt;
  return jwt.verify(token, secret);&lt;br&gt;
};&lt;br&gt;
module.exports = { generateToken, verifyToken };&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
&lt;strong&gt;Protecting Your Routes&lt;/strong&gt;&lt;br&gt;
Protecting routes ensures that only authorized users can access specific endpoints. To do this, create a middleware for route protection. Here’s an example of protecting a route:&lt;/p&gt;

&lt;p&gt;Create a file called authMiddleware.js:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;const { verifyToken } = require('../auth');&lt;br&gt;
const requireAuth = (req, res, next) =&amp;gt; {&lt;br&gt;
  const token = req.headers.authorization;&lt;br&gt;
  if (token) {&lt;br&gt;
    try {&lt;br&gt;
      const user = verifyToken(token);&lt;br&gt;
      req.user = user;&lt;br&gt;
      next();&lt;br&gt;
    } catch (error) {&lt;br&gt;
      res.status(401).json({ error: 'Invalid token' });&lt;br&gt;
    }&lt;br&gt;
  } else {&lt;br&gt;
    res.status(401).json({ error: 'Token not provided' });&lt;br&gt;
  }&lt;br&gt;
};&lt;br&gt;
module.exports = { requireAuth };&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
Apply this middleware to your protected routes, as shown below:&lt;/p&gt;

&lt;p&gt;In the routes/userRoutes.js file:&lt;/p&gt;

&lt;p&gt;const { requireAuth } = require('../middleware/authMiddleware');&lt;br&gt;
router.get('/profile', requireAuth, (req, res) =&amp;gt; {&lt;br&gt;
  // Protected route logic&lt;br&gt;
});`&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Error Handling&lt;/strong&gt;&lt;br&gt;
Proper error handling is essential for providing clear and secure error responses to clients. Create an error handler middleware to handle errors gracefully. Here’s an example of an error handler:&lt;/p&gt;

&lt;p&gt;Create a file called errorMiddleware.js:&lt;/p&gt;

&lt;p&gt;`const handleErrors = (err, req, res, next) =&amp;gt; {&lt;br&gt;
  console.error(err);&lt;br&gt;
  res.status(500).json({ error: 'Something went wrong' });&lt;br&gt;
};&lt;br&gt;
module.exports = { handleErrors };&lt;br&gt;
Include this error handler in your main app.js:&lt;/p&gt;

&lt;p&gt;const { handleErrors } = require('./middleware/errorMiddleware');&lt;br&gt;
app.use(handleErrors);&lt;br&gt;
`&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Adding Security Headers&lt;/strong&gt;&lt;br&gt;
To enhance the security of your REST API, use the helmet middleware to add security headers. These headers help prot`ect your API from common security vulnerabilities. Fortunately, the helmet middleware is already included in your Express setup.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Input Validation&lt;/strong&gt;&lt;br&gt;
Preventing security vulnerabilities like SQL injection and cross-site scripting (XSS) is critical. Implement input validation using libraries like Joi or express-validator. These libraries help validate incoming data to ensure it's safe.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Enabling HTTPS Encryption&lt;/strong&gt;&lt;br&gt;
To secure data transmission between your API and clients, always use HTTPS with SSL/TLS certificates. Tools like Let’s Encrypt provide free SSL certificates, making it easier than ever to enable HTTPS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;:&lt;br&gt;
Developing a secure REST API in Node.js is a pivotal step towards building web and mobile applications that prioritize data security. By following the steps outlined in this guide, which include setting up your development environment, installing necessary packages, defining routes, implementing authentication, and applying security best practices, you can create a secure REST API that users can trust.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to use JWT for Authentication in Node.Js</title>
      <dc:creator>Arowolo Ebine</dc:creator>
      <pubDate>Thu, 05 Jan 2023 20:05:18 +0000</pubDate>
      <link>https://dev.to/arosebine/how-to-use-jwt-for-authentication-in-nodejs-3ach</link>
      <guid>https://dev.to/arosebine/how-to-use-jwt-for-authentication-in-nodejs-3ach</guid>
      <description>&lt;p&gt;JWT is a method or standard way of securely transferring or transmitting between two parties as a json token.&lt;/p&gt;

&lt;p&gt;The compressed size of the tokens easily make it to be transmit and transfer through an URL (POST), or inside an HTTP header. The information is contained in a digitally signed using a Secret_key usually in an environment.&lt;/p&gt;

&lt;p&gt;JWTs are using a secret or private key to sign in.&lt;/p&gt;

&lt;p&gt;So, JWTs are mainly used for authentication. When a user login in to an application, the application then assigns and apportions JWT token to that user. Subsequent requests by the user will include the assigned JWT. This token tells the server what routes, services, and resources the user is allowed to access.&lt;/p&gt;

&lt;p&gt;The JWT token is mainly for these followings:&lt;br&gt;
&lt;code&gt;It provides simple verification through a JSON Web Token&lt;/code&gt; &lt;br&gt;
&lt;code&gt;It is use an authentication service or outsource it&lt;/code&gt;&lt;br&gt;
&lt;code&gt;It provides more security and trustworthiness than cookies or sessions&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;So, let us dive to how to construct it with our application.&lt;/p&gt;

&lt;p&gt;first, you need to create a server like this. &lt;br&gt;
create a directory call jwtauth. you can call yours any name.&lt;/p&gt;

&lt;p&gt;in it. when opened in the terminal, I preferred VSCode, initialise it, I'm using Express.js as a framework.&lt;br&gt;
&lt;code&gt;npm init -y&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and then, you can now install the necessary packages e.g. express, jsonwebtoken, dotenv, etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;npm install express dotenv jsonwebtoken&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;so, after the installation of the above.&lt;/p&gt;

&lt;p&gt;let us create a folder that would housing JWT as a middleware.&lt;br&gt;
&lt;em&gt;&lt;code&gt;middleware/jwtauth.js&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ouQ5yQGZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ge9z6d271pmzttsbw6e.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ouQ5yQGZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ge9z6d271pmzttsbw6e.JPG" alt="Image description" width="464" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;and then, create a controller and route.&lt;br&gt;
&lt;em&gt;&lt;code&gt;controller/user.controller.js&lt;/code&gt;&lt;/em&gt;&lt;br&gt;
this is for the user to login and when successfully login in, it will generate token.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WWZ7TwQ1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/isz41a84dl96v16maejw.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WWZ7TwQ1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/isz41a84dl96v16maejw.JPG" alt="Image description" width="809" height="622"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;after you successfully constructed the login logic as you can see the user has 30mins for the jwt token to be expired.&lt;/p&gt;

&lt;p&gt;Now, let us create the route file.&lt;br&gt;
&lt;em&gt;&lt;code&gt;routes/user.router.js&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Xh94Y1X7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sgdbpdm0omxvpu5swa90.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Xh94Y1X7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sgdbpdm0omxvpu5swa90.JPG" alt="Image description" width="226" height="88"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let us try to login using Postman.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1rkdwc3j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tq9e0tr9f952f92zbx5s.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1rkdwc3j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tq9e0tr9f952f92zbx5s.JPG" alt="Image description" width="880" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>What is a CRUD?</title>
      <dc:creator>Arowolo Ebine</dc:creator>
      <pubDate>Sat, 27 Aug 2022 22:48:28 +0000</pubDate>
      <link>https://dev.to/arosebine/what-is-a-crud-40h2</link>
      <guid>https://dev.to/arosebine/what-is-a-crud-40h2</guid>
      <description>&lt;p&gt;In this my concise article, you will understand the different between CRUD and RESTFul API.&lt;/p&gt;

&lt;p&gt;When building an API, we want our model to provide four basic functionalities which are the four major functions &lt;br&gt;
used to interact with database applications in which we refer to as create, read, update, and delete&lt;br&gt;
resources known as CRUD. This CRUD is essential operations needed in building an endpoint API.&lt;/p&gt;

&lt;p&gt;RESTful APIs most commonly utilize HTTP requests. Four of the most common HTTP methods in a REST environment are GET, POST,&lt;br&gt;
PUT, and DELETE, which are the methods by which a developer can create a CRUD system.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Create: Use the HTTP POST method to create a resource in a REST environment
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Read: Use the GET method to read a resource, retrieving data without altering it
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Update: Use the PUT method to update a resource
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Delete: Use the DELETE method to remove a resource from the system
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
NAME        DESCRIPTION                                                                 SQL EQUIVALENT
Create      Adds one or more new entries.                                               Insert
Read        Retrieves entries that match certain criteria (if there are any).           Select
Update      Changes specific fields in existing entries.                                Update
Delete      Entirely removes one or more existing entries.                              Delete
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>How To Send Email Using NodeMailer in NodeJs</title>
      <dc:creator>Arowolo Ebine</dc:creator>
      <pubDate>Fri, 12 Aug 2022 04:04:00 +0000</pubDate>
      <link>https://dev.to/arosebine/how-to-send-email-using-nodemailer-in-nodejs-4957</link>
      <guid>https://dev.to/arosebine/how-to-send-email-using-nodemailer-in-nodejs-4957</guid>
      <description>&lt;p&gt;For you to send an email in nodejs, you will need the NodeMailer. Nodemailer is a module that enable you&lt;br&gt;
to send email without hassle easily through the Simple Mail Transfer Protocol(SMTP) which allows sending &lt;br&gt;
of messages within servers.&lt;/p&gt;

&lt;p&gt;Most email systems that sendi mail over the Internet supports and allows SMTP.&lt;br&gt;
So, SMTP is the main Transport that NodeMailer use to send mail.&lt;/p&gt;

&lt;p&gt;In this article, you will understand how to send email through NodeMailer using your Gmail Account.&lt;/p&gt;

&lt;p&gt;Ok, Now, let us create a project and&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;after that we will need the following packages, Nodemailer and Express and nodemon. let us install them with this 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 i --save nodemailer express 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;in order not to continue run our server everytime we make changes to our files, we need to install Nodemon to keep our &lt;br&gt;
server running.&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 --save-dev nodemon
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the root directory, create one js file called index.js&lt;/p&gt;

&lt;p&gt;// index.js&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 path = require('path'),
const nodeMailer = require('nodemailer');

const app = express();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;also, create a file that housing your secret keys called .env known as environment variable&lt;/p&gt;

&lt;p&gt;// .env&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PORT = 3540
EMAIL = ebiscoui23@gmail.com
PASSWORD = @#R!*9ewbd32~(
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   const port = process.env.PORT || 4300


   app.listen(port, function(req, res){
      console.log(`Server is running on localhost:${port}`);
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is just to start our project. another thing we need to do is that we need to modify the start script in a package.json file.&lt;/p&gt;

&lt;p&gt;// package.json&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
    "start": "nodemon index"
  },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, when we have to start the node server, we need to write 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;Then if we change the file, it will continue restart the server automatically.&lt;/p&gt;

&lt;p&gt;The Uses EJS as a templating engine.&lt;br&gt;
We need to install a templating engine called ejs(embedded javascript) by typing 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 i --save ejs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create one directory in the root folder called the public.&lt;/p&gt;

&lt;p&gt;// in index.js do these&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.set('view engine', 'ejs');
app.use(express.static('public'));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we have setting an ejs templating engine for our application to serving static files from the public directory.&lt;/p&gt;

&lt;p&gt;Also, we need to create a directory called Views in the root folder. In it, create a file called index.ejs.&lt;/p&gt;

&lt;p&gt;// index.ejs&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&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8"&amp;gt;
    &amp;lt;title&amp;gt;Nodemailer&amp;lt;/title&amp;gt;

  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;div class="container"&amp;gt;
      &amp;lt;div class="seyi"&amp;gt;
        Sending Email using NodeMailer
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;

    &amp;lt;div class="container"&amp;gt;&amp;lt;br /&amp;gt;
      &amp;lt;h1&amp;gt;Send The Email&amp;lt;/h1&amp;gt;&amp;lt;br /&amp;gt;
      &amp;lt;form action="/send-email" method="post"&amp;gt;
        &amp;lt;div class="row"&amp;gt;
            &amp;lt;label for="to"&amp;gt;To:&amp;lt;/label&amp;gt;
            &amp;lt;input type="email" class="form-control" name="to"&amp;gt;
          &amp;lt;/div&amp;gt;

        &amp;lt;div class="row"&amp;gt;
            &amp;lt;label for="subject"&amp;gt;Subject:&amp;lt;/label&amp;gt;
            &amp;lt;input type="text" class="form-control" name="subject"&amp;gt;
        &amp;lt;/div&amp;gt;

        &amp;lt;div class="row"&amp;gt;
              &amp;lt;label for="body"&amp;gt;Body:&amp;lt;/label&amp;gt;
              &amp;lt;textarea cols="5" rows="5"class="form-control" name="body"&amp;gt;&amp;lt;/textarea
        &amp;lt;/div&amp;gt;

        &amp;lt;div class="row"&amp;gt;
            &amp;lt;button type="submit" class="btn btn-success"&amp;gt;Send&amp;lt;/button&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/form&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can give this to the front guys to style it for you.&lt;/p&gt;

&lt;p&gt;After that let come back to index.js to create one route for the home page by typing the following code.&lt;/p&gt;

&lt;p&gt;// index.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.get('/',  (req, res) {
   res.render('index');
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can start the server by 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;It will start at port 3000. Switch to the URL: &lt;a href="http://locahost:3540"&gt;http://locahost:3540&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now to send email in expressjs&lt;br&gt;
before that, nonetheless, we need to install the body-parser package to get all the field data on the server side.&lt;/p&gt;

&lt;p&gt;So, use this command to install it&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 body-parser --save
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let make use this package in our express framework.&lt;/p&gt;

&lt;p&gt;// index.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const bodyParser = require('body-parser');

app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The next thing is to create a route for the post request sent by form and handle its data.&lt;br&gt;
So, our final server.js file will look like this.&lt;/p&gt;

&lt;p&gt;// index.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const bodyParser = require('body-parser');

const app = express();



    app.set('view engine', 'ejs');
    app.use(express.static('public'));
    app.use(bodyParser.urlencoded({extended: true}));
    app.use(bodyParser.json());

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

&lt;/div&gt;



&lt;p&gt;Now, Let us write a function that would use to send the email.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    app.post('/send-email',  (req, res) {
      const transporter = nodeMailer.createTransport({
          host: 'smtp.gmail.com',
          port: 465,
          secure: true,
          auth: {
              user: process.env.EMAIL,
              pass: process.env.PASSWORD,
          }
      });
      const messages = {
          from: process.env.EMAIL,
          to: req.body.to,
          subject: req.body.subject,
          text: req.body.body,
      };

      transporter.sendMail(messages, (error, info) =&amp;gt; {
          if (error) {
              return console.log(error);
          }
          console.log('Message %s sent: %s', info.messageId, info.response);
              res.render('index');
          });
      });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let me show you how to generate PASSWORD(Token) from Gmail account. Please, don't use your normal password but you need to login &lt;br&gt;
with normal password to generate the token.&lt;/p&gt;

&lt;p&gt;When you login into your Gmail account. Type APP PASS in the search bar. it will pop up where you will generate the token.&lt;br&gt;
Here, I have shown you how to send the email via Gmail. You can use any other host. First, you need to grab their API keys.&lt;/p&gt;

&lt;p&gt;Thanks for reading&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How To Resolve Git Conflicts{Merge}</title>
      <dc:creator>Arowolo Ebine</dc:creator>
      <pubDate>Sat, 06 Aug 2022 08:38:00 +0000</pubDate>
      <link>https://dev.to/arosebine/how-to-resolve-git-conflictsmerge-24i2</link>
      <guid>https://dev.to/arosebine/how-to-resolve-git-conflictsmerge-24i2</guid>
      <description>&lt;p&gt;Git is one of the most common source-control systems that enable software developers in all industries, &lt;br&gt;
enabling multiple team members or colleagues to work concurrently and simultaneously on projects. This is known as Version control systems&lt;br&gt;
which are all about managing contributions between multiple distributed developers.&lt;/p&gt;

&lt;p&gt;So,since many users are simultaneously working from different places on the same file, however, this may end up with a merge conflict. This article explains the basics of Git merge&lt;br&gt;
conflicts and this is where Git merge command is involve to resolving a Git merge conflict. &lt;/p&gt;

&lt;p&gt;I would like to show the common git commands used to resolve merge conflict. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Basic Git Commands are:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git init
git add 
git commit
git status
git merge
git push
git pull
git reset
git checkout
git diff 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Conflicts in Git environment generally arise when two people have changed the same lines in a file, or if one developer deleted a file while another developer was modifying it. In these cases, Git cannot automatically determine what is correct. &lt;/p&gt;

&lt;p&gt;So, this Conflict is only made known to the team that conducting the merge, the rest of the team is unaware of the conflict. &lt;br&gt;
Git will mark the file as being conflicted and halt the merging process. It is then the developers' responsibility &lt;br&gt;
to resolve the conflict.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Categories of merge conflicts&lt;/strong&gt;&lt;br&gt;
When contemplate of resolve merge conflict, know that there are two stages involved at a separate points. &lt;br&gt;
When starting and during a merge process. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Starting the Merge Process:&lt;/strong&gt;&lt;br&gt;
In this case, if there are changes in the PWD (working directory) in the current project, merging won’t start. &lt;br&gt;
So, conflicts happen due to pending changes that need to be stabilized using the Git commands.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;During the Merge Process:&lt;/strong&gt;&lt;br&gt;
In this stage failure indicates that there is a conflict between the local branch and the remote branch during the merge process.&lt;br&gt;
In this case, Git resolves as much as possible, but there are things that have to be resolved manually in the conflicted files.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now, let us look at how to resolve it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to Resolve Merge Conflicts in Git?&lt;/strong&gt;&lt;br&gt;
These are a few steps needed to resolve merge conflicts in Git.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open the conflicted file and make any necessary changes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After edit and make the necessary change in the file, we can make use of the git add. a command to stage the new merged content.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The final step is to create a new commit with the use of git commit command.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then, Git will create a new merge commit to complete the merge.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let us now look at the Git commands that perhaps we may use to resolving the conflict.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. git log --merge 
This command helps to populate the list of commits that are causing the conflict.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2. git diff 
This helps to identify the differences between the states repositories or files.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3. git checkout 
It is used to undo the changes made to the file, or for changing branches.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;4. git reset --mixed 
It also is used to undo changes to the working directory and current folder
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;5. git merge --abort
This command helps in exiting the merge process and returning back to the state before the merging began.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;6. git reset
It is used at the time of merge conflict to reset the conflicted files to their original state.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iKjeU5B2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/01za77smc0fpsvwfon5e.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iKjeU5B2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/01za77smc0fpsvwfon5e.JPG" alt="**Git command demo:**" width="452" height="205"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hPM4WqV0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u7iwkv9d3bl3e1ynv0y6.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hPM4WqV0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u7iwkv9d3bl3e1ynv0y6.JPG" alt="**Git Command Demo:**" width="595" height="234"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>node</category>
    </item>
    <item>
      <title>THE BEST TWO WAYS TO SECURED YOUR WEB APP</title>
      <dc:creator>Arowolo Ebine</dc:creator>
      <pubDate>Wed, 03 Aug 2022 07:37:00 +0000</pubDate>
      <link>https://dev.to/arosebine/the-best-two-ways-to-secured-your-web-app-57gp</link>
      <guid>https://dev.to/arosebine/the-best-two-ways-to-secured-your-web-app-57gp</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;a href="//linkedin.com/in/arowolo-ebine-97105483"&gt;THE BEST TWO WAYS TO SECURED YOUR WEB APP:&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Validate User Inputs:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Accordingly, Injection-based attacks can come in so many ways; XSS, SQL injections, host header injection, and OS command injection are a few examples of these attacks.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Therefore, Injection-based attacks have over the years made their way into the OWASP (Open Web Application Security Project) and SANS Top 25 CWE (Common Weakness Enumeration) many times.&lt;/p&gt;

&lt;p&gt;So, in the web development, we need to validate all inputs before the application processes the data to mitigate injection-based attacks.&lt;/p&gt;

&lt;p&gt;E.g., the phone number field, Password field, Name field, they must only accept an acceptable format with specific numeric and special characters.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Managing Application Secrets:&lt;/strong&gt;&lt;br&gt;
This is another crucial way to securitized the web app secret credentials by managing sensitive secrets such as database connection strings, API keys, and credentials is mandatory in any application.&lt;br&gt;
Therefore, we should stop keeping these secrets in the codebase at all costs and follow standard rules and methods to store them.&lt;/p&gt;

&lt;p&gt;for example, You can use environment variables within the operating system to store this sensitive information, and we can use Node.js to call these environment variables.&lt;/p&gt;

&lt;p&gt;However, there are instances where the application would require more than one variable instantiated. At this juncture, the only best way to manage secrets is to use the &lt;code&gt;dotenv&lt;/code&gt; package.&lt;/p&gt;

&lt;p&gt;so, you can easily install it using npm or Yarn as follows:&lt;/p&gt;
&lt;h4&gt;
  
  
  NPM
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;npm install dotenv&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;
  
  
  Yarn
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;yarn add dotenv&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Then, create a &lt;code&gt;.env&lt;/code&gt; file at the project root and define all the secrets in that file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;NODE_ENV&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;develpment&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;MONGODB_URL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;"mongodb_url:uerbsf@kgeyfdop_jhf"&lt;/span&gt;
&lt;span class="n"&gt;PORT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;
&lt;span class="n"&gt;USERNAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;secret123&lt;/span&gt;
&lt;span class="n"&gt;PASSWORD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;secret123&lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, you can require and use these secrets in the application like below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dotenv&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nx"&gt;mongoose&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
&lt;span class="na"&gt;host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="na"&gt;username&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;MONGODB_URL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PASSWORD&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Most importantly, make sure to include .env files in the .gitignore file to prevent them from being pushed to the Git repository.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>const animals = ['lion', 'goat', 'frog',]; console.log(animals)</title>
      <dc:creator>Arowolo Ebine</dc:creator>
      <pubDate>Wed, 06 Jul 2022 21:01:20 +0000</pubDate>
      <link>https://dev.to/arosebine/const-animals-lion-goat-frog-consoleloganimals-301b</link>
      <guid>https://dev.to/arosebine/const-animals-lion-goat-frog-consoleloganimals-301b</guid>
      <description></description>
    </item>
  </channel>
</rss>
