<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by The Syntax Sushi on Medium]]></title>
        <description><![CDATA[Stories by The Syntax Sushi on Medium]]></description>
        <link>https://medium.com/@ravibelwal?source=rss-9a971512e558------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*SmTS-KPmpapX8x_qo37yTQ.jpeg</url>
            <title>Stories by The Syntax Sushi on Medium</title>
            <link>https://medium.com/@ravibelwal?source=rss-9a971512e558------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 13:21:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ravibelwal/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Design Patterns in Node.js]]></title>
            <link>https://medium.com/@ravibelwal/design-patterns-in-node-js-1c241022e32e?source=rss-9a971512e558------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c241022e32e</guid>
            <category><![CDATA[circuit-breaker]]></category>
            <category><![CDATA[the-syntax-sushi]]></category>
            <category><![CDATA[ravi-belwal]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[design-patterns-in-nodejs]]></category>
            <dc:creator><![CDATA[The Syntax Sushi]]></dc:creator>
            <pubDate>Fri, 14 Mar 2025 17:10:55 GMT</pubDate>
            <atom:updated>2025-03-14T17:21:52.552Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ztk7TAD2YDifoLvMvZeZLg.png" /></figure><p>Node.js is widely used for building scalable and efficient applications, but without proper structure, projects can become unmanageable. This is where <strong>design patterns</strong> come in! They provide <strong>reusable solutions</strong> to common coding problems and help build <strong>maintainable, scalable applications</strong>.</p><p>In this post, we’ll explore <strong>key design patterns in Node.js</strong> with <strong>real-world relatable examples</strong> to help you master them.</p><h3>1️⃣ Singleton Pattern: The One and Only</h3><h3>Practical Scenario:</h3><p>Imagine an <strong>online ticket booking system</strong> where multiple users access the <strong>database connection</strong>. If each request creates a new database instance, it wastes resources and can slow down the system. The <strong>solution</strong> is to create a single database instance.</p><h3>When to Use?</h3><ul><li>Database connections (MongoDB, PostgreSQL)</li><li>Caching services (Redis, in-memory caches)</li><li>Logging utilities (Winston, Morgan)</li></ul><h3>Implementation in Node.js:</h3><pre>class Database {<br>  constructor() {<br>    if (!Database.instance) {<br>      Database.instance = this;<br>      this.connection = &quot;Database Connection Established&quot;;<br>    }<br>    return Database.instance;<br>  }<br>}<br>const db1 = new Database();<br>const db2 = new Database();<br>console.log(db1 === db2); // true (Same instance)</pre><p><strong>📌 Takeaway:</strong> Ensures <strong>only one instance</strong> is created throughout the application.</p><h3>2️⃣ Factory Pattern: The Object Creator</h3><h3>Practical Scenario:</h3><p>Think of an <strong>e-commerce platform</strong> where you have different user roles: <strong>Admin, Seller, Customer</strong>. Instead of writing separate classes for each, we use a <strong>factory function</strong> to create objects dynamically.</p><h3>When to Use?</h3><ul><li>When object creation logic is complex</li><li>When multiple object types share similar structure</li><li>When you need flexibility in object creation</li></ul><h3>Implementation in Node.js:</h3><pre>class User {<br>  constructor(name, role) {<br>    this.name = name;<br>    this.role = role;<br>  }<br>}<br>class UserFactory {<br>  createUser(name, role) {<br>    return new User(name, role);<br>  }<br>}<br>const factory = new UserFactory();<br>const admin = factory.createUser(&quot;Alice&quot;, &quot;Admin&quot;);<br>console.log(admin);</pre><p><strong>📌 Takeaway:</strong> <strong>Easier object creation</strong> without hardcoding classes.</p><h3>3️⃣ Observer Pattern: Event-Driven Magic</h3><h3>Practical Scenario:</h3><p>Think of a <strong>news portal</strong> where users subscribe to different topics (e.g., Sports, Tech, Business). When new content is published, only the <strong>subscribed users get notified</strong>.</p><h3>When to Use?</h3><ul><li>Event-driven systems (Node.js Event Emitters)</li><li>Real-time applications (Notifications, Pub-Sub systems)</li><li>Microservices communication</li></ul><h3>Implementation in Node.js:</h3><pre>const EventEmitter = require(&#39;events&#39;);<br>class NewsPublisher extends EventEmitter {<br>  publish(news) {<br>    console.log(`News Published: ${news}`);<br>    this.emit(&quot;news&quot;, news);<br>  }<br>}<br>class Subscriber {<br>  constructor(name) {<br>    this.name = name;<br>  }<br>  receive(news) {<br>    console.log(`${this.name} received: ${news}`);<br>  }<br>}<br>const publisher = new NewsPublisher();<br>const user1 = new Subscriber(&quot;Alice&quot;);<br>const user2 = new Subscriber(&quot;Bob&quot;);<br>publisher.on(&quot;news&quot;, user1.receive.bind(user1));<br>publisher.on(&quot;news&quot;, user2.receive.bind(user2));<br>publisher.publish(&quot;Tech Giants Announce New AI Breakthrough!&quot;);</pre><p><strong>📌 Takeaway:</strong> <strong>One-to-many communication</strong> pattern. Great for <strong>notifications &amp; real-time updates</strong>.</p><h3>4️⃣ Adapter Pattern: Bridging the Gap</h3><h3>Practical Scenario:</h3><p>Suppose you’re integrating a <strong>third-party payment gateway</strong> into your application. However, your existing system expects data in a different format. The <strong>Adapter Pattern</strong> helps by acting as a bridge between the two systems.</p><h3>When to Use?</h3><ul><li>Integrating third-party APIs</li><li>Converting data formats</li><li>Adapting legacy code to new requirements</li></ul><h3>Implementation in Node.js:</h3><pre>class OldPaymentSystem {<br>  process(amount) {<br>    console.log(`Processing payment of $${amount} using old system.`);<br>  }<br>}<br>class PaymentAdapter {<br>  constructor() {<br>    this.oldSystem = new OldPaymentSystem();<br>  }<br>  processPayment(amount) {<br>    this.oldSystem.process(amount);<br>  }<br>}<br>const payment = new PaymentAdapter();<br>payment.processPayment(100);</pre><p><strong>📌 Takeaway:</strong> Helps integrate incompatible systems without modifying existing code.</p><h3>5️⃣ Middleware Pattern: Request Processing Chain</h3><h3>Practical Scenario:</h3><p>In an Express.js application, requests must go through various <strong>authentication, logging, and validation</strong> steps before reaching the final handler.</p><h3>When to Use?</h3><ul><li>Web frameworks (Express.js middleware)</li><li>Authentication and request validation</li><li>Logging and error handling</li></ul><h3>Implementation in Node.js (Express.js example):</h3><pre>const express = require(&#39;express&#39;);<br>const app = express();<br>// Middleware function<br>app.use((req, res, next) =&gt; {<br>  console.log(`Request URL: ${req.url}`);<br>  next();<br>});<br>app.get(&#39;/&#39;, (req, res) =&gt; {<br>  res.send(&#39;Hello, World!&#39;);<br>});<br>app.listen(3000, () =&gt; console.log(&#39;Server running on port 3000&#39;));</pre><p><strong>📌 Takeaway:</strong> Useful for <strong>chaining operations</strong> like authentication, logging, and validation.</p><h3>6️⃣ Circuit Breaker Pattern: Fail-Safe API Calls</h3><h3>Practical Scenario:</h3><p>Imagine your application depends on an <strong>external API</strong>. If the API goes down, your app keeps making requests, causing performance issues. The <strong>Circuit Breaker Pattern</strong> helps prevent repeated failures by temporarily stopping requests when a failure threshold is reached.</p><h3>When to Use?</h3><ul><li>Preventing cascading failures in microservices</li><li>Handling API timeouts and slow responses</li></ul><h3>Implementation in Node.js (Using opossum library):</h3><pre>const CircuitBreaker = require(&#39;opossum&#39;);<br>const fetch = require(&#39;node-fetch&#39;);<br>async function fetchData() {<br>  const response = await fetch(&quot;https://jsonplaceholder.typicode.com/posts&quot;);<br>  return response.json();<br>}<br>const options = { timeout: 3000, errorThresholdPercentage: 50, resetTimeout: 5000 };<br>const breaker = new CircuitBreaker(fetchData, options);<br>breaker.fallback(() =&gt; &quot;Service unavailable, try again later&quot;);<br>breaker.fire().then(console.log).catch(console.error);</pre><p><strong>📌 Takeaway:</strong> Helps maintain <strong>API resilience</strong> and prevents <strong>excessive retries</strong>.</p><h3>7️⃣ Proxy Pattern: Controlled Access</h3><h3>Practical Scenario:</h3><p>Imagine you have an <strong>API</strong> that is being overused by clients. Instead of exposing it directly, you create a <strong>proxy</strong> that controls access, caches responses, or logs requests.</p><h3>When to Use?</h3><ul><li>API rate limiting</li><li>Caching responses to optimize performance</li><li>Security layers (authentication &amp; authorization)</li></ul><h3>Implementation in Node.js:</h3><pre>class API {<br>  fetchData() {<br>    return &quot;Data from API&quot;;<br>  }<br>}<br>class APIProxy {<br>  constructor() {<br>    this.api = new API();<br>    this.cache = null;<br>  }<br>fetchData() {<br>    if (!this.cache) {<br>      this.cache = this.api.fetchData();<br>    }<br>    return this.cache;<br>  }<br>}<br>const proxy = new APIProxy();<br>console.log(proxy.fetchData()); // Fetches from API<br>console.log(proxy.fetchData()); // Fetches from cache</pre><p><strong>📌 Takeaway:</strong> Helps <strong>optimize performance and control access</strong> to resources.</p><h3>8️⃣ Strategy Pattern: Interchangeable Algorithms</h3><h3>Practical Scenario:</h3><p>Think of a <strong>payment system</strong> that supports multiple payment methods (credit card, PayPal, Bitcoin). Instead of hardcoding logic, we can define multiple strategies.</p><h3>When to Use?</h3><ul><li>When you need <strong>multiple interchangeable algorithms</strong></li><li>Payment processing, sorting strategies, authentication mechanisms</li></ul><h3>Implementation in Node.js:</h3><pre>class CreditCardPayment {<br>  pay(amount) {<br>    console.log(`Paid $${amount} using Credit Card`);<br>  }<br>}<br>class PayPalPayment {<br>  pay(amount) {<br>    console.log(`Paid $${amount} using PayPal`);<br>  }<br>}<br>class PaymentProcessor {<br>  constructor(strategy) {<br>    this.strategy = strategy;<br>  }<br>  setStrategy(strategy) {<br>    this.strategy = strategy;<br>  }<br>  pay(amount) {<br>    this.strategy.pay(amount);<br>  }<br>}<br>const processor = new PaymentProcessor(new CreditCardPayment());<br>processor.pay(100);<br>processor.setStrategy(new PayPalPayment());<br>processor.pay(200);</pre><p><strong>📌 Takeaway:</strong> Provides <strong>flexibility</strong> by allowing different implementations at runtime.</p><h3>Conclusion: Why Use Design Patterns?</h3><p>Using the right design pattern <strong>improves code quality</strong> and <strong>makes development scalable</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c241022e32e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Logging in Node.js with Winston and Morgan]]></title>
            <link>https://medium.com/@ravibelwal/logging-in-node-js-with-winston-and-morgan-6236ad985ccd?source=rss-9a971512e558------2</link>
            <guid isPermaLink="false">https://medium.com/p/6236ad985ccd</guid>
            <category><![CDATA[the-syntax-sushi]]></category>
            <category><![CDATA[ravi-belwal]]></category>
            <category><![CDATA[winston]]></category>
            <category><![CDATA[morgan]]></category>
            <category><![CDATA[logging-in-nodejs]]></category>
            <dc:creator><![CDATA[The Syntax Sushi]]></dc:creator>
            <pubDate>Mon, 03 Mar 2025 09:01:24 GMT</pubDate>
            <atom:updated>2025-03-03T09:01:24.256Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M5MQOEb7SirsrbBjn9hvZA.png" /></figure><p>Logging is an essential part of any application. It helps in debugging, monitoring, and analyzing application behavior. In Node.js, two popular logging libraries are <strong>Winston</strong> and <strong>Morgan</strong>. In this article, we will explore these libraries, their differences, how to use them, and advanced techniques like logging to multiple outputs (console, file, and cloud platforms like Google Cloud).</p><h3>Why Logging is Important</h3><ul><li>Helps in debugging and troubleshooting.</li><li>Tracks user activities and API requests.</li><li>Monitors application health and performance.</li><li>Detects errors and security issues.</li></ul><h3>Using Winston and Morgan</h3><h3>Winston</h3><p>Winston is a powerful and flexible logging library for Node.js. It supports multiple transports, allowing logs to be stored in different locations like the console, files, databases, and cloud services.</p><h4>Key Features of Winston</h4><ul><li>Supports multiple transports (console, file, HTTP, etc.).</li><li>Allows custom log formats and metadata.</li><li>Supports different logging levels (info, error, debug, etc.).</li><li>Can be integrated with cloud logging services like Google Cloud Logging.</li></ul><h3>Morgan</h3><p>Morgan is an HTTP request logger middleware for Express.js. It logs request details like method, URL, status, response time, and more. It is lightweight and primarily used for logging incoming requests.</p><h4>Key Features of Morgan</h4><ul><li>Logs HTTP requests in a structured format.</li><li>Supports predefined and custom log formats.</li><li>Can be combined with Winston for advanced logging.</li><li>Helps in monitoring API requests and responses.</li></ul><p><strong>Difference between Winston and Morgan:</strong></p><p>Feature Winston Morgan Purpose General logging for applications HTTP request logging Supports multiple transports Yes No Custom log levels Yes No Middleware for Express No Yes Stores logs in files/databases Yes No</p><h3>Setting Up Winston and Morgan in a Node.js Project</h3><h3>1. Install Dependencies</h3><p>Run the following command to install Winston and Morgan:</p><pre>npm install winston morgan</pre><h3>2. Configuring Winston Logger</h3><p>Create a logger.js file to configure Winston:</p><pre>import winston from &#39;winston&#39;;<br>import path from &#39;path&#39;;<br>const { combine, timestamp, json } = winston.format;<br>const logger = winston.createLogger({<br>    level: &#39;info&#39;,<br>    format: combine(<br>        timestamp({ format: &#39;YYYY-MM-DD HH:mm:ss&#39; }),<br>        json()<br>    ),<br>    transports: [<br>        new winston.transports.Console(),<br>        new winston.transports.File({ filename: path.join(&#39;./logs&#39;, &#39;app.log&#39;) })<br>    ]<br>});<br>export default logger;</pre><h3>3. Setting Up Morgan for HTTP Logging</h3><p>Create morganMiddleware.js:</p><pre>import morgan from &#39;morgan&#39;;<br>import logger from &#39;./logger.js&#39;;<br>const morganMiddleware = morgan(<br>    (tokens, req, res) =&gt; {<br>        return JSON.stringify({<br>            method: tokens.method(req, res),<br>            url: tokens.url(https://medium.com/req,%20res),<br>            status: tokens.status(req, res),<br>            responseTime: `${tokens[&#39;response-time&#39;](req, res)}ms`,<br>            userAgent: tokens[&#39;user-agent&#39;](req, res)<br>        });<br>    },<br>    {<br>        stream: { write: (message) =&gt; logger.info(message.trim()) }<br>    }<br>);<br>export default morganMiddleware;</pre><h3>4. Integrating in an Express.js Application</h3><p>Modify server.js:</p><pre>import express from &#39;express&#39;;<br>import logger from &#39;./logger.js&#39;;<br>import morganMiddleware from &#39;./morganMiddleware.js&#39;;<br>const app = express();<br>// Use Morgan Middleware<br>app.use(morganMiddleware);<br>app.get(&#39;/&#39;, (req, res) =&gt; {<br>    logger.info(&#39;Homepage accessed&#39;);<br>    res.send(&#39;Hello, World!&#39;);<br>});<br>app.listen(3000, () =&gt; {<br>    logger.info(&#39;Server started on port 3000&#39;);<br>});</pre><h3>Logging to Different Outputs</h3><h3>1. Logging to Google Cloud</h3><p>Install Google Cloud Logging library:</p><pre>npm install @google-cloud/logging-winston</pre><p>Modify logger.js:</p><pre>import { LoggingWinston } from &#39;@google-cloud/logging-winston&#39;;<br>const loggingWinston = new LoggingWinston();<br>const logger = winston.createLogger({<br>    transports: [<br>        new winston.transports.Console(),<br>        new winston.transports.File({ filename: &#39;logs/app.log&#39; }),<br>        loggingWinston // Send logs to Google Cloud<br>    ]<br>});</pre><h3>2. Logging Errors Separately</h3><pre>logger.add(new winston.transports.File({ filename: &#39;logs/errors.log&#39;, level: &#39;error&#39; }));</pre><h3>3. Logging to a Database (MongoDB)</h3><p>Install MongoDB transport:</p><pre>npm install winston-mongodb</pre><p>Modify logger.js:</p><pre>import winston from &#39;winston&#39;;<br>import { MongoDB } from &#39;winston-mongodb&#39;;<br>logger.add(new MongoDB({ db: &#39;mongodb://localhost:27017/logs&#39;, collection: &#39;app_logs&#39; }));</pre><h3>Sample Log Output</h3><h3>Console Output:</h3><pre>{&quot;level&quot;:&quot;info&quot;,&quot;message&quot;:&quot;Server started on port 3000&quot;,&quot;timestamp&quot;:&quot;2025-03-02 12:00:00&quot;}</pre><h3>File Output (app.log):</h3><pre>{&quot;level&quot;:&quot;info&quot;,&quot;message&quot;:&quot;Homepage accessed&quot;,&quot;timestamp&quot;:&quot;2025-03-02 12:01:10&quot;}</pre><h3>Google Cloud Output:</h3><pre>Stored in Google Cloud Logs</pre><h3>Alternatives to Winston and Morgan</h3><p>Library Purpose Pino Fast JSON-based logging Bunyan Structured logging for large apps Log4js Flexible logging with different appenders</p><h3>Conclusion</h3><ul><li><strong>Use Winston</strong> for general logging (console, files, databases, cloud).</li><li><strong>Use Morgan</strong> for HTTP request logging.</li><li><strong>Combine both</strong> for a robust logging strategy.</li><li><strong>Extend logging</strong> to Google Cloud, databases, or external services.</li></ul><p>By following these practices, you can effectively monitor, debug, and maintain your Node.js applications.</p><p>🚀 Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6236ad985ccd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CORS: Why Your Browser Blocks API Requests and How to Fix It]]></title>
            <link>https://medium.com/@ravibelwal/cors-why-your-browser-blocks-api-requests-and-how-to-fix-it-730fe7653d12?source=rss-9a971512e558------2</link>
            <guid isPermaLink="false">https://medium.com/p/730fe7653d12</guid>
            <category><![CDATA[preflight-request]]></category>
            <category><![CDATA[cors]]></category>
            <category><![CDATA[cors-fix]]></category>
            <category><![CDATA[the-syntax-sushi]]></category>
            <category><![CDATA[ravi-belwal]]></category>
            <dc:creator><![CDATA[The Syntax Sushi]]></dc:creator>
            <pubDate>Sun, 02 Mar 2025 14:47:16 GMT</pubDate>
            <atom:updated>2025-03-02T17:23:54.487Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D_PCDDDyHuJH3wJJXvGdzQ.png" /></figure><h3>Ever Wondered Why Your API Requests Get Blocked?</h3><p>You’re building a frontend app, and everything is going great — until you try fetching data from your backend. Suddenly, your browser throws an error like this:</p><pre>Access to fetch at &#39;http://localhost:5000/api&#39; from origin &#39;http://localhost:3000&#39; has been blocked by CORS policy</pre><p>If you’ve seen this and wondered what it means, don’t worry. You’re not alone! Let’s break it down in a simple way.</p><h3>What is CORS, and Why Does It Exist?</h3><p>CORS (<strong>Cross-Origin Resource Sharing</strong>) is a security feature implemented by browsers to prevent <strong>unauthorized cross-origin requests</strong>. Simply put, it stops your frontend from randomly talking to any backend it wants without permission.</p><p>Imagine this:</p><ul><li>You own a <strong>cookie shop</strong> 🍪 (your API server at <a href="http://localhost:5000).">http://localhost:5000).</a></li><li>A customer (your frontend at http://localhost:3000) wants to buy cookies.</li><li>But browsers are <strong>paranoid guardians</strong>. They don’t trust just anyone to take your cookies!</li><li>Unless you explicitly say, <em>“Hey, frontend, you’re allowed to talk to me!”</em>, your cookies (data) remain locked. 🔒</li></ul><p>That’s <strong>CORS in a nutshell!</strong></p><h3>Preflight vs. Postflight Requests — Like an Airport!</h3><h3>✈️ Preflight Request (Checking the Rules)</h3><p>Before letting your request <strong>actually hit</strong> the server, the browser sends an <strong>OPTIONS request</strong> to check:</p><p>✔️ Is this origin (http://localhost:3000) allowed?<br> ✔️ Are these HTTP methods (POST, PUT, etc.) allowed?<br> ✔️ Can the request include credentials (cookies, authorization headers)?</p><h4>Example of a Preflight Request</h4><pre>OPTIONS /api/users HTTP/1.1<br>Host: localhost:5000<br>Origin: http://localhost:3000<br>Access-Control-Request-Method: POST</pre><p>If the server responds with a thumbs-up ✅, the browser <strong>proceeds</strong> with the actual request. Otherwise, it blocks it.</p><h3>🛬 Postflight Request (The Actual Data Request)</h3><p>Once the <strong>preflight check</strong> is approved, the browser sends the real request, like:</p><pre>POST /api/users HTTP/1.1<br>Host: localhost:5000<br>Origin: http://localhost:3000<br>Authorization: Bearer xyz123<br>{ &quot;name&quot;: &quot;Alice&quot; }</pre><p>The backend then processes it and sends back cookies (or data) as needed.</p><h3>How to Fix CORS Errors in Express.js?</h3><p>Okay, let’s <strong>solve this mess</strong> in our backend. Express.js provides a package called cors to make this easy.</p><h3>Step 1: Install CORS Middleware</h3><pre>npm install cors</pre><h3>Step 2: Enable CORS in Express</h3><h4>✅ Allow All Origins (Not Recommended for Production)</h4><pre>const express = require(&#39;express&#39;);<br>const cors = require(&#39;cors&#39;);<br>const app = express();<br>app.use(cors()); // Open to everyone (😱 Not safe for production!)</pre><h4>✅ Allow Only Specific Origins (Better Approach)</h4><pre>app.use(<br>  cors({<br>    origin: &#39;http://localhost:3000&#39;, // Allow only this frontend<br>    methods: [&#39;GET&#39;, &#39;POST&#39;, &#39;PUT&#39;, &#39;DELETE&#39;],<br>    credentials: true // Allow cookies and authorization headers<br>  })<br>);</pre><h4>✅ Manually Handle CORS (For Full Control)</h4><pre>app.use((req, res, next) =&gt; {<br>  res.header(&#39;Access-Control-Allow-Origin&#39;, &#39;http://localhost:3000&#39;);<br>  res.header(&#39;Access-Control-Allow-Methods&#39;, &#39;GET, POST, PUT, DELETE, OPTIONS&#39;);<br>  res.header(&#39;Access-Control-Allow-Headers&#39;, &#39;Content-Type, Authorization&#39;);<br>  next();<br>});</pre><h4>✅ Handle Preflight Requests</h4><pre>app.options(&#39;*&#39;, cors()); // Allow all OPTIONS requests (for preflight checks)</pre><h3>Fixing CORS on the Frontend (Temporary Workarounds)</h3><p>If you <strong>don’t control the backend</strong>, you can still bypass CORS <strong>for development only</strong>:</p><h4>1️⃣ Use a Proxy in React (Easiest Solution)</h4><p>Modify your package.json:</p><pre>&quot;proxy&quot;: &quot;http://localhost:5000&quot;</pre><p>This makes requests appear as if they are from the same origin.</p><h4>2️⃣ Use a CORS Browser Extension</h4><p>Search for “CORS Unblock” extensions on Chrome to temporarily bypass restrictions.</p><h4>3️⃣ Run Chrome with Disabled CORS (Unsafe)</h4><p>You can start Chrome with CORS disabled:</p><pre>chrome --disable-web-security --user-data-dir=&quot;/tmp/chrome_dev&quot;</pre><p>❌ <strong>Warning:</strong> This is highly insecure, only use it for debugging!</p><h3>Wrapping Up 🚀</h3><p>✅ <strong>CORS exists to prevent unauthorized cross-origin requests.</strong><br> ✅ <strong>Browsers send preflight OPTIONS requests to verify access.</strong><br> ✅ <strong>Fix CORS in Express by using the </strong><strong>cors middleware or setting headers manually.</strong><br> ✅ <strong>Use frontend proxies or extensions as temporary fixes.</strong></p><p>Now go forth and <strong>unblock those CORS errors like a pro!</strong> 🏆🚀</p><h3>Got More CORS Troubles?</h3><p>Drop a comment! Let’s fix them together. Happy coding! 🎉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=730fe7653d12" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Securing Your Express.js Application: Building a Robust Middleware to Prevent XSS and SQL Injection]]></title>
            <link>https://medium.com/@ravibelwal/securing-your-express-js-application-building-a-robust-middleware-to-prevent-xss-and-sql-injection-2e19e94b78c6?source=rss-9a971512e558------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e19e94b78c6</guid>
            <category><![CDATA[code-sanitization]]></category>
            <category><![CDATA[the-syntax-sushi]]></category>
            <category><![CDATA[sql-injection]]></category>
            <category><![CDATA[prevent-xss-sql-injection]]></category>
            <category><![CDATA[ravi-belwal]]></category>
            <dc:creator><![CDATA[The Syntax Sushi]]></dc:creator>
            <pubDate>Sun, 02 Mar 2025 13:08:05 GMT</pubDate>
            <atom:updated>2025-03-02T13:08:05.935Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cnT44PFbNfamDEWNaTdZSw.png" /></figure><p>Web security is a critical concern when building modern web applications. Attackers often exploit vulnerabilities like <strong>Cross-Site Scripting (XSS)</strong> and <strong>SQL Injection</strong> to compromise systems and steal data. In this article, we will build an <strong>Express.js middleware</strong> to sanitize user inputs, ensuring that your application remains secure from these common threats.</p><h3>Understanding XSS and SQL Injection</h3><h3>1. Cross-Site Scripting (XSS)</h3><p>XSS attacks occur when an attacker injects malicious scripts into a web page that is viewed by other users. For example:</p><pre>&lt;input type=&quot;text&quot; value=&quot;&lt;script&gt;alert(&#39;Hacked!&#39;)&lt;/script&gt;&quot;&gt;</pre><p>If the application fails to sanitize inputs properly, this script could be executed in a user’s browser, leading to data theft or session hijacking.</p><h3>2. SQL Injection</h3><p>SQL Injection occurs when an attacker manipulates database queries by injecting malicious SQL code. Example:</p><pre>SELECT * FROM users WHERE username = &#39;&#39; OR &#39;1&#39;=&#39;1&#39;;</pre><p>Without proper sanitization, this query could allow unauthorized access to sensitive data.</p><h3>Building an Express.js Middleware for Input Sanitization</h3><p>We will create an Express middleware that sanitizes incoming request data and blocks any potential <strong>XSS</strong> or <strong>SQL Injection</strong> attacks.</p><h3>Step 1: Install Required Packages</h3><p>We will use two npm packages:</p><ul><li><a href="https://www.npmjs.com/package/xss">xss</a> - To sanitize inputs against XSS.</li><li><a href="https://www.npmjs.com/package/sqlstring">sqlstring</a> - To escape SQL queries and prevent SQL Injection.</li></ul><p>Run the following command to install these dependencies:</p><pre>npm install express xss sqlstring</pre><h3>Step 2: Implement the Middleware</h3><p>Create a new file sanitizeMiddleware.ts and add the following code:</p><pre>import { Request, Response, NextFunction } from &#39;express&#39;;<br>import xss, { IWhiteList, IFilterXSSOptions } from &#39;xss&#39;;<br>import sqlString from &#39;sqlstring&#39;;<br><br>// Define allowed safe HTML tags and attributes<br>const safeWhitelist: IWhiteList = {<br>  a: [&#39;href&#39;, &#39;title&#39;, &#39;target&#39;],<br>  b: [], i: [], strong: [], em: [], p: [],<br>  ul: [], li: [], ol: [], br: [],<br>  span: [&#39;style&#39;],<br>  h1: [], h2: [], h3: [], h4: [], h5: [], h6: [],<br>};<br>// XSS filtering options<br>const xssOptions: IFilterXSSOptions = {<br>  whiteList: safeWhitelist,<br>  stripIgnoreTag: true,<br>  stripIgnoreTagBody: [&#39;script&#39;, &#39;iframe&#39;, &#39;object&#39;, &#39;embed&#39;],<br>};<br>// Define the error object type<br>interface SanitizationError {<br>  key: string;<br>  value: any;<br>  sanitizedValue: any;<br>  type: &#39;XSS&#39; | &#39;SQL Injection&#39;;<br>}<br>// Express Middleware for Input Sanitization<br>export const sanitizeMiddleware = (req: Request, res: Response, next: NextFunction): void =&gt; {<br>  const errors: SanitizationError[] = [];<br>  const sanitizeAndDetect = (value: string, key: string): string =&gt; {<br>    // XSS Protection<br>    const xssSanitized = xss(value, xssOptions);<br>    if (xssSanitized !== value) {<br>      errors.push({ key, value, sanitizedValue: xssSanitized, type: &#39;XSS&#39; });<br>    }<br>    // SQL Injection Protection<br>    const sqlEscaped = sqlString.escape(value);<br>    if (sqlEscaped.includes(&quot;&#39; OR &quot;) || sqlEscaped.includes(&quot;--&quot;)) {<br>      errors.push({ key, value, sanitizedValue: sqlEscaped, type: &#39;SQL Injection&#39; });<br>    }<br>    return xssSanitized;<br>  };<br>  const sanitizeObject = (obj: Record&lt;string, any&gt;): void =&gt; {<br>    for (const key in obj) {<br>      if (typeof obj[key] === &#39;string&#39;) {<br>        obj[key] = sanitizeAndDetect(obj[key], key);<br>      } else if (typeof obj[key] === &#39;object&#39; &amp;&amp; obj[key] !== null) {<br>        sanitizeObject(obj[key]); // Recursively sanitize nested objects<br>      }<br>    }<br>  };<br>  sanitizeObject(req.body);<br>  sanitizeObject(req.query);<br>  sanitizeObject(req.params);<br>  if (errors.length &gt; 0) {<br>    res.status(400).json({<br>      error: &#39;Potential security risks detected&#39;,<br>      details: errors.map(err =&gt; ({<br>        key: err.key,<br>        type: err.type,<br>        originalValue: err.value,<br>        sanitizedValue: err.sanitizedValue,<br>      })),<br>    });<br>    return;<br>  }<br>  next();<br>};</pre><h3>Step 3: Use Middleware in an Express App</h3><p>Modify server.ts to include the middleware:</p><pre>import express from &#39;express&#39;;<br>import { sanitizeMiddleware } from &#39;./sanitizeMiddleware&#39;;<br>const app = express();<br>app.use(express.json());<br>app.use(sanitizeMiddleware);<br>app.post(&#39;/submit&#39;, (req, res) =&gt; {<br>  res.json({ message: &#39;Data received successfully&#39;, data: req.body });<br>});<br>app.listen(3000, () =&gt; {<br>  console.log(&#39;Server running on http://localhost:3000&#39;);<br>});</pre><h3>Step 4: Testing the Middleware</h3><h4>Testing XSS Attack Prevention</h4><p>Send a request with malicious XSS payload:</p><pre>curl -X POST http://localhost:3000/submit -H &quot;Content-Type: application/json&quot; -d &#39;{&quot;comment&quot;: &quot;&lt;script&gt;alert(1)&lt;/script&gt;&quot;}&#39;</pre><p>✅ The request will be blocked, and a response like this will be returned:</p><pre>{<br>  &quot;error&quot;: &quot;Potential security risks detected&quot;,<br>  &quot;details&quot;: [<br>    {<br>      &quot;key&quot;: &quot;comment&quot;,<br>      &quot;type&quot;: &quot;XSS&quot;,<br>      &quot;originalValue&quot;: &quot;&lt;script&gt;alert(1)&lt;/script&gt;&quot;,<br>      &quot;sanitizedValue&quot;: &quot;alert(1)&quot;<br>    }<br>  ]<br>}</pre><h4>Testing SQL Injection Prevention</h4><p>Send a request with an SQL Injection payload:</p><pre>curl -X POST http://localhost:3000/submit -H &quot;Content-Type: application/json&quot; -d &#39;{&quot;username&quot;: &quot;admin&#39; OR &#39;1&#39;=&#39;1&quot;}&#39;</pre><p>✅ The request will be blocked with a similar error response.</p><h3>Conclusion</h3><p>This Express middleware helps protect your application from XSS and SQL Injection attacks by sanitizing user inputs before processing them. By implementing such security measures, you can safeguard your application against potential exploits and ensure secure data handling.</p><p>Would you like to see more security-related Express.js middleware? Let me know in the comments! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e19e94b78c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting Up App Icons and Splash Screens in Expo]]></title>
            <link>https://medium.com/@ravibelwal/setting-up-app-icons-and-splash-screens-in-expo-3aa60775e601?source=rss-9a971512e558------2</link>
            <guid isPermaLink="false">https://medium.com/p/3aa60775e601</guid>
            <category><![CDATA[syntax-sushi]]></category>
            <category><![CDATA[ravi-belwal]]></category>
            <category><![CDATA[the-syntax-sushi]]></category>
            <category><![CDATA[expo]]></category>
            <category><![CDATA[expo-icon-and-splash]]></category>
            <dc:creator><![CDATA[The Syntax Sushi]]></dc:creator>
            <pubDate>Sat, 01 Mar 2025 08:24:39 GMT</pubDate>
            <atom:updated>2025-03-01T08:24:39.287Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uvlfdr-KWC-FFfvhfWnnkA.png" /></figure><p>Customizing your app’s icon and splash screen is essential for branding and enhancing user experience. Expo provides straightforward methods to configure these elements.</p><h3>1. Preparing Your Assets</h3><p>Before configuring your app, ensure you have the appropriate assets:</p><h3>App Icon</h3><ul><li><strong>Dimensions</strong>: 1024x1024 pixels</li><li><strong>Format</strong>: PNG with a transparent background</li><li><strong>Design Tips</strong>:</li><li>Avoid intricate details; icons are displayed at small sizes.</li><li>Steer clear of text, as it may become unreadable.</li><li>Ensure the design is centered and utilizes the available space effectively.</li></ul><h3>Splash Screen</h3><ul><li><strong>Dimensions</strong>: At least 1200x1600 pixels</li><li><strong>Format</strong>: PNG</li><li><strong>Design Tips</strong>:</li><li>Use a solid background color that complements your app’s theme.</li><li>Center your logo or main image, ensuring it doesn’t touch the edges.</li><li>Maintain simplicity to provide a clean loading experience.</li></ul><h3>2. Configuring app.json or app.config.js</h3><p>Expo utilizes the app.json or app.config.js configuration file to define app settings, including icons and splash screens.</p><h3>Setting the App Icon</h3><p>Add the following within the expo object:</p><pre>&quot;expo&quot;: {<br>  &quot;icon&quot;: &quot;./assets/icon.png&quot;<br>}</pre><p>Ensure the path points to your icon file.</p><h3>Setting the Splash Screen</h3><p>Define the splash screen configuration:</p><pre>&quot;expo&quot;: {<br>  &quot;splash&quot;: {<br>    &quot;image&quot;: &quot;./assets/splash.png&quot;,<br>    &quot;resizeMode&quot;: &quot;contain&quot;,<br>    &quot;backgroundColor&quot;: &quot;#ffffff&quot;<br>  }<br>}</pre><ul><li><strong>image</strong>: Path to your splash screen image.</li><li><strong>resizeMode</strong>:</li><li>contain: Scales the image uniformly (maintaining aspect ratio) so that both dimensions (width and height) fit within the given area.</li><li>cover: Scales the image uniformly (maintaining aspect ratio) so that its shorter side fits exactly.</li><li><strong>backgroundColor</strong>: Hex color code for the splash screen background.</li></ul><p>For more detailed configurations, refer to the <a href="https://docs.expo.dev/develop/user-interface/splash-screen-and-app-icon/">Expo splash screen and app icon documentation</a>.</p><h3>3. Advanced Splash Screen Control</h3><p>To manage the splash screen’s visibility during app loading, you can use the expo-splash-screen library. This is particularly useful for tasks like pre-loading assets or making API calls before the main app screen appears.</p><h3>Installation</h3><p>Install the expo-splash-screen package:</p><pre>npx expo install expo-splash-screen</pre><h3>Usage Example</h3><p>In your main application file (e.g., App.js), implement the following:</p><pre>import { useEffect } from &#39;react&#39;;<br>import { View } from &#39;react-native&#39;;<br>import * as SplashScreen from &#39;expo-splash-screen&#39;;</pre><pre>export default function App() {<br>  useEffect(() =&gt; {<br>    async function prepare() {<br>      try {<br>        await SplashScreen.preventAutoHideAsync();<br>        await new Promise(resolve =&gt; setTimeout(resolve, 2000));<br>      } catch (e) {<br>        console.warn(e);<br>      } finally {<br>        await SplashScreen.hideAsync();<br>      }<br>    }<br>    prepare();<br>  }, []);</pre><pre>  return (<br>    &lt;View&gt;<br>      {/* Your app content */}<br>    &lt;/View&gt;<br>  );<br>}</pre><p>This setup ensures the splash screen remains visible until your app has finished loading necessary resources.</p><p>For comprehensive details, consult the <a href="https://docs.expo.dev/versions/latest/sdk/splash-screen/">Expo SplashScreen API documentation</a>.</p><h3>4. Testing Your Changes</h3><p>After configuring your app icon and splash screen:</p><ul><li><strong>Clear Cache</strong>: Run expo start --clear to ensure no cached assets interfere with your testing.</li><li><strong>Build the APK</strong>:</li><li>For classic builds:</li><li>expo build:android -t apk</li><li>For EAS builds:</li><li>eas build --platform android</li></ul><p>Test the generated APK on a physical device or emulator to verify the appearance of the icon and splash screen.</p><h3>5. Common Issues and Solutions</h3><h3>Icon Appears Blurry or Cropped</h3><ul><li><strong>Resolution</strong>: Ensure the icon is exactly 1024x1024 pixels.</li><li><strong>Format</strong>: Use a PNG file with a transparent background.</li><li><strong>Design</strong>: Avoid adding unnecessary padding around the icon.</li></ul><h3>Splash Screen Displays Incorrectly</h3><ul><li><strong>Background Color</strong>: Confirm that the backgroundColor in the splash configuration matches the design.</li><li><strong>Resize Mode</strong>: Choose the appropriate resizeMode (contain or cover) based on your image design.</li></ul><h3>Changes Not Reflecting</h3><ul><li><strong>Cache</strong>: Always clear the cache using expo start --clear after making asset changes.</li><li><strong>Build</strong>: Rebuild the app to ensure the new assets are included.</li></ul><h3>Conclusion</h3><p>Setting up a splash screen and app icon correctly ensures a polished and professional appearance. Following these best practices and Expo’s guidelines will help you avoid common pitfalls and improve the overall user experience. Let me know in the comments if you faced any issues or have additional tips!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3aa60775e601" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Choosing the Best File System for Storage Devices on macOS, Windows, and Android]]></title>
            <link>https://medium.com/@ravibelwal/choosing-the-best-file-system-for-storage-devices-on-macos-windows-and-android-8f308d676b44?source=rss-9a971512e558------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f308d676b44</guid>
            <dc:creator><![CDATA[The Syntax Sushi]]></dc:creator>
            <pubDate>Sun, 16 Feb 2025 10:48:24 GMT</pubDate>
            <atom:updated>2025-02-16T10:48:24.541Z</atom:updated>
            <content:encoded><![CDATA[<p>When formatting a storage device (USB drives, external hard drives, SSDs, SD cards), choosing the right file system is crucial to ensure compatibility across different devices. Whether you need it for macOS, Windows, Android, gaming consoles, or Linux, understanding the differences between various formats can save you from unexpected headaches. In this post, we’ll explore the most common file systems, their pros and cons, and which one is best for your needs.</p><h3>Understanding File Systems</h3><p>A file system determines how data is stored and retrieved on a storage device. Different operating systems support different file systems, which affects compatibility, performance, and file size limitations.</p><h3>Common File Formats for Storage Devices</h3><h3>1. APFS (Apple File System)</h3><p><strong>Best for:</strong> macOS-only use (Mac internal and external drives)</p><p><strong>Pros:</strong></p><ul><li>Optimized for modern macOS versions</li><li>Supports encryption and fast performance</li><li>Efficient space management with snapshots</li></ul><p><strong>Cons:</strong></p><ul><li>Not compatible with Windows or Android</li><li>Requires macOS High Sierra (10.13) or later</li></ul><h3>2. Mac OS Extended (HFS+)</h3><p><strong>Best for:</strong> Older macOS systems</p><p><strong>Pros:</strong></p><ul><li>Works well on macOS</li><li>Supports journaling for data integrity</li></ul><p><strong>Cons:</strong></p><ul><li>Not readable by Windows without third-party software</li><li>Slower compared to APFS on modern Macs</li></ul><h3>3. NTFS (New Technology File System)</h3><p><strong>Best for:</strong> Windows-only use (Internal/external HDDs, SSDs)</p><p><strong>Pros:</strong></p><ul><li>Supports large files and high performance</li><li>More secure with file permissions</li></ul><p><strong>Cons:</strong></p><ul><li>Read-only on macOS without additional software</li><li>Not natively supported by Android</li></ul><h3>4. FAT32 (File Allocation Table 32-bit)</h3><p><strong>Best for:</strong> Maximum compatibility (USB drives, SD cards, gaming consoles, smart TVs)</p><p><strong>Pros:</strong></p><ul><li>Works on almost any device (Windows, macOS, Linux, Android, cameras, gaming consoles, smart TVs)</li><li>No special software needed</li></ul><p><strong>Cons:</strong></p><ul><li><strong>4GB file size limit</strong></li><li>Less efficient storage management</li><li>Can be slower compared to exFAT and NTFS</li></ul><h3>5. exFAT (Extended File Allocation Table)</h3><p><strong>Best for:</strong> Cross-platform usage with large file support (Windows, macOS, Android, cameras, game consoles)</p><p><strong>Pros:</strong></p><ul><li>No <strong>4GB file size limit</strong> (unlike FAT32)</li><li>Works on <strong>macOS, Windows, Android, gaming consoles, cameras</strong></li><li>Fast and lightweight</li></ul><p><strong>Cons:</strong></p><ul><li>Not supported by very old devices</li><li>Lacks journaling (less data protection compared to NTFS or APFS)</li></ul><h3>6. ext4 (Fourth Extended File System)</h3><p><strong>Best for:</strong> Linux systems (HDDs, SSDs, SD cards)</p><p><strong>Pros:</strong></p><ul><li>High performance and reliability</li><li>Supports large files and partitions</li><li>Journaling for data protection</li></ul><p><strong>Cons:</strong></p><ul><li>Not natively supported by Windows or macOS</li><li>Requires third-party tools for access on non-Linux systems</li></ul><h3>7. ReFS (Resilient File System)</h3><p><strong>Best for:</strong> Windows Server and high-reliability storage (Enterprise HDDs, SSDs)</p><p><strong>Pros:</strong></p><ul><li>High resilience to corruption</li><li>Supports large volumes and files</li><li>Automatic data integrity checking</li></ul><p><strong>Cons:</strong></p><ul><li>Not supported on consumer editions of Windows</li><li>Not compatible with macOS or Android</li></ul><h3>8. XFS (Extended File System)</h3><p><strong>Best for:</strong> High-performance Linux systems (Enterprise storage, NAS devices)</p><p><strong>Pros:</strong></p><ul><li>Handles large files and high-speed I/O operations well</li><li>Journaling for data safety</li></ul><p><strong>Cons:</strong></p><ul><li>Not supported by Windows or macOS without extra software</li><li>Best suited for enterprise storage solutions</li></ul><h3>9. Btrfs (B-Tree File System)</h3><p><strong>Best for:</strong> Linux systems with advanced storage needs (RAID setups, NAS devices)</p><p><strong>Pros:</strong></p><ul><li>Supports snapshots and compression</li><li>Highly efficient storage management</li><li>Journaling for data integrity</li></ul><p><strong>Cons:</strong></p><ul><li>Limited support outside Linux</li><li>Complex compared to other file systems</li></ul><h3>Which File System Should You Use?</h3><p><strong>Use Case</strong> <strong>Recommended Format</strong> macOS only APFS or Mac OS Extended (HFS+) Windows only NTFS Mac + Windows exFAT Mac + Windows + Android exFAT Old devices (cameras, game consoles, etc.) FAT32 Large file transfers (4GB+) across platforms exFAT Linux only ext4, XFS, or Btrfs Windows Server ReFS High-speed Linux storage (NAS, RAID) XFS, Btrfs Smart TVs, cameras, gaming consoles FAT32, exFAT</p><h3>How to Format Your Storage Device</h3><h3>On macOS:</h3><ol><li>Open <strong>Disk Utility</strong> (Cmd + Space, type <strong>Disk Utility</strong>, press <strong>Enter</strong>).</li><li>Select your <strong>storage device</strong> from the left panel.</li><li>Click <strong>Erase</strong> (⚠️ This will delete all data on the drive!).</li><li>Choose the desired format (<strong>exFAT</strong> for best compatibility).</li><li>Click <strong>Erase</strong> and wait for the process to complete.</li></ol><h3>On Windows:</h3><ol><li>Plug in the storage device.</li><li>Open <strong>File Explorer</strong> &gt; Right-click on the storage device &gt; Click <strong>Format</strong>.</li><li>Select <strong>exFAT</strong> as the file system (or another format based on your needs).</li><li>Click <strong>Start</strong> to format the drive.</li></ol><h3>On Linux:</h3><ol><li>Open a terminal.</li><li>Use lsblk to find the device name.</li><li>Format using a command like:</li></ol><ul><li><strong>ext4</strong>: sudo mkfs.ext4 /dev/sdX</li><li><strong>XFS</strong>: sudo mkfs.xfs /dev/sdX</li><li><strong>Btrfs</strong>: sudo mkfs.btrfs /dev/sdX</li></ul><h3>Final Thoughts</h3><p>Choosing the right file format depends on your specific needs. If you want a drive that works seamlessly across <strong>macOS, Windows, and Android</strong>, <strong>exFAT</strong> is the best choice. For <strong>Mac-only use</strong>, stick with <strong>APFS</strong> or <strong>HFS+</strong>, while <strong>NTFS</strong> is ideal for <strong>Windows-only systems</strong>. If you need <strong>maximum compatibility</strong>, FAT32 is still an option, but beware of its file size limitations.</p><p>For Linux users, <strong>ext4, XFS, or Btrfs</strong> are good choices, while <strong>ReFS</strong> is best suited for Windows Server environments. If you’re formatting SD cards, game console storage, or cameras, <strong>FAT32 or exFAT</strong> are the best bets.</p><p>Now that you know which format to use, go ahead and format your storage device the right way! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f308d676b44" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering ~/.zshrc on macOS: A Developer's Guide]]></title>
            <link>https://medium.com/@ravibelwal/mastering-zshrc-on-macos-a-developers-guide-2b2c7e1e058a?source=rss-9a971512e558------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b2c7e1e058a</guid>
            <dc:creator><![CDATA[The Syntax Sushi]]></dc:creator>
            <pubDate>Sat, 15 Feb 2025 18:33:36 GMT</pubDate>
            <atom:updated>2025-02-15T18:44:43.060Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ieITn1g7exAt6ltT2GA-NA.jpeg" /></figure><p>If you’re a developer working with <strong>macOS</strong>, you’ve probably come across ~/.zshrc. But what exactly is it, and why should you care? In this guide, we’ll break down what ~/.zshrc is, why you need it, and how to customize it with real-world examples for developers.</p><h3>📌 What is ~/.zshrc?</h3><p>The ~/.zshrc file is a <strong>configuration file for the Z shell (Zsh)</strong>. It contains settings, environment variables, and customizations that load every time you start a new terminal session.</p><p><strong>🔹 Where is it located?</strong></p><pre>~/.zshrc</pre><p>(~ refers to your home directory, usually /Users/your-username/ on macOS.)</p><p><strong>🔹 Why does macOS use Zsh?</strong> As of <strong>macOS Catalina (10.15)</strong>, Apple switched the default shell from <strong>Bash to Zsh</strong> for security and feature improvements.</p><h3>💡 Why We Need ~/.zshrc?</h3><h3>1️⃣ Customizing the Terminal Experience</h3><ul><li>Set <strong>aliases</strong> for frequently used commands</li><li>Configure <strong>prompt appearance</strong></li><li>Enable <strong>syntax highlighting and auto-suggestions</strong></li></ul><h3>2️⃣ Managing Environment Variables</h3><ul><li>Set up <strong>PATH</strong> variables for tools like Node.js, Python, and Java</li><li>Configure API keys or other development-related variables</li></ul><h3>3️⃣ Enhancing Productivity</h3><ul><li>Enable <strong>autocompletion</strong> for tools like Git and Docker</li><li>Load <strong>custom scripts</strong> automatically</li><li>Integrate <strong>powerful plugins</strong> like zsh-autosuggestions and oh-my-zsh</li></ul><h3>⚙️ How to Use ~/.zshrc?</h3><h3>📝 Editing the File</h3><p>To open and edit your ~/.zshrc file, run:</p><pre>nano ~/.zshrc</pre><p>OR (if you prefer Visual Studio Code)</p><pre>code ~/.zshrc</pre><h3>🔄 Apply Changes Without Restarting</h3><p>After making changes, apply them immediately by running:</p><pre>source ~/.zshrc</pre><p>Otherwise, the changes will only take effect in new terminal sessions.</p><h3>🛠️ Examples</h3><h3>🔹 Example 1: Adding Useful Aliases</h3><p>Aliases allow you to create shortcuts for commands. For example:</p><pre># Shorten &#39;ls&#39; command with colors<br>alias ls=&#39;ls -G&#39;</pre><pre># Quickly navigate to projects folder<br>alias projects=&#39;cd ~/Developer/Projects&#39;</pre><pre># Start a local server instantly<br>alias serve=&#39;python3 -m http.server 8000&#39;</pre><h3>🔹 Example 2: Setting Up Node.js &amp; NVM</h3><p>If you use Node.js with <strong>NVM (Node Version Manager)</strong>, add this to ~/.zshrc:</p><pre>export NVM_DIR=&quot;$HOME/.nvm&quot;<br>[ -s &quot;/opt/homebrew/opt/nvm/nvm.sh&quot; ] &amp;&amp; \. &quot;/opt/homebrew/opt/nvm/nvm.sh&quot;<br>[ -s &quot;/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm&quot; ] &amp;&amp; \. &quot;/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm&quot;</pre><p>This ensures nvm loads every time you open a terminal.</p><h3>🔹 Example 3: Updating the PATH for Custom Tools</h3><p>If you have tools installed in a custom location, add them to your <strong>PATH</strong>:</p><pre>export PATH=&quot;$HOME/.local/bin:$PATH&quot;</pre><h3>🔹 Example 4: Enable Git Auto-Completion</h3><pre>autoload -Uz compinit &amp;&amp; compinit</pre><p>This helps with Git command suggestions while typing.</p><h3>🛠️ How to Update ~/.zshrc?</h3><h3>1️⃣ Open the file in a text editor</h3><pre>nano ~/.zshrc</pre><h3>2️⃣ Make your changes</h3><p>Add new aliases, export environment variables, or modify existing configurations.</p><h3>3️⃣ Save and Exit</h3><p>For <strong>nano</strong>:</p><ul><li>Press CTRL + X</li><li>Press Y to confirm changes</li><li>Press Enter</li></ul><h3>4️⃣ Apply changes</h3><pre>source ~/.zshrc</pre><h3>🔍 Troubleshooting Common Issues</h3><p><strong>🚨 Issue: Command Not Found After Editing </strong><strong>~/.zshrc</strong></p><ul><li>Ensure the changes are applied using:</li></ul><pre>source ~/.zshrc</pre><ul><li>source ~/.zshrc</li><li>Check if the <strong>PATH</strong> variable is correctly set:</li></ul><pre>echo $PATH</pre><p><strong>🚨 Issue: </strong><strong>zsh: permission denied</strong></p><ul><li>Run the following command to fix permissions:</li></ul><pre>chmod +x ~/.zshrc</pre><h3>🚀 Conclusion</h3><p>The ~/.zshrc file is <strong>a powerful tool for developers</strong>, enabling custom aliases, environment variable management, and workflow automation. By mastering ~/.zshrc, you can <strong>boost your productivity</strong> and streamline your development process.</p><p>Happy coding! 🎉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b2c7e1e058a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Use the Android Emulator Directly from the Command Line]]></title>
            <link>https://medium.com/@ravibelwal/use-the-android-emulator-directly-from-the-command-line-4ec6dbe110ac?source=rss-9a971512e558------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ec6dbe110ac</guid>
            <dc:creator><![CDATA[The Syntax Sushi]]></dc:creator>
            <pubDate>Sat, 15 Feb 2025 06:52:38 GMT</pubDate>
            <atom:updated>2025-02-15T06:52:38.644Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Cv6EnghmafsPAq2nnkDGA.jpeg" /></figure><p>If you’re an Android developer, you may want to run and manage the Android Emulator without opening Android Studio. This is useful for automation, testing, or working with lightweight setups. In this guide, we’ll explore how to use the Android Emulator directly from the command line.</p><h3>1. Locating the Emulator Tool</h3><p>The emulator command is part of the Android SDK and is located in the following directories by default:</p><ul><li><strong>Mac/Linux:</strong> ~/Library/Android/sdk/emulator</li><li><strong>Windows:</strong> C:\Users\&lt;YourUsername&gt;\AppData\Local\Android\Sdk\emulator</li></ul><p>To make it accessible from anywhere, add it to your PATH environment variable.</p><h3>For Mac/Linux:</h3><p>Edit the ~/.zshrc or ~/.bashrc file:</p><pre>export PATH=$PATH:$HOME/Library/Android/sdk/emulator<br>export PATH=$PATH:$HOME/Library/Android/sdk/platform-tools</pre><p>Apply the changes:</p><pre>source ~/.zshrc   # or source ~/.bashrc</pre><h3>For Windows (PowerShell or Git Bash):</h3><p>Add the following to your system environment variables:</p><pre>C:\Users\&lt;YourUsername&gt;\AppData\Local\Android\Sdk\emulator<br>C:\Users\&lt;YourUsername&gt;\AppData\Local\Android\Sdk\platform-tools</pre><p>Restart your terminal after making these changes.</p><h3>2. Listing Available Emulators</h3><p>To see the list of installed Android Virtual Devices (AVDs), run:</p><pre>emulator -list-avds</pre><p>Example output:</p><pre>Pixel_4_API_30<br>Pixel_6_Pro_API_33</pre><h3>3. Starting an Emulator</h3><p>To start a specific emulator, use:</p><pre>emulator -avd &lt;AVD_NAME&gt;</pre><p>Example:</p><pre>emulator -avd Pixel_4_API_30</pre><h3>Run Emulator Without GUI (Headless Mode):</h3><pre>emulator -avd &lt;AVD_NAME&gt; -no-window</pre><h3>Start Emulator with Quick Boot (Faster Startup):</h3><pre>emulator -avd &lt;AVD_NAME&gt; -quick-boot</pre><h3>Disable Boot Animation (Speed Up Startup Time):</h3><pre>emulator -avd &lt;AVD_NAME&gt; -no-boot-anim</pre><h3>4. Installing an APK on the Emulator</h3><p>Once the emulator is running, install an APK using ADB (Android Debug Bridge):</p><pre>adb install my_app.apk</pre><p>Verify that the device is connected with:</p><pre>adb devices</pre><p>Example output:</p><pre>List of devices attached<br>emulator-5554   device</pre><h3>5. Stopping the Emulator</h3><p>To close the emulator from the command line:</p><pre>adb emu kill</pre><h3>6. Bonus: Creating a New Emulator from CLI</h3><p>You can create a new AVD directly from the command line:</p><pre>avdmanager create avd -n MyNewAVD -k &quot;system-images;android-30;google_apis;x86_64&quot; --device &quot;pixel_4&quot;</pre><p>Then start it using:</p><pre>emulator -avd MyNewAVD</pre><h3>Conclusion</h3><p>Using the Android Emulator from the command line provides more control and flexibility for testing and automation. Whether you want to speed up your workflow, integrate with CI/CD pipelines, or simply avoid opening Android Studio, these commands will help you manage your virtual devices efficiently.</p><p>Let me know in the comments if you have any questions! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ec6dbe110ac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jailbreaking: What It Is and How to Prevent It in Your React Native & Node.js App]]></title>
            <link>https://medium.com/@ravibelwal/jailbreaking-what-it-is-and-how-to-prevent-it-in-your-react-native-node-js-app-2f4ceac3193e?source=rss-9a971512e558------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f4ceac3193e</guid>
            <category><![CDATA[jailbreaking]]></category>
            <category><![CDATA[jain-break-react-native]]></category>
            <category><![CDATA[jailbreak-ios-11]]></category>
            <category><![CDATA[jailbreak-react-native]]></category>
            <category><![CDATA[jailbreak-in-nodejs]]></category>
            <dc:creator><![CDATA[The Syntax Sushi]]></dc:creator>
            <pubDate>Tue, 04 Feb 2025 05:01:42 GMT</pubDate>
            <atom:updated>2025-02-04T05:04:06.211Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6HkfZgNgHHr8qRcm0vPtqQ.jpeg" /></figure><p><strong>Ever wondered how attackers can bypass security and exploit mobile apps? Jailbreaking is a major risk, and if your app isn’t protected, you might be in trouble!</strong></p><p>In today’s world of mobile security, jailbreaking is one of the most common ways hackers gain control over an app. If you’re building a React Native app with a Node.js backend, understanding jailbreak threats and how to prevent them is crucial. So, let’s break it down in simple terms.</p><h3>What is Jailbreaking?</h3><p>A jailbroken (iOS) or rooted (Android) device gives users full control over the operating system, bypassing built-in security restrictions. This might sound great for customization, but it also allows attackers to:</p><ul><li>Modify your app’s behavior.</li><li>Bypass security mechanisms like SSL Pinning.</li><li>Extract sensitive data such as API keys or tokens.</li><li>Install malicious apps to spy on users.</li></ul><p>For developers, this means your app could be running in an <strong>untrusted</strong> environment where attackers can manipulate it as they please. That’s a serious problem, especially if your app handles sensitive user data!</p><h3>How Jailbreak Threats Affect Your App</h3><p>Let’s say you’ve built a <strong>React Native app</strong> that interacts with a <strong>Node.js API</strong>. If a user is running a jailbroken device, they could:</p><ul><li><strong>Intercept API requests</strong> using tools like <strong>Frida</strong> or <strong>Burp Suite</strong>.</li><li><strong>Modify your app’s code</strong> to bypass authentication or gain access to restricted features.</li><li><strong>Steal access tokens</strong> and impersonate users on other devices.</li></ul><p>Imagine running a <strong>banking app</strong> on a jailbroken phone — hackers could steal credentials, extract financial data, and cause major security breaches!</p><h3>How to Detect &amp; Prevent Jailbreaking in React Native</h3><h3>1. Detect Jailbroken or Rooted Devices</h3><p>The first step in securing your React Native app is <strong>detecting if the device is jailbroken</strong>. You can use the react-native-device-info library to check for jailbreak status.</p><h4>Install the package:</h4><pre>npm install react-native-device-info</pre><h4>Implement Jailbreak Detection:</h4><pre>import DeviceInfo from &#39;react-native-device-info&#39;;</pre><pre>const isJailBroken = DeviceInfo.isJailBroken();</pre><pre>if (isJailBroken) {<br>  console.warn(&quot;Jailbroken device detected!&quot;);<br>  // Optionally exit the app<br>  // BackHandler.exitApp();<br>}</pre><p>This will return true if the app is running on a compromised device. You can then take actions like blocking access or displaying a warning.</p><h3>2. Prevent Debugging &amp; Code Injection</h3><p>Hackers use debugging tools like Frida to manipulate your app at runtime. To make this harder:</p><ul><li><strong>Obfuscate your JavaScript code</strong> using metro-config.</li><li><strong>Use secure storage</strong> instead of AsyncStorage for sensitive data.</li><li><strong>Disable debugging and logging in production.</strong></li></ul><h4>Example: Disable debug logs in production</h4><pre>if (!__DEV__) {<br>  console.log = () =&gt; {};<br>  console.warn = () =&gt; {};<br>  console.error = () =&gt; {};<br>}</pre><p>This prevents attackers from gaining insights through console logs.</p><h3>3. Implement SSL Pinning to Prevent API Interception</h3><p>If a hacker is using a jailbroken device, they might intercept API traffic and extract sensitive data. <strong>SSL Pinning</strong> ensures that your app only trusts a specific certificate.</p><h4>Use react-native-ssl-pinning:</h4><pre>npm install react-native-ssl-pinning</pre><pre>import {fetch} from &#39;react-native-ssl-pinning&#39;;</pre><pre>fetch(&quot;https://yourapi.com&quot;, {<br>  method: &quot;GET&quot;,<br>  sslPinning: {<br>    certs: [&quot;your_cert&quot;]<br>  }<br>})<br>.then(response =&gt; response.json())<br>.catch(error =&gt; console.error(&quot;SSL Pinning Failed&quot;, error));</pre><p>This ensures attackers cannot use custom certificates to intercept API traffic.</p><h3>How to Secure Your Node.js Backend from Jailbroken Clients</h3><p>A jailbroken device might send <strong>malicious API requests</strong> to your backend. Here’s how to <strong>protect your Node.js API</strong>:</p><h3>1. Block Requests from Jailbroken Devices</h3><p>When your app detects a jailbreak, send a flag to the backend and reject requests:</p><pre>app.use((req, res, next) =&gt; {<br>  if (req.headers[&quot;x-jailbreak&quot;] === &quot;true&quot;) {<br>    return res.status(403).json({ error: &quot;Jailbroken devices are not allowed.&quot; });<br>  }<br>  next();<br>});</pre><h3>2. Use Token Expiry &amp; Device Binding</h3><p>Link access tokens to a specific device ID to prevent stolen tokens from being reused:</p><pre>const tokenStore = new Map();</pre><pre>function generateToken(userId, deviceId) {<br>  const token = crypto.randomBytes(32).toString(&quot;hex&quot;);<br>  tokenStore.set(token, { userId, deviceId, expires: Date.now() + 3600000 });<br>  return token;<br>}</pre><pre>function verifyToken(token, deviceId) {<br>  const data = tokenStore.get(token);<br>  if (!data || data.deviceId !== deviceId || data.expires &lt; Date.now()) {<br>    throw new Error(&quot;Invalid or expired token&quot;);<br>  }<br>  return data.userId;<br>}</pre><p>This ensures tokens cannot be used on another device.</p><h3>Can Jailbreaking Be Completely Prevented?</h3><p>Not 100%, but you can <strong>make it extremely difficult</strong> for hackers by:</p><ul><li><strong>Detecting jailbreak/root access and blocking access.</strong></li><li><a href="https://medium.com/@ravibelwal/securing-your-react-native-node-js-app-with-ssl-pinning-f3a6c612c00b"><strong>Using SSL Pinning to prevent API interception.</strong></a><strong> 🔗</strong></li><li><strong>Disabling debugging tools and obfuscating code.</strong></li><li><strong>Implementing backend validation to reject malicious requests.</strong></li></ul><p>By following these steps, you can <strong>protect your React Native app and Node.js backend from jailbroken threats</strong> and keep your users’ data safe. 💪🔐</p><h3>Final Thoughts</h3><p>Jailbreaking is a major security risk, but with the right precautions, you can <strong>minimize the damage hackers can do</strong>. Security is an ongoing battle — <strong>stay proactive, test frequently, and always assume attackers are looking for a way in.</strong> 🚀</p><p><strong>Have thoughts on mobile security? Let’s discuss in the comments!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f4ceac3193e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Securing Your React Native & Node.js App With SSL Pinning]]></title>
            <link>https://medium.com/@ravibelwal/securing-your-react-native-node-js-app-with-ssl-pinning-f3a6c612c00b?source=rss-9a971512e558------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3a6c612c00b</guid>
            <category><![CDATA[react-native-ssl-pinning]]></category>
            <category><![CDATA[ssl-pinning-in-node]]></category>
            <category><![CDATA[ssl-pinning]]></category>
            <category><![CDATA[ssl-pinning-in-react]]></category>
            <dc:creator><![CDATA[The Syntax Sushi]]></dc:creator>
            <pubDate>Mon, 03 Feb 2025 17:55:41 GMT</pubDate>
            <atom:updated>2025-02-15T06:59:11.161Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JbPMt2LkQ0g3KH_t9q9Ggg.jpeg" /></figure><p><strong>Ever heard of hackers intercepting your app’s network traffic? SSL Pinning is your first line of defense!</strong></p><p>In today’s world, where cybersecurity threats are more real than ever, securing your app’s network communication is crucial. Imagine you’re building a React Native app that communicates with your backend API in Node.js. You trust HTTPS to secure the connection, but what if an attacker sneaks in using a fake certificate? That’s where <strong>SSL Pinning</strong> comes in.</p><h3>What is SSL Pinning &amp; Why Should You Care?</h3><p>By default, your app trusts any certificate issued by a Certificate Authority (CA). This means if an attacker tricks your device into accepting a malicious certificate, they can intercept your API requests — a classic <strong>Man-in-the-Middle (MITM) attack</strong>.</p><p><strong>SSL Pinning fixes this by forcing your app to trust only a specific certificate or public key.</strong> Even if a hacker tries to use a valid-looking certificate, your app will reject it.</p><h3>How SSL Pinning Works</h3><p>Here’s the simple breakdown:</p><ol><li>Your app downloads the server’s SSL certificate during the first request.</li><li>Instead of blindly trusting any CA-signed certificate, your app compares it to a predefined (“pinned”) certificate or public key.</li><li>If it doesn’t match, the connection is <strong>rejected.</strong></li></ol><h3>Types of SSL Pinning</h3><h3>1. Certificate Pinning</h3><p>You pin the <strong>entire SSL certificate.</strong> If the certificate changes (like after expiry), you need to update your app.</p><p>✅ More secure, but requires frequent updates.</p><h3>2. Public Key Pinning</h3><p>You extract and pin the <strong>public key</strong> of the certificate. As long as the key remains unchanged, you won’t need frequent updates.</p><p>✅ More flexible and preferred for most cases.</p><h3>Implementing SSL Pinning in React Native (Expo &amp; Non-Expo)</h3><p>Let’s implement SSL Pinning in a React Native app using react-native-ssl-pinning (for non-Expo) or fetch for Expo projects.</p><h3>For React Native (Non-Expo)</h3><p>Install react-native-ssl-pinning:</p><pre>npm install react-native-ssl-pinning</pre><p>Then, configure it in your API request:</p><pre>import {fetch} from &#39;react-native-ssl-pinning&#39;;</pre><pre>fetch(&quot;https://yourapi.com&quot;, {<br>  method: &quot;GET&quot;,<br>  sslPinning: {<br>    certs: [&quot;your_cert&quot;]  // Store your .cer file in the project<br>  }<br>})<br>.then(response =&gt; response.json())<br>.then(data =&gt; console.log(data))<br>.catch(error =&gt; console.error(&quot;SSL Pinning Error:&quot;, error));</pre><h3>For React Native (Expo Project)</h3><p>Expo doesn’t support native SSL pinning libraries, but you can manually verify the certificate fingerprint using fetch:</p><pre>fetch(&quot;https://yourapi.com&quot;).then(response =&gt; {<br>  const certFingerprint = response.headers.get(&quot;Public-Key-Pins&quot;);<br>  const trustedFingerprint = &quot;sha256/AAAAAAAAAAAAAAAAAAAAAAAAAAAAA=&quot;;<br>  if (certFingerprint !== trustedFingerprint) {<br>    throw new Error(&quot;SSL Pinning Failed&quot;);<br>  }<br>  return response.json();<br>}).then(data =&gt; console.log(data))<br>.catch(error =&gt; console.error(&quot;SSL Pinning Error:&quot;, error));</pre><h3>Implementing SSL Pinning in Node.js</h3><p>For a Node.js backend, you can use the https module and specify the trusted certificate:</p><pre>const https = require(&quot;https&quot;);<br>const fs = require(&quot;fs&quot;);</pre><pre>const options = {<br>  hostname: &quot;yourapi.com&quot;,<br>  port: 443,<br>  method: &quot;GET&quot;,<br>  ca: fs.readFileSync(&quot;your_cert.pem&quot;)<br>};</pre><pre>const req = https.request(options, (res) =&gt; {<br>  console.log(`Status Code: ${res.statusCode}`);<br>});<br>req.end();</pre><h3>Can SSL Pinning Be Bypassed?</h3><p>Yes, attackers can use tools like <strong>Frida</strong> or <strong>Xposed</strong> to bypass SSL pinning. Some ways to make it harder:</p><ul><li><strong>Code Obfuscation</strong>: Makes it difficult to hook into your app.</li><li><strong>Runtime Checks</strong>: Detect if debugging tools are being used.</li><li><strong>Multiple Pinning Methods</strong>: Pin both certificates and public keys.</li></ul><h3>When Should You Use SSL Pinning?</h3><ul><li>If your app deals with <strong>sensitive data</strong> (e.g., banking, healthcare).</li><li>If you need <strong>stronger protection</strong> against MITM attacks.</li><li>If you are handling <strong>authentication tokens</strong> or API keys.</li></ul><h3>Final Thoughts</h3><p>SSL Pinning is a powerful security measure, but <strong>it’s not a silver bullet</strong>. Combine it with <strong>other security best practices</strong> like proper authentication and encryption. If you’re serious about securing your React Native app and Node.js backend, implementing SSL Pinning is a must.</p><p>Want to discuss more security practices? Drop a comment below! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3a6c612c00b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>