<?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 Tareq Aziz on Medium]]></title>
        <description><![CDATA[Stories by Tareq Aziz on Medium]]></description>
        <link>https://medium.com/@tareqaziz0065?source=rss-6f94fe1f9c46------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*oxBB1q4U-RauSJPMiPQ9gg.jpeg</url>
            <title>Stories by Tareq Aziz on Medium</title>
            <link>https://medium.com/@tareqaziz0065?source=rss-6f94fe1f9c46------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 13:18:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tareqaziz0065/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[Why I Spent the Last 6 Months Rebuilding the Desktop Video Editor from Scratch]]></title>
            <link>https://medium.com/@tareqaziz0065/why-i-spent-the-last-6-months-rebuilding-the-desktop-video-editor-from-scratch-b5372c4e23c7?source=rss-6f94fe1f9c46------2</link>
            <guid isPermaLink="false">https://medium.com/p/b5372c4e23c7</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[startup]]></category>
            <dc:creator><![CDATA[Tareq Aziz]]></dc:creator>
            <pubDate>Wed, 09 Sep 2026 20:44:20 GMT</pubDate>
            <atom:updated>2026-09-09T20:44:20.321Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OEXnXCYcmSVm3wdXLC2Llg.png" /></figure><h4>Modern video creation shouldn’t feel like wrestling software from 2004. Here is what happens when you design an editor around modern workflows, local-first performance, and creator flow state.</h4><p>Every video editor has experienced that specific moment of dread.</p><p>You have six browser tabs open downloading B-roll. Your timeline is lagging because of two nested adjustment layers. You’ve spent twenty minutes manually syncing subtitle timing, and Premiere or DaVinci just decided to freeze on a clip you forgot to transcode.</p><p>The video landscape has undergone a massive shift over the past five years. Creators today aren’t just cutting 16:9 broadcast footage; they are building vertical content for TikTok, Shorts, and Reels, designing dynamic caption animations, experimenting with aggressive color grades, and juggling thousands of stock assets on tight turnaround schedules.</p><p>Yet, most desktop video editors are still burdened by decades of legacy code, clunky licensing, and fragmented workflows that force you out of your editor and into browser tabs dozens of times per video.</p><p>Over the past six months, I set out to build a modern, high-performance desktop video editor engineered from the ground up for modern creators.</p><p>Here is a deep dive into the architecture, the features we’ve built, and why we’re taking a completely different approach before opening up public access.</p><h3>The Core Philosophy: Eliminating “Flow State Friction”</h3><p>When you study how creators actually spend their time editing, the biggest productivity drain is rarely rendering speed — it’s <strong>context switching</strong>.</p><p>Every time you leave your editor to find stock footage, transcode an audio file, generate AI captions on a web tool, or convert aspect ratios, you break your cognitive momentum.</p><p>Our upcoming editor is built around four guiding principles:</p><ol><li><strong>Zero-Tab Workflow:</strong> Stock assets, caption generation, masking, and color LUTs exist directly inside the native interface.</li><li><strong>Local-First &amp; Private:</strong> Your media never leaves your hardware. Rendering, audio processing, and caching happen natively on your machine without mandatory cloud subscriptions or surveillance.</li><li><strong>Sub-Pixel Parity:</strong> What you scrub on the canvas at 60 FPS is mathematically identical to the rendered MP4 export.</li><li><strong>Lightweight &amp; Instant:</strong> No 15-minute software installs or 10GB bloated background services.</li></ol><h3>A Tour of the Core Features:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DdUClZh2JoZL4pjbPk2-iQ.png" /><figcaption>In-App Royalty-Free Stock Media (Pixabay Powered)</figcaption></figure><h3>1. In-App Royalty-Free Stock Media (Pixabay Powered)</h3><p>Instead of jumping back and forth between Chrome and your editor, we built a native stock library directly into the media bin.</p><ul><li><strong>Millions of Assets at Your Fingertips:</strong> Instant, real-time search across 4K/HD footage, photography, vector illustrations, and SFX.</li><li><strong>Smart Aspect-Ratio Snapping:</strong> Pixabay’s raw API does not natively categorize vertical videos. We built client-side stream metadata inspection that automatically isolates true <strong>9:16 vertical video</strong> for mobile content or <strong>16:9 widescreen</strong> for cinema and YouTube.</li><li><strong>Color Palette &amp; Filter Matching:</strong> Looking for a mood? Filter stock footage by dominant color tone (amber sunset, cyberpunk cyan, moody monochrome) to seamlessly match your project’s color grade.</li><li><strong>Background Local Caching:</strong> When you drag stock footage to the timeline, it immediately caches locally, meaning zero streaming buffering or dropped playback frames.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*17VXbjr_Om3WfzwM7LbN9w.png" /><figcaption>Trendy Captions Studio with Word-by-Word Karaoke</figcaption></figure><h3>2. Trendy Captions Studio with Word-by-Word Karaoke</h3><p>Captions have become non-negotiable for short-form retention. Traditionally, creators had to export to CapCut or third-party web tools just to get animated subtitle highlights.</p><ul><li><strong>High-Accuracy Speech-to-Text:</strong> Local and cloud-assisted voice recognition that parses your audio in seconds.</li><li><strong>Viral Preset Animations:</strong> Pre-tuned typography and motion graphics inspired by top creators (Hormozi-style energetic pops, MrBeast high-contrast punchlines, minimalist aesthetic lower-thirds).</li><li><strong>Word-by-Word Active Karaoke:</strong> Granular timestamp strips allow you to customize highlighted colors, fonts, stroke outlines, and scale bounces word-by-word with live preview.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5hWhn56abR9XK3moI-nUjQ.png" /><figcaption>Studio Power Window Masks &amp; Bezier Pen Tool</figcaption></figure><h3>3. Studio Power Window Masks &amp; Bezier Pen Tool</h3><p>Colorists love DaVinci Resolve’s Power Windows, but typical timeline editors offer primitive or cumbersome crop tools. We built a dedicated geometric and polygon masking engine directly into the canvas:</p><ul><li><strong>Multi-Layer Masking:</strong> Combine Box, Ellipse, Linear Gradient, and custom Bezier Pen paths on any video or image track.</li><li><strong>Studio Relighting &amp; Power Presets:</strong> Transform flat footage with volumetric spotlight beams, golden hour lens flares, cyberpunk rim lighting, and vignette darkeners.</li><li><strong>Interactive Canvas Controls:</strong> Rotate, scale, adjust feather boundaries, and toggle between <em>Normal (Inside)</em> and <em>Inverted (Outside)</em> with instant visual feedback.</li></ul><h3>4. Real-Time Hover Quick Previews</h3><p>Why should you have to drag an effect onto your clip and wait for rendering just to see how it looks?</p><ul><li><strong>Instant Canvas Mirroring:</strong> Hovering over any filter, cinematic LUT, or transition instantly renders a live preview of that effect directly over your current frame.</li><li><strong>Zero Commit Stress:</strong> Move your cursor across 20 film looks in 5 seconds to find the exact aesthetic you need before applying it.</li></ul><h3>5. High-Precision Keyframing &amp; Unified Motion Engine</h3><p>A common complaint in modern web-based and lightweight editors is timing drift: the preview looks smooth, but the exported video drops frames or misses keyframe curves.</p><ul><li><strong>Remotion + WebCodecs Architecture:</strong> We unified the canvas preview engine with the export pipeline. Easing curves, sub-pixel transform coordinates, and rotational momentum calculate identically on the playback head as they do during hardware-accelerated MP4 rendering.</li><li><strong>Timeline Runway:</strong> Infinite forward timeline runway expansion eliminates track cutoffs, ghost lags, and snapping stutter.</li></ul><h3>Why We Haven’t “Just Launched” Yet</h3><p>We could have published a rough MVP weeks ago. But editors are personal, critical pieces of software. When you sit down to edit a project, you need to trust that the software won’t crash mid-render, corrupt your timeline, or hijack your project files with proprietary locks.</p><p>Before opening the doors publicly, we are conducting a focused, closed alpha with real creators, YouTube producers, and indie filmmakers.</p><p>We want to battle-test:</p><ul><li>Multi-track heavy timeline stress under 4K 60fps video workloads.</li><li>Edge-case codec handling across different camera formats.</li><li>Workflow polish and keyboard shortcut ergonomics.</li></ul><h3>Join the Closed Beta &amp; Shape the Future of Editing</h3><p>If you are a video creator, YouTuber, TikToker, or editor who is tired of clunky legacy software and wants a blazing-fast, privacy-first editor built for today’s content, we want your input.</p><p>We are accepting our first batch of private beta testers:</p><p><strong>Get Early Access:</strong> Drop your email on comment section.</p><p>We’re building the tool we always wished existed. Let’s make video editing fun and frictionless again.</p><p><em>What is the single biggest bottleneck in your current video editing workflow? Drop a comment below — we’d love to talk architecture, workflow, and features.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b5372c4e23c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why I Re-Engineered My Admin Panel Engine into an Event-Driven Powerhouse]]></title>
            <link>https://medium.com/@tareqaziz0065/why-i-re-engineered-my-admin-panel-engine-into-an-event-driven-powerhouse-7266fef2def8?source=rss-6f94fe1f9c46------2</link>
            <guid isPermaLink="false">https://medium.com/p/7266fef2def8</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[mern-stack]]></category>
            <category><![CDATA[nextmin]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Tareq Aziz]]></dc:creator>
            <pubDate>Mon, 08 Jun 2026 07:26:44 GMT</pubDate>
            <atom:updated>2026-06-08T07:26:44.800Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yo5b24xt0-w_5AyIB_xANQ.png" /></figure><p>Every developer has a list of tasks they absolutely dread. For me, it’s building the exact same boilerplate CRUD interface and custom admin panel for every single new Node.js and React project.</p><p>You know the drill: set up authentication, build the tables, handle the API routes, wire up form validations, and inevitably figure out how to add a rich text editor. It’s a repetitive time-sink.</p><p>A while back, I decided I’d had enough. I built <strong>NextMin</strong> to automate that headache away. But as production applications scale, simple “passive CRUD” starts to break down. You quickly realize you don’t just need tables; you need event hooks, real-time sync, and intelligent caching layer optimizations to survive high traffic.</p><p>That is why I spent the last few months completely tearing down and rebuilding the core architecture. Today, I’m incredibly excited to share <strong>NextMin 2.0</strong> — which transforms the traditional admin panel into a high-performance, event-driven engine.</p><p>Here is a look under the hood at what changed, why I made these architectural decisions, and how it makes building internal tools significantly faster.</p><h3>1. The Unified Data Layer (NMAdapter)</h3><p>One of the biggest hurdles when building reusable internal tools is database lock-in. If your tool only works for MongoDB, SQL developers are left out.</p><p>For 2.0, I rewrote the entire data abstraction layer. Whether your project relies on SQL or MongoDB, the internal API and schema definitions remain completely identical. The core router doesn’t care what your database dialect is anymore; the unified adapter translates everything seamlessly behind the scenes.</p><h3>2. Moving From Passive UI to Event-Driven Lifecycles</h3><p>When an admin changes data in a dashboard, you rarely <em>just</em> want to update the database. You usually need to trigger a webhook, fire a welcome email, clear a cache, or run custom data validation.</p><p>Instead of forcing developers to hack the core routing or write custom controllers, NextMin 2.0 introduces a strict event-driven system. You can now effortlessly tap into before or after lifecycle hooks for any CRUD operation:</p><p>JavaScript</p><pre>// Example: Easily execute custom business logic right in your lifecycle<br>nextMin.on(&#39;afterUpdate&#39;, (data) =&gt; {<br>  triggerExternalWebhook(data);<br>});</pre><h3>3. Native Real-Time Sync (Goodbye, WebSocket Boilerplate)</h3><p>If multiple team members are managing data simultaneously, stale dashboards are a recipe for data corruption. Instead of forcing you to write custom socket infrastructure, real-time synchronization is now baked directly into NextMin’s core router. Updates propagate instantly across connected clients out of the box.</p><h3>4. Intelligent Caching Layer via keyv</h3><p>Database latency can kill dashboard performance, especially when reading repetitive configuration tables or heavy data sets. We integrated keyv to handle abstract caching natively.</p><ul><li>Running a small app or standard dev build? It defaults to lightning-fast <strong>In-memory caching</strong>.</li><li>Scaling a production microservice architecture? Switch it over to <strong>Redis</strong> with a single config line.</li></ul><h3>5. Rich Text Editing with Just One Line of Code</h3><p>Rich content editing shouldn’t require installing five different npm packages and styling them from scratch. We natively integrated the Tiptap editor into the schema engine. Now, if you want a premium, robust rich text experience on a field, you just add a single property to your schema:</p><p>JSON</p><pre>&quot;content&quot;: {<br>  &quot;type&quot;: &quot;String&quot;,<br>  &quot;rich&quot;: true<br>}</pre><h3>Give it a spin 🚀</h3><p>NextMin 2.0 is fully open, live, and ready for your next project. I’ve refreshed the entire documentation suite, including a comprehensive migration guide if you were using the earlier builds.</p><p>👉 <strong>Check out the live docs and examples:</strong> <a href="https://nextmin.gscodes.dev/">nextmin.gscodes.dev</a></p><h3>Over to You: Let’s Chat! 💬</h3><p>Building this architecture taught me a lot about the fine line between making a tool “configurable” versus making it “flexible.”</p><ul><li>How do you currently tackle the internal tools bottleneck in your own engineering stack?</li><li>Do you prefer UI-first drag-and-drop builders (like Retool), or code-first backend engines like NextMin?</li></ul><p><strong>I’d love to hear your thoughts, critiques, or feature requests in the comments below!</strong></p><p><em>If you found this breakdown insightful and want to follow along with my journey of building and scaling developer tools, hit that </em><strong><em>Follow</em></strong><em> button! I’ll be sharing deep dives into performance tuning and node microservices regularly.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7266fef2def8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rethinking SSH Security: Why Persistent Daemons Are a Threat to Your Local]]></title>
            <link>https://medium.com/@tareqaziz0065/rethinking-ssh-security-why-persistent-daemons-are-a-threat-to-your-local-68c6f6c97fbd?source=rss-6f94fe1f9c46------2</link>
            <guid isPermaLink="false">https://medium.com/p/68c6f6c97fbd</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[secure-ssh]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[free-ssh]]></category>
            <dc:creator><![CDATA[Tareq Aziz]]></dc:creator>
            <pubDate>Fri, 05 Jun 2026 06:56:21 GMT</pubDate>
            <atom:updated>2026-06-05T06:56:21.931Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zKCsZNjG6MgaG1SkjjMQhQ.png" /></figure><h3>Introduction: The Coffee Shop Dilemma</h3><p>Picture this: You’re at your favorite local coffee shop, working on your latest project. Your development machine is connected to the public Wi-Fi. You needed to transfer a few build assets or config files from your test bench or handheld Linux device earlier this morning, so you ran sudo systemctl start sshd.</p><p>Then, you forgot about it.</p><p>While you are focused on debugging your React state or optimizing database indexes, a malicious actor on the same public network is actively scanning for open ports. Port 22 is wide open. If you have password authentication enabled, or if your private configuration has even the slightest vulnerability, your entire environment is compromised.</p><p>As developers, we build incredible systems, but we are often guilty of trading configuration convenience for security. Why do we keep SSH daemons running persistently when we only need them for a 3-minute file transfer?</p><p>This is exactly why I built <strong>SSH Deck (</strong><a href="https://sshdeck.gscodes.dev/">sshdeck.gscodes.dev</a><strong>)</strong>.</p><h3>The Problem: The Danger of Persistent SSH Daemons</h3><p>For years, the standard approach to remote device management and file synchronization has been setting up a permanent SSH server. We tell ourselves:</p><ul><li><em>“It’s fine, I’m behind a NAT.”</em></li><li><em>“No one can find my device on a local subnet.”</em></li><li><em>“I have a strong password.”</em></li></ul><p>But developer mobility has broken the traditional perimeter defense model. When your local environment shifts between your home office, public transit, and client networks, a persistent background daemon transitions from a harmless utility into an active threat vector. Furthermore, managing complex cryptographic configurations (key rotations, disabling password auth entirely, setting up custom firewall ports) can feel like unnecessary overhead for a quick, routine local file sync.</p><h3>The Solution: Enter SSH Deck</h3><p><strong>SSH Deck</strong> reimagines local SSH interaction by replacing the permanent background daemon with an <strong>ephemeral, session-based workflow</strong>.</p><p>Instead of configuring a service that boots with your system and constantly polls network interfaces, SSH Deck serves as an interactive “on-demand” switch.</p><h4>How it Works Under the Hood</h4><ol><li><strong>Zero-Persistence Execution:</strong> When launched, SSH Deck initializes the SSH environment and spins up a temporary daemon instance.</li><li><strong>Visual Session State:</strong> A lightweight, persistent UI window or prompt is opened for the developer. As long as this window is visible, your SSH port is active, displaying your temporary connection strings and credentials.</li><li><strong>Instant Attack Surface Destruction:</strong> The exact moment you close the application popup, or your device triggers a sleep cycle, the underlying bash runtime cleanly traps the exit code, kills the specific PID associated with the daemon, and shuts down the connection.</li></ol><h3>Architecting for Developer Safety: Sandboxing the Environment</h3><p>When designing SSH Deck, my absolute highest priority was <strong>developer safety</strong>. It isn’t enough to just turn the connection off when you’re done; the environment must be safe <em>while</em> the connection is active.</p><h4>1. Isolated User Scoping</h4><p>Traditional SSH setups dump the incoming connection directly into your root or default user home directory (/home/user). If a malicious script maps to that connection, your source code, configuration .env files, and cloud provider API tokens are fully exposed.</p><p>SSH Deck is engineered to mitigate this through isolated scoped routing. By generating or targeting specific unprivileged system profiles (such as restricted sdcard paths or specific /run/media/ contexts), the incoming SFTP or SSH stream is strictly bound to the target assets you intended to transfer—leaving your system configurations completely out of arm&#39;s reach.</p><h4>2. Protection on Untrusted Networks</h4><p>Because the script operates purely on an instantaneous lifecycle, you never have to worry about accidentally broadcasting an open port to an insecure public hotspot. It provides an “easy-mode” safe switch for developers who want robust, rapid file manipulation capabilities without becoming network security experts.</p><h3>Open Source and Built for the Community</h3><p>Security tools should never be a black box. SSH Deck is entirely open, predictable, and clean. There are no hidden tracking scripts, telemetry, or remote analytics reporting back to an external server. It’s written with clean, inspectable scripting designed to leverage native Linux hooks smoothly.</p><p>Whether you are trying to move massive local assets onto an edge machine, manage secondary system storage partitions without constantly running back and forth to your desk, or simply looking to harden your daily development flow, SSH Deck gives you the speed of SSH with the security of an air-gapped system when idle.</p><h3>Try It Today</h3><p>Stop leaving your background daemons running. Check out the project, inspect the logic, and install it for your environment today.</p><p>👉 <strong>Visit the official portal:</strong> <a href="https://sshdeck.gscodes.dev/">sshdeck.gscodes.dev</a></p><p><em>How do you handle SSH management on your local machines? Let’s talk about network security and dev workflows in the comments below!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68c6f6c97fbd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NextMin — Ship Admin Panels & APIs from JSON Schemas in Record Time]]></title>
            <link>https://medium.com/@tareqaziz0065/nextmin-ship-admin-panels-apis-from-json-schemas-in-record-time-89b08ce4d05f?source=rss-6f94fe1f9c46------2</link>
            <guid isPermaLink="false">https://medium.com/p/89b08ce4d05f</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Tareq Aziz]]></dc:creator>
            <pubDate>Fri, 26 Sep 2025 04:25:02 GMT</pubDate>
            <atom:updated>2025-09-26T04:25:02.642Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YrkeLNNBxI_j1YGwqir7lA.png" /></figure><h3>NextMin — Ship Admin Panels &amp; APIs from JSON Schemas in Record Time</h3><p>Developers waste weeks setting up CRUD, auth, and dashboards. NextMin cuts that to <strong>hours</strong> by turning <strong>JSON schemas into production-ready apps</strong>.</p><p><strong>Why NextMin?</strong></p><ul><li>Schema-first development</li><li>Secure APIs with JWT + API Keys</li><li>Plug-and-play React Admin</li><li>Works with Next.js App Router</li></ul><p><strong>Live Playground:</strong> <a href="https://nextmin-playground.gscodes.dev/">https://nextmin-playground.gscodes.dev/</a></p><p>NextMin is for builders who value speed + adaptability. Perfect for startups, hackathons, and internal tools.</p><p><strong>Read More:</strong> 👉 <a href="https://nextmin.gscodes.dev/">https://nextmin.gscodes.dev/</a></p><p>Next.js admin panel, React dashboard, JSON schema API, Node.js CRUD generator, developer productivity tools</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89b08ce4d05f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Streamlining End‑to‑End Testing in React Native with Detox and AuthApp]]></title>
            <link>https://medium.com/@tareqaziz0065/streamlining-end-to-end-testing-in-react-native-with-detox-and-authapp-1f6fde9c8153?source=rss-6f94fe1f9c46------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f6fde9c8153</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[ui-test-automation]]></category>
            <category><![CDATA[detox]]></category>
            <dc:creator><![CDATA[Tareq Aziz]]></dc:creator>
            <pubDate>Tue, 22 Apr 2025 22:54:08 GMT</pubDate>
            <atom:updated>2025-04-22T22:54:08.876Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KwRi5dM9J7zAtWxrMX_I-w.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@edvino123?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Edvin Vasilionok</a> on <a href="https://unsplash.com/photos/background-pattern-eSAtjyIly1A?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><p>Building a rock‑solid authentication flow is only half the battle — automating its validation end‑to‑end is what gives you true confidence. In this post, I’ll walk you through how I integrated <strong>Detox</strong> into <strong>AuthApp</strong>, a React Native CLI starter that features login, signup, and logout flows managed via Context API. You’ll see how to set up Detox, capture screenshots and GIFs, and keep your artifacts organized per platform.</p><p><strong>Why Detox?</strong></p><ul><li><strong>True E2E</strong>: Detox drives your app on real simulators/emulators, interacting with native controls.</li><li><strong>Synchronization</strong>: Automatically waits for React Native’s JS thread, network requests, and animations to idle.</li><li><strong>Cross‑platform</strong>: Run the same tests on iOS and Android with unified APIs.</li></ul><p><strong>AuthApp at a Glance</strong></p><p>AuthApp is a TypeScript‑based React Native CLI project (no Expo) featuring:</p><ul><li><strong>Login &amp; Signup</strong> screens with live validation</li><li><strong>React Context API</strong> for global auth state</li><li><strong>AsyncStorage</strong> persistence (optional)</li><li><strong>Animated</strong> form fields, buttons, and screen transitions</li></ul><p>Check out the full code on GitHub:<br>https://github.com/tareq0065/AuthApp</p><p><strong>Key Detox Features in AuthApp</strong></p><ol><li><strong>Platform‑specific artifact folders</strong><br> Screenshots and videos live under files/ios/ and files/android/.</li><li><strong>Automatic screenshots</strong><br> A small helper capture(screenName) takes a snapshot whenever a screen appears.</li><li><strong>Merged videos &amp; GIF previews</strong><br> Per‑test clips are concatenated via FFmpeg into ios.mp4/android.mp4 and converted to ios.gif/android.gif.</li><li><strong>Clear cleanup</strong><br> Intermediate folders are pruned so only your final artifacts remain.</li></ol><h3>Getting Started</h3><h4>1. Install Detox</h4><pre># at the root of AuthApp<br>yarn add --dev detox detox-cli</pre><p>Install peer dependencies for Android and iOS per the Detox docs.</p><h4><strong>2. Configure Detox</strong></h4><p>In your detox.config.json:</p><pre>{<br>  &quot;apps&quot;: {<br>    &quot;ios.debug&quot;: {<br>      &quot;type&quot;: &quot;ios.app&quot;,<br>      &quot;binaryPath&quot;: &quot;ios/build/Build/Products/Debug-iphonesimulator/AuthApp.app&quot;,<br>      &quot;build&quot;: &quot;xcodebuild -workspace ios/AuthApp.xcworkspace -scheme AuthApp -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build&quot;<br>    },<br>    &quot;android.debug&quot;: {<br>      &quot;type&quot;: &quot;android.apk&quot;,<br>      &quot;binaryPath&quot;: &quot;android/app/build/outputs/apk/debug/app-debug.apk&quot;,<br>      &quot;testBinaryPath&quot;: &quot;android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk&quot;,<br>      &quot;build&quot;: &quot;cd android &amp;&amp; ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug &amp;&amp; cd ..&quot;<br>    }<br>  },<br>  &quot;devices&quot;: {<br>    &quot;simulator&quot;: {<br>      &quot;type&quot;: &quot;ios.simulator&quot;,<br>      &quot;device&quot;: { &quot;type&quot;: &quot;iPhone 16 Pro&quot; }<br>    },<br>    &quot;emulator&quot;: {<br>      &quot;type&quot;: &quot;android.emulator&quot;,<br>      &quot;device&quot;: { &quot;avdName&quot;: &quot;Pixel_3a_API_34_extension_level_7_arm64-v8a&quot; }<br>    }<br>  },<br>  &quot;configurations&quot;: {<br>    &quot;ios.sim.debug&quot;: { &quot;device&quot;: &quot;simulator&quot;, &quot;app&quot;: &quot;ios.debug&quot; },<br>    &quot;android.emu.debug&quot;: { &quot;device&quot;: &quot;emulator&quot;, &quot;app&quot;: &quot;android.debug&quot; }<br>  }<br>}</pre><h4>3. Add the capture() helper</h4><p>Create e2e/utils/capture.ts:</p><pre>import { device } from &#39;detox&#39;;<br>import fs from &#39;fs&#39;;<br>import path from &#39;path&#39;;<br><br>export async function capture(name: string) {<br>  const tmp = await device.takeScreenshot(name);<br>  const platform = device.getPlatform();<br>  const dir = path.resolve(__dirname, &#39;..&#39;, &#39;..&#39;, &#39;files&#39;, platform);<br>  if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });<br>  fs.copyFileSync(tmp, path.join(dir, `${name}.png`));<br>}</pre><h4>4. Write your tests</h4><p>In e2e/authFlow.e2e.ts:</p><pre>import { device, element, by, expect } from &#39;detox&#39;;<br>import { capture } from &#39;./utils/capture&#39;;<br><br>describe(&#39;Auth Flow&#39;, () =&gt; {<br>  beforeAll(async () =&gt; {<br>    await device.launchApp({ delete: true });<br>  });<br><br>  it(&#39;signup → login → logout&#39;, async () =&gt; {<br>    // SIGNUP SCREEN<br>    await element(by.id(&#39;gotoSignup&#39;)).tap();<br>    await capture(&#39;01_Signup&#39;);<br>    // ... form interactions ...<br>    await capture(&#39;02_SignupSuccess&#39;);<br><br>    // LOGOUT &amp; LOGIN<br>    await element(by.id(&#39;logout&#39;)).tap();<br>    await capture(&#39;03_Login&#39;);<br>    // ... more interactions ...<br>    await capture(&#39;04_LoginSuccess&#39;);<br>  });<br>});</pre><h4>5. Record and merge videos/GIFs</h4><p>Scripts in package.json:</p><pre>&quot;scripts&quot;: {<br>  &quot;predetox:ios&quot;: &quot;rm -rf files/ios &amp;&amp; mkdir -p files/ios&quot;,<br>  &quot;detox:build:ios&quot;: &quot;detox build -c ios.sim.debug&quot;,<br>  &quot;detox:test:ios&quot;: &quot;npm run predetox:ios &amp;&amp; detox test -c ios.sim.debug --record-videos all --take-screenshots all --artifacts-location files/ios/ &amp;&amp; node scripts/finalizeVideo.js ios&quot;,<br>  // same for Android…<br>}</pre><p>finalizeVideo.js merges clips, converts to GIF, and prunes:</p><pre>#!/usr/bin/env node<br># (see full script in repo/scripts/finalizeVideo.js)</pre><h4>Wrapping Up</h4><p>With Detox wired into AuthApp:</p><ul><li>You get <strong>reliable, cross‑platform E2E tests</strong></li><li><strong>Artifacts</strong> (screenshots &amp; GIFs) live alongside your code</li><li>Your CI pipeline can <strong>validate every auth flow</strong> before release</li></ul><p>Dive into the full setup and code examples here:<br> <a href="https://github.com/tareq0065/AuthApp">https://github.com/tareq0065/AuthApp</a></p><p>Happy testing! 🚀</p><p><strong>I am trying to share real life coding problems and how I resolve those problems. Please follow me for more.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f6fde9c8153" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A tool that creates next js pages for app router]]></title>
            <link>https://medium.com/@tareqaziz0065/a-tool-that-creates-next-js-pages-for-app-router-23f413027fc6?source=rss-6f94fe1f9c46------2</link>
            <guid isPermaLink="false">https://medium.com/p/23f413027fc6</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Tareq Aziz]]></dc:creator>
            <pubDate>Fri, 24 May 2024 16:45:36 GMT</pubDate>
            <atom:updated>2024-05-24T16:45:36.474Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AyakQRbNKpB9Wgv4vy6hlw.jpeg" /></figure><h3>A tool that creates Next.js pages for app router</h3><h3>CNAP — Create Next App Pages</h3><p>cnap (Create Next App Page) is a CLI tool designed to quickly scaffold Next.js pages for app router using tailwind css. It generates a directory structure with predefined files, including loader.js, template.js, page.js, and layout.js, each filled with basic component templates to jumpstart your Next.js development.</p><h3>Installation</h3><p>To install cnap globally on your machine via npm, run the following command:</p><pre>npm install -g @airoom/create-next-app-page</pre><p>This allows you to use the cnap command from anywhere on your system.</p><h3>Usage</h3><p>To use cnap, provide a path and component name. The command creates a new directory structure at the specified location with predefined component templates. The path can include both the base directory and the component name, enabling you to specify exactly where in your project&#39;s directory structure you want the new components to be created.</p><h3>Basic Usage</h3><p>To create a new component structure:</p><pre>cnap</pre><p>This will ask you to enter path name and page name to create a directory within app/pageName with the following structure:</p><ul><li>loader.js - Basic loading component.</li><li>template.js - Basic template component.</li><li>page.js - Basic page component.</li><li>layout.js - Basic layout component.</li></ul><p>Each file will contain a simple Next.js component template to get you started.</p><h3>Example File Content:</h3><p>For example, page.js might contain:</p><pre>export default function Page() {<br>  return &lt;div&gt;Page Component&lt;/div&gt;;<br>}</pre><p><a href="https://www.npmjs.com/package/@airoom/create-next-app-page">@airoom/create-next-app-page</a></p><p><strong>I am trying to share real life coding problems and how I resolve those problems. Please follow me for more.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23f413027fc6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Streamline the process of listening for new data in your bad database and migrating it to your good…]]></title>
            <link>https://medium.com/@tareqaziz0065/streamline-the-process-of-listening-for-new-data-in-your-bad-database-and-migrating-it-to-your-c6b0eaa6fc43?source=rss-6f94fe1f9c46------2</link>
            <guid isPermaLink="false">https://medium.com/p/c6b0eaa6fc43</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[postgres]]></category>
            <dc:creator><![CDATA[Tareq Aziz]]></dc:creator>
            <pubDate>Sat, 16 Mar 2024 07:01:20 GMT</pubDate>
            <atom:updated>2024-03-16T07:01:20.923Z</atom:updated>
            <content:encoded><![CDATA[<h3>Streamline the process of listening for new data in your bad database and migrating it to your good database</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7Tss3k3qr-gCILEXVSCQzQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@growtika?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Growtika</a> on <a href="https://unsplash.com/photos/a-blue-and-white-logo-8zB4P0eafrs?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><h3>Step 1: Set Up PostgreSQL Triggers</h3><p>First, you need to create a PostgreSQL trigger that uses the NOTIFY command to alert your application of new data. Execute the following SQL commands in your PostgreSQL database to set up the trigger and notification function:</p><pre>-- Create a function that sends a notification<br>CREATE OR REPLACE FUNCTION notify_new_data()<br>RETURNS TRIGGER AS $$<br>BEGIN<br>  NOTIFY new_data_channel, NEW.id::text; -- Sends the new row&#39;s ID<br>  RETURN NEW;<br>END;<br>$$ LANGUAGE plpgsql;<br><br>-- Create a trigger that calls the notify function after each new row insertion<br>CREATE TRIGGER trigger_new_data_after_insert<br>AFTER INSERT ON bad_table<br>FOR EACH ROW EXECUTE FUNCTION notify_new_data();</pre><h3>Step 2: Create a Node.js Application</h3><pre>npm init -y<br>npm install pg</pre><p>Create a file named migrateData.js and fill it with the following code, which establishes two database connections (one for listening to notifications and another for querying the database) and handles new data processing:</p><pre>const { Pool, Client } = require(&#39;pg&#39;);<br><br>// Configuration for the &quot;bad&quot; database<br>const badDbConfig = {<br>  user: &#39;your_bad_db_user&#39;,<br>  host: &#39;your_bad_db_host&#39;,<br>  database: &#39;your_bad_db_name&#39;,<br>  password: &#39;your_bad_db_password&#39;,<br>  port: 3211, // example port<br>};<br><br>// Configuration for the &quot;good&quot; database<br>const goodDbPool = new Pool({<br>  user: &#39;your_good_db_user&#39;,<br>  host: &#39;your_good_db_host&#39;,<br>  database: &#39;your_good_db_name&#39;,<br>  password: &#39;your_good_db_password&#39;,<br>  port: 5432, // default PostgreSQL port<br>});<br><br>// Client solely for listening to NOTIFY<br>const listenClient = new Client(badDbConfig);<br>listenClient.connect();<br>listenClient.query(&#39;LISTEN new_data_channel&#39;);<br><br>listenClient.on(&#39;notification&#39;, async (msg) =&gt; {<br>  console.log(&#39;New data notification received:&#39;, msg);<br>  // Process the new data using its ID received in the notification<br>  await processNewData(msg.payload);<br>});<br><br>const processNewData = async (dataId) =&gt; {<br>  const badDbPool = new Pool(badDbConfig);<br>  try {<br>    // Fetch the new row by ID<br>    const res = await badDbPool.query(&#39;SELECT * FROM bad_table WHERE id = $1&#39;, [dataId]);<br>    const newData = res.rows[0]; // Assuming the ID is unique, we get one row<br><br>    if (newData) {<br>      const formattedData = formatData(newData);<br>      await insertIntoGoodDatabase(formattedData);<br>      // Optionally, mark the row as processed in the bad database<br>    }<br>  } catch (err) {<br>    console.error(&#39;Error processing new data:&#39;, err);<br>  } finally {<br>    await badDbPool.end(); // Close the pool to prevent hanging connections<br>  }<br>};<br><br>const formatData = (data) =&gt; {<br>  // Implement data formatting logic here<br>  return data;<br>};<br><br>const insertIntoGoodDatabase = async (data) =&gt; {<br>  try {<br>    // Insert formatted data into the good database<br>    await goodDbPool.query(&#39;INSERT INTO good_table (column1, column2) VALUES ($1, $2)&#39;, [data.column1, data.column2]);<br>  } catch (err) {<br>    console.error(&#39;Error inserting into good database:&#39;, err);<br>  }<br>};</pre><p>Replace the placeholders in the badDbConfig and goodDbPool configurations with your actual database connection details. Also, adjust the formatData and insertIntoGoodDatabase functions according to your data formatting and insertion needs.</p><h3>How It Works:</h3><ol><li>Listening for Notifications: The script uses a Client instance to listen for notifications on the new_data_channel. When a new row is inserted into bad_table, the trigger fires, sending a notification that includes the new row&#39;s ID.</li><li>Processing New Data: Upon receiving a notification, the script fetches the new row from the bad database using its ID, formats the data, and then inserts the formatted data into the good database.</li><li>Closing Resources: After processing the data, the pool used to fetch the new row is closed to prevent resource leaks.</li></ol><p>This code establishes a persistent connection to listen for notifications from the bad database. Upon receiving a notification, it fetches the new data, processes it, and inserts it into the good database. It ensures that data migration happens automatically and handles one row at a time, minimizing the risk of data loss or duplication.</p><p><strong>I am trying to share real life coding problems and how I resolve those problems. Please follow me for more.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c6b0eaa6fc43" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Next JS Implementing Server-Side Sessions]]></title>
            <link>https://medium.com/@tareqaziz0065/next-js-implementing-server-side-sessions-b15333d9ef8d?source=rss-6f94fe1f9c46------2</link>
            <guid isPermaLink="false">https://medium.com/p/b15333d9ef8d</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[nextauth]]></category>
            <dc:creator><![CDATA[Tareq Aziz]]></dc:creator>
            <pubDate>Sat, 27 Jan 2024 15:43:17 GMT</pubDate>
            <atom:updated>2024-01-27T15:43:17.670Z</atom:updated>
            <content:encoded><![CDATA[<h3>Next.js Implementing Server-Side Sessions</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q0uB32tybgbnuJKgSLlqCA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@mr_williams_photography?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Micah Williams</a> on <a href="https://unsplash.com/photos/black-and-gray-code-padlock-anchored-on-chain-link-fence-selective-focus-photo-lmFJOx7hPc4?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><h3>Step 1: Implementing Server-Side Sessions</h3><p>First, set up your session management system. This typically involves creating and validating sessions, and storing session information in secure, HTTP-only cookies.</p><h4>Session Management in API Routes</h4><p>In your API routes (under app/routes/api/), you can manage sessions. For example, in a login route, you would authenticate the user, create a session, and then set a session cookie.</p><pre>// app/routes/api/login.ts<br><br>import { createSession, getUser } from &#39;@/lib/auth&#39;; // Implement these functions<br>import type { NextApiRequest, NextApiResponse } from &#39;next&#39;;<br><br>export default async function login(req: NextApiRequest, res: NextApiResponse) {<br>  const user = await getUser(req.body.username, req.body.password); // User authentication<br>  if (!user) {<br>    return res.status(401).json({ error: &#39;Invalid credentials&#39; });<br>  }<br><br>  const sessionId = await createSession(user.id); // Session creation<br>  res.setHeader(&#39;Set-Cookie&#39;, `sessionId=${sessionId}; HttpOnly; Path=/; SameSite=Lax`);<br>  res.status(200).json({ message: &#39;Success&#39; });<br>}</pre><h3>Step 2: Using App Router Middleware for Redirection</h3><p>With App Router middleware, you can intercept requests and implement logic based on the session state.</p><h4>Example Middleware</h4><p>Create a middleware file (e.g., app/middleware.ts) to handle session validation and redirection.</p><pre>// app/middleware.ts<br><br>import { NextRequest, NextResponse } from &#39;next/server&#39;;<br>import { getSession } from &#39;@/lib/session&#39;; // Implement this function<br><br>export async function middleware(req: NextRequest) {<br>  const session = await getSession(req.cookies.sessionId); // Validate session<br><br>  // Redirect to login if there&#39;s no session and the request is for a protected route<br>  if (!session &amp;&amp; req.nextUrl.pathname.startsWith(&#39;/protected&#39;)) {<br>    return NextResponse.redirect(new URL(&#39;/login&#39;, req.url));<br>  }<br><br>  return NextResponse.next();<br>}</pre><h3>Step 3: Session Validation and Redirection on the Client</h3><p>On the client side, you might still need to handle session-related updates, like redirecting after login/logout or displaying loading states.</p><pre>// In your React components<br>import { useEffect } from &#39;react&#39;;<br>import { useRouter } from &#39;next/router&#39;;<br><br>const MyComponent = () =&gt; {<br>  const router = useRouter();<br><br>  useEffect(() =&gt; {<br>    // Check session state and redirect if necessary<br>    // This could be a call to an API route that verifies the session<br>    checkSession().then(isValidSession =&gt; {<br>      if (!isValidSession) {<br>        router.push(&#39;/login&#39;);<br>      }<br>    });<br>  }, []);<br><br>  // Render your component<br>};</pre><h3>Conclusions</h3><ul><li>Session Security: Use secure, HTTP-only cookies to store session identifiers.</li><li>Cookie Flags: Set appropriate cookie flags (like SameSite and Secure) to enhance security.</li><li>Scalability: For a scalable application, consider using a database or a service like Redis for session management.</li><li>Error Handling: Ensure robust error handling in your session management logic.</li><li>Client-Side Handling: Even with server-side checks, you may want to handle certain client-side behaviors based on the session state for a better user experience.</li></ul><p>This setup provides a robust system for managing server-side sessions and controlling access to routes in your Next.js application using the App Router.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b15333d9ef8d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Convert seconds to an audio time format]]></title>
            <link>https://medium.com/@tareqaziz0065/convert-seconds-to-an-audio-time-format-46f43b765d5e?source=rss-6f94fe1f9c46------2</link>
            <guid isPermaLink="false">https://medium.com/p/46f43b765d5e</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[time-converter]]></category>
            <category><![CDATA[snippet]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Tareq Aziz]]></dc:creator>
            <pubDate>Sat, 09 Sep 2023 10:00:59 GMT</pubDate>
            <atom:updated>2023-09-09T10:00:59.725Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Convert seconds to an audio time format" src="https://cdn-images-1.medium.com/max/1024/1*bWG7CGj__s56dgKSfrERaQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@neonbrand?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Kenny Eliason</a> on <a href="https://unsplash.com/photos/KYxXMTpTzek?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>To convert seconds to an audio time format (typically represented as HH:MM:SS), you can use the following function in JavaScript:</p><pre>function secondsToHMS(seconds) {<br>    let hours = Math.floor(seconds / 3600);<br>    seconds %= 3600;<br>    let minutes = Math.floor(seconds / 60);<br>    let secs = Math.floor(seconds % 60);<br><br>    return [hours, minutes, secs]<br>        .map(v =&gt; v &lt; 10 ? &#39;0&#39; + v : v)<br>        .filter((v, i) =&gt; v !== &#39;00&#39; || i &gt; 0)<br>        .join(&#39;:&#39;);<br>}<br><br>console.log(secondsToHMS(3723)); // Output: 1:02:03<br>console.log(secondsToHMS(63));   // Output: 01:03<br>console.log(secondsToHMS(5));    // Output: 05</pre><p><strong>In this function:</strong></p><ol><li>Divides the total seconds by, 3600 to get the number of hours.</li><li>Uses the modulus operator % to get the remaining seconds after hours have been determined.</li><li>Divides the remaining seconds by 60 to get the number of minutes.</li><li>Again, uses the modulus operator to get the remaining seconds after minutes have been determined.</li><li>Formats each value (hours, minutes, seconds) with leading zeroes if necessary.</li><li>Filters out leading ‘00’ hours if present.</li><li>Joins them using the colon ‘:’ to produce the formatted time.</li></ol><p><strong>I am trying to share real life coding problems and how I resolve those problems. Please follow me for more.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46f43b765d5e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building an audio converter using FFmpeg and Next.js]]></title>
            <link>https://medium.com/@tareqaziz0065/building-an-audio-converter-using-ffmpeg-and-next-js-b96cfc519091?source=rss-6f94fe1f9c46------2</link>
            <guid isPermaLink="false">https://medium.com/p/b96cfc519091</guid>
            <category><![CDATA[audio]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[ffmpeg]]></category>
            <dc:creator><![CDATA[Tareq Aziz]]></dc:creator>
            <pubDate>Fri, 25 Aug 2023 17:56:52 GMT</pubDate>
            <atom:updated>2023-08-25T17:56:52.896Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MY5pFwXSrKWd0PJwkGznCQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@kellysikkema?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Kelly Sikkema</a> on <a href="https://unsplash.com/photos/F7UonANW5LU?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Building an audio converter using FFmpeg and Next.js will involve handling file uploads, processing the audio using FFmpeg, and then serving the converted file to the user. Here is a basic outline and implementation:</p><h3>Prerequisites:</h3><ol><li>You need to have FFmpeg installed on your server.</li><li>Install the required dependencies:</li></ol><p>npm install next multer</p><h3>Steps:</h3><ol><li><strong>File Upload Handling</strong>:</li></ol><p>We&#39;ll use the multer middleware for handling file uploads in Next.js.</p><p><strong>2. Audio Conversion using FFmpeg</strong>:</p><p>Once the file is uploaded, we&#39;ll use FFmpeg to convert the audio format.</p><p><strong>3. Serve the Converted File</strong>:</p><p>After conversion, the new file will be available for download.</p><h3>Implementation:</h3><ol><li><strong>API Route for File Upload &amp; Conversion</strong>:</li></ol><p>Create a new API route: pages/api/convert.js</p><pre>import multer from &#39;multer&#39;;<br>import { exec } from &#39;child_process&#39;;<br>import { promises as fs } from &#39;fs&#39;;<br><br>const upload = multer({ dest: &#39;/tmp&#39; }); // Store the uploaded file temporarily in /tmp<br><br>export const config = {<br>  api: {<br>    bodyParser: false,<br>  },<br>};<br><br>export default async (req, res) =&gt; {<br>  if (req.method === &#39;POST&#39;) {<br>    const convertAudio = async (filePath, outputFormat) =&gt; {<br>      return new Promise((resolve, reject) =&gt; {<br>        const outputPath = `/tmp/output.${outputFormat}`;<br>        exec(`ffmpeg -i ${filePath} ${outputPath}`, (error) =&gt; {<br>          if (error) {<br>            reject(error);<br>          } else {<br>            resolve(outputPath);<br>          }<br>        });<br>      });<br>    };<br><br>    const fileHandlingMiddleware = upload.single(&#39;audioFile&#39;);<br><br>    fileHandlingMiddleware(req, res, async (err) =&gt; {<br>      if (err) {<br>        return res.status(500).json({ error: &#39;Error uploading file.&#39; });<br>      }<br><br>      try {<br>        const convertedFilePath = await convertAudio(req.file.path, &#39;mp3&#39;); // Convert to mp3 for this example<br>        const fileBuffer = await fs.readFile(convertedFilePath);<br><br>        res.setHeader(&#39;Content-Disposition&#39;, &#39;attachment; filename=converted.mp3&#39;);<br>        res.setHeader(&#39;Content-Type&#39;, &#39;audio/mpeg&#39;);<br>        res.end(fileBuffer);<br><br>        // Cleanup temp files<br>        await fs.unlink(req.file.path);<br>        await fs.unlink(convertedFilePath);<br>      } catch (error) {<br>        res.status(500).json({ error: &#39;Error converting audio.&#39; });<br>      }<br>    });<br>  } else {<br>    res.status(405).json({ error: &#39;Only POST requests are allowed.&#39; });<br>  }<br>};</pre><ol><li><strong>Frontend for File Upload</strong>:</li></ol><p>You can create a simple form in one of your pages to allow users to upload a file.</p><pre>import React, { useRef } from &#39;react&#39;;<br><br>const ConverterPage = () =&gt; {<br>  const fileRef = useRef(null);<br><br>  const handleUpload = async (event) =&gt; {<br>    event.preventDefault();<br>    const formData = new FormData();<br>    formData.append(&#39;audioFile&#39;, fileRef.current.files[0]);<br><br>    const response = await fetch(&#39;/api/convert&#39;, {<br>      method: &#39;POST&#39;,<br>      body: formData,<br>    });<br><br>    if (response.ok) {<br>      const blob = await response.blob();<br>      const url = window.URL.createObjectURL(blob);<br>      const a = document.createElement(&#39;a&#39;);<br>      a.style.display = &#39;none&#39;;<br>      a.href = url;<br>      a.download = &#39;converted.mp3&#39;;<br>      document.body.appendChild(a);<br>      a.click();<br>      window.URL.revokeObjectURL(url);<br>    } else {<br>      console.error(&#39;Failed to convert audio&#39;);<br>    }<br>  };<br><br>  return (<br>    &lt;div&gt;<br>      &lt;form onSubmit={handleUpload}&gt;<br>        &lt;input type=&quot;file&quot; ref={fileRef} accept=&quot;audio/*&quot; required /&gt;<br>        &lt;button type=&quot;submit&quot;&gt;Convert&lt;/button&gt;<br>      &lt;/form&gt;<br>    &lt;/div&gt;<br>  );<br>};<br><br>export default ConverterPage;</pre><p>This is a very basic implementation. You may want to add more error handling, allow users to select output formats, or use a library like ffmpeg.wasm to process the audio in the browser (without the need for a server-side FFmpeg installation). Always ensure that you manage uploaded files carefully to avoid any security risks.</p><p><strong>I am trying to share real life coding problems and how I resolve those problems. Please follow me for more.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b96cfc519091" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>