<?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 Yarin Dekel on Medium]]></title>
        <description><![CDATA[Stories by Yarin Dekel on Medium]]></description>
        <link>https://medium.com/@yarindeoh?source=rss-cc8fa2b8ed4f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*QPOdrjx4a3FHAa45</url>
            <title>Stories by Yarin Dekel on Medium</title>
            <link>https://medium.com/@yarindeoh?source=rss-cc8fa2b8ed4f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 15:22:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yarindeoh/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[Boost Your Build Time By 70% With Rspack]]></title>
            <link>https://medium.com/@yarindeoh/boost-your-build-time-by-70-with-rspack-a2dd3c47697c?source=rss-cc8fa2b8ed4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2dd3c47697c</guid>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <dc:creator><![CDATA[Yarin Dekel]]></dc:creator>
            <pubDate>Mon, 10 Mar 2025 18:40:31 GMT</pubDate>
            <atom:updated>2025-03-19T09:22:08.957Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*73LVZpj7BIpM3PzY3RGZlA.png" /></figure><p>In the world of frontend development, <strong>speed is everything</strong>. Long build times, slow development servers, and resource-heavy bundlers can kill productivity and velocity. That’s exactly why we decided to <strong>migrate from Webpack to Rspack</strong>, a Rust-powered bundler that promises <strong>super-fast performance</strong> while keeping Webpack’s familiar configuration.</p><p>Here’s everything I learned along the way — the why, the how, the challenges, and of course, the <strong>sweet performance gains</strong>.</p><h3>Why We Ditched Webpack for Rspack</h3><p>Our Webpack setup had been working fine <strong>but super slow</strong>.</p><p>As our codebase grew, <strong>build times became unbearable</strong>, and the <strong>development server reloads took forever</strong>. Every code change felt like waiting for a bus in the rain.</p><p>We wanted:</p><p>✅ <strong>Faster builds</strong> — Less time watching the terminal, more time coding.<br>✅ <strong>Better HMR (Hot Module Replacement)</strong> — Instant feedback while developing.<br>✅ <strong>Easy migration</strong> — A new tool that wouldn’t force a complete rewrite.</p><h4>Before Diving in</h4><p>I don’t believe in <strong>switching tools just because they’re new</strong>. The frontend ecosystem moves super fast, and there’s always a shiny new library promising to be <strong>faster, smaller, and better</strong>. But blindly chasing trends can lead to <strong>unnecessary rewrites and wasted effort</strong>.</p><h4>Optimization vs. Migration: Asking the Right Questions</h4><p>That’s why, before considering a migration, it’s always worth asking:<strong> Can we optimize our current setup instead?</strong></p><ul><li>If you can improve build times with minimal effort by tweaking Webpack (caching, parallelization, etc.), that’s a great first step.</li><li>If optimization requires deep architectural changes or still doesn’t meet your performance goals, then migration might be the better choice.</li></ul><h4>Could Webpack Be Optimized to Match Rspack?</h4><p>From what I’ve seen, <strong>Rspack’s performance gains come from fundamental architectural advantages</strong> that Webpack can’t easily match:</p><ul><li><strong>Caching &amp; Incremental Builds</strong> — Webpack offers <strong>filesystem caching</strong>, but Rspack’s <strong>native incremental compilation</strong> is far more efficient.</li><li><strong>Parallelization</strong> — You can use thread-loaderwith Webpack, but Rspack is <strong>natively multi-threaded</strong> with Rust’s parallel execution.</li><li><strong>Dev Server &amp; HMR</strong> — Webpack’s <strong>HMR slows down</strong> with large projects because of how it <strong>t</strong>racks, updates, and recompiles modules, whereas Rspack <strong>keeps it super fast</strong>.</li></ul><h4>When Should You Migrate?</h4><p>If Webpack optimizations can get you to an acceptable build time, that would be great! But if the effort required to optimize Webpack outweighs the migration effort, then switching to a more performant bundler like Rspack <strong>makes sense</strong>.</p><h3>The Migration: Smoother Than Expected</h3><p>One of our biggest concerns was <strong>compatibility</strong>.</p><p>I’ve done migrations before, and given that our codebase is huge with tons of custom Webpack config, I did not expect this migration to go smoothly.</p><p>But to my surprise, it <strong>wasn’t painful at all</strong> 🎉</p><p>I benchmarked other build tools like Vite, but the migration effort was too high for us. Rspack, on the other hand, was designed as a drop-in replacement for Webpack, meaning most of the transition was <strong>just API replacements</strong>.</p><p>I won’t lie — I wanted to rewrite our entire build setup from scratch (because, let’s be honest, sometimes we just want a fresh start 😃). But <strong>ROI matters</strong>, and Rspack’s compatibility saved us <strong>weeks of unnecessary work</strong>.</p><h3>The Performance Boost: Numbers Don’t Lie</h3><p>Now, the fun part —<strong> </strong>benchmarking the speed difference<strong>.</strong></p><p><strong>Local Build Time:</strong><br>❌ <strong>Before:</strong> ~1.7 minutes<br>✅ <strong>After:</strong> ~30 seconds</p><p><strong>CI Build Time:</strong><br>❌ <strong>Before:</strong> ~2.8 minutes<br>✅ <strong>After:</strong> ~48 seconds</p><p>That’s a <strong>~70% decrease in both local &amp; CI build time</strong>. Our development experience became buttery smooth, and our CI/CD pipeline saw huge improvements.</p><h3>API Compatability</h3><h4>Webpack Plugins That Worked with Minimal Changes</h4><p>Most of our key plugins had <strong>direct replacements in Rspack</strong>, including, for example:</p><ul><li>mini-css-extract-plugin<strong> → </strong>Rspack.CssExtractRspackPlugin built-in alternative</li><li>html-webpack-plugin<strong> → </strong>Rspack.HtmlRspackPlugin same usage</li><li>module-federation-plugin<strong> → </strong>Rspack.container.ModuleFederationPlugin fully compatible</li><li>eslint-webpack-plugin<strong> → </strong>eslint-rspack-plugin works with minimal changes</li><li>@pmmmwh/react-refresh-webpack-plugin<strong>→ </strong>@rspack/plugin-react-refresh direct replacement</li><li>webpack.DefinePlugin <strong>→ </strong>rspack.DefinePlugin works the same way</li><li>css-minimizer-webpack-plugin <strong>→ </strong>Not needed; Rspack does it internally</li><li>webpack devserver configuration also required API changes. Our existing setup was based on an <strong>older Webpack DevServer version</strong>, which had already diverged from the latest Webpack API. As a result, we had to update it regardless of the migration.</li></ul><p>The full list of plugin compatibility can be found here: <a href="https://rspack.dev/guide/compatibility/plugin">https://rspack.dev/guide/compatibility/plugin</a></p><h4>Missing Plugins &amp; Workarounds</h4><p>Some Webpack plugins didn’t have direct replacements.<br>For example, rollbar-sourcemap-webpack-plugin had no equivalent, so I solved this by <strong>manually uploading source maps to Rollbar using a GitHub Action</strong> during the deployment process.</p><blockquote>Rspack is still a relatively new tool compared to Webpack. While its ecosystem is rapidly expanding and adoption is growing, its community and plugin support aren’t yet as extensive as Webpack’s, leaving a few gaps that may require workarounds.</blockquote><h3>Pro Tips (Written with Blood 😅)</h3><h4>1. Don’t Trust AI Blindly</h4><p>In the era of AI, using tools like ChatGPT for coding help is super tempting. I quickly realized that many suggested APIs <strong>simply don’t exist</strong> in Rspack (or other libraries). After spending <strong>some time</strong> on imaginary functions, I <strong>sticked to the official documentation</strong> and migrated the old-school way — just me and the Rspack docs.</p><h4>2. Lock Your Dependencies</h4><p>We follow <strong>Semantic Versioning (SemVer)</strong> and initially used <strong>caret (</strong><strong>^) </strong>versioning, which allows automatic updates for minor and patch releases. However, a minor update introduced a bug that <strong>broke our build—only in CI. </strong>I spent <strong>hours debugging</strong>, only to realize that what seemed like a harmless update had <strong>silently introduced a bug</strong>. This can happen with <strong>any library, no matter how stable it is</strong>.</p><p>💡 Consider locking your dependencies to <strong>fixed versions </strong>to prevent unexpected failures, especially in CI/CD.</p><h3>Final Thoughts</h3><h4>TL;DR</h4><p><strong>✅</strong> Almost same Webpack config, but much faster<br>✅ Drop-in replacement for most Webpack plugins<br>✅ Instant HMR and super-fast builds to improved development speed<br>✅ A few plugin adjustments needed, but totally worth it</p><p><strong>For us, Rspack was the right choice — </strong>but every project is different and migration isn’t always the answer. If small optimizations can significantly improve your Webpack setup, that’s the best first step. But if the effort to optimize Webpack outweighs the migration effort, then switching to a more performant bundler like Rspack <strong>is the right answer.</strong> Run a<strong> small POC</strong> and see the results for yourself. 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2dd3c47697c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A journey for migrating Jenkins to GitHub Actions]]></title>
            <link>https://medium.com/@yarindeoh/a-journey-for-migrating-jenkins-to-github-actions-4fc635f541d4?source=rss-cc8fa2b8ed4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/4fc635f541d4</guid>
            <category><![CDATA[migration]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[jenkins]]></category>
            <dc:creator><![CDATA[Yarin Dekel]]></dc:creator>
            <pubDate>Sat, 13 May 2023 17:44:57 GMT</pubDate>
            <atom:updated>2023-05-13T17:57:55.476Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*JfzI0QnJPeq_ZpxNExcV6g.png" /></figure><p>In the past, R&amp;D roles were more focused and professional but often caused bottlenecks and decreased developer velocity due to centralized responsibilities and detached teams. Nowadays, developers’ roles are less defined, blurring the boundaries between Product Managers, Software Developers, DevOps Engineers, Automation Engineers, UI/UX designers, and Project Managers.</p><p>Having said that, being a Frontend Infrastructure engineer doing DevOps tasks is super cool but it has a learning curve and challenges. This is where GitHub action comes to the rescue! Read more to learn about my journey ofnmigrating Frontend apps pipelines from Jenkins to GitHub Actions, including why, what, and how.</p><h3>The Motivation</h3><p>Initially, we relied on Jenkins, with a dedicated DevOps team maintaining it. However, as our team grew, scaling with Jenkins became difficult.</p><p>First, we tried to solve it by creating a lot of self-services in Jenkins. It helped dramatically! We jumped into the deep water, and with the product teams, we started to develop and maintain Jenkins files and jobs.</p><p>But managing and maintaining permission levels in Jenkins was challenging. We ended up with only a few developers maintaining and creating new services and jobs to support new needs, making it still centralized.</p><h3>Why GitHub actions?</h3><p>That’s why we wanted to change our approach, own our frontend pipeline, and enable everyone to automate easily and quickly. GitHub Actions helped us achieve this goal. Here’s why:</p><ul><li><strong>Easy to set up and use</strong>: GitHub Actions has a user-friendly interface that makes it easy to create and manage workflows. It also has a large library of pre-built actions that you can use to quickly automate common tasks, such as running tests or deploying code. It has a simple and easy-to-learn syntax for defining your workflows, making it easier to set up and manage your CI/CD pipelines. Compare to Jenkins, you can set up your workflow in seconds.</li><li><strong>Tight integration with your code</strong>: you can easily trigger Actions and workflows when certain events occur in your GitHub repository, such as a new commit or pull request. A single line of code compares to multiple steps you need to do with Jenkins where you need to create Github integration, link your job configuration as a Github webhook, and configure your jobs accordingly.</li><li><strong>No infrastructure to manage</strong>: With GitHub Actions, you don’t need to worry about setting up and maintaining servers to run your automation. GitHub provides the infrastructure for you, so you can focus on writing code instead of managing infrastructure. (unless you are using <a href="https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners">self-hosted runners</a>).</li><li><strong>Supports a wide range of platforms and languages</strong>: GitHub Actions supports a wide range of platforms and languages, including Windows, Linux, and macOS, as well as many popular programming languages like JavaScript, Python, and Ruby.</li><li><strong>Better code maintenance:</strong> You can write custom actions in JavaScript or other programming languages, making your code more readable and easier to maintain.</li></ul><h4>The downsides</h4><ul><li>Jenkins has some advantages over GitHub Actions, such as a <strong>larger community</strong> and support for a wider range of plugins.</li><li>GitHub actions have some limitations in the features they are supporting for example, <a href="https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch">the inputs view</a> is not customizable, and the fields functionality is not dynamic.</li><li><strong>Dependency on GitHub</strong>: Using GitHub Actions requires that your code and repositories be hosted on GitHub. If you use other Git hosting services or have private repositories that you don’t want to host on GitHub, then GitHub Actions may not be the best choice for your organization.</li><li>When using GitHub actions you will be more <strong>exposed to instability in terms of infrastructure</strong> (especially if you will use Github actions runners) and in general the Actions <a href="https://www.githubstatus.com/">services</a>.</li><li><strong>Security</strong>: While GitHub Actions has built-in security features, there have been concerns raised about the security of workflows that execute code from external sources, you’ll need to dig into Github Action <a href="https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions">best practices</a>. Jenkins, on the other hand, has been around for a long time and has a proven track record when it comes to security.</li></ul><h3>Migration Plan</h3><h4>Technical Perspective</h4><p>We first collected all the pipelines we had in Jenkins - starting from code verification in CI through publishing artifacts to our artifactory and deploying our Frontend applications.</p><p>We started the migration by taking our pipelines and migrating them one by one while we kept using Jenkins in the meantime.</p><p>The first candidate was the closest in the lifecycle of our code — verification checks we are running in our CI. We ran both pipelines in <strong>parallel</strong> to have better clarity and visibility to detect problems in the new Github workflows. We kept the GitHub workflow optional while Jenkins was required.</p><p>After we run it for one iteration, we compared the outcomes from both pipelines in terms of status codes, logs, and performance. We even detected some real accidents we saw when running GitHub workflows that were uncovered with Jenkins.</p><p>At the end of the first iteration, we felt safe enough to switch it so that Github workflow was required while Jenkins ran in the background. After the second iteration, we removed Jenkins job from our code verification pipeline.</p><p>We did the same process with the rest of the pipelines —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rGaEELmeVzp1F5k7wHR1zA.png" /></figure><h4>Process Wise</h4><p>Driving a change is challenging, especially a broad-scale one. We announced our plans and timelines to all stakeholders, including DevOps, Frontend developers, and QA engineers. We provided proper knowledge-level training to promote adoption, holding sessions around using GitHub Actions, troubleshooting, and identifying common mistakes. We also offered hands-on training, pairing up developers to learn from each other until we reached the end of the process.</p><h4>Summary</h4><p>We saw that we have a much easier experience creating new pipelines and owning and managing them. We started to automate everything easily and the big success came when we saw that developers are starting to use it to solve their problems by automating things with Github actions!</p><p>The process of migrating Jenkins to GitHub Actions requires careful planning and execution to ensure a smooth transition. It’s important to thoroughly evaluate the differences between the two systems and assess the potential impact on your workflow before making the switch — in terms of security, cost, time, and capacity.</p><p>Once you’ve identified the key differences and planned out your migration strategy, the actual process of migrating can be broken down into several steps, including setting up GitHub Actions workflows, transferring data from Jenkins to GitHub, and integrating GitHub Actions with your existing tools and processes.</p><p>By following these steps and staying mindful of potential challenges, you can successfully migrate your Jenkins pipeline to GitHub Actions, take advantage of the benefits of this powerful automation tool and make developers happier.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4fc635f541d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build a Global Dialog Modal Infrastructure With React Hooks and Redux Hooks]]></title>
            <link>https://medium.com/better-programming/global-dialog-modal-infrastructure-with-react-hooks-and-redux-hooks-1b6bedd052a6?source=rss-cc8fa2b8ed4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b6bedd052a6</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[react-hook]]></category>
            <dc:creator><![CDATA[Yarin Dekel]]></dc:creator>
            <pubDate>Sun, 19 Jan 2020 08:57:15 GMT</pubDate>
            <atom:updated>2020-01-28T09:30:36.464Z</atom:updated>
            <content:encoded><![CDATA[<h4>Infrastructure for your modals to appear anywhere you like</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jJnA1n422AfEU23e-eWSBA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@ronwhitaker?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Ron Whitaker</a> on <a href="https://unsplash.com/s/photos/patterns?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Since dialog modals are almost inseparable from every web application, you need to build its infrastructure wisely. With React hooks (version 16.8 and up) you can reuse logic across your application easily and elegantly. In this piece we’ll go over a global management approach to creating a dialog modal infrastructure using React Hooks and Redux Hooks.</p><h3>Choosing the Right Approach</h3><p>Inspired by <a href="http://atomicdesign.bradfrost.com/chapter-2/">Atomic design methodology</a>, the best practice scenario is to decouple your Modal container from your application using an external/internal reusable component library. Then you need to ask yourself where are you going to manage Modal’s logic? Are you using a global management library? Where you are going to render it — at a predetermined place in the DOM or will you append it dynamically?</p><p>There are many ways of creating Modal infrastructure and you can manage its logic using the following methods.</p><h4>Manage locally</h4><p>Holding a global modal component and manage a local state in every component that consumes it. You can render it with <a href="https://reactjs.org/docs/portals.html">React Portal</a>, which renders right inside the consuming components and provides a way to render children in a DOM node that exists outside the DOM hierarchy of the parent component. Another way is to also include the modal dialog element globally and append its children dynamically in the old way.</p><p>You can choose this quick implementation if you have <em>very low use</em> of dialog modals in your application and a negative trade-off of investing efforts in building solid infrastructure.</p><h4>Manage globally</h4><p>If you’re already using a state management library such as Redux, and you’re using dialog modals all over your application, you’d be better off managing its logic in a global state, creating a reusable shared logic and rendering it as a global element. These days, that easy to do with Hooks — let’s dive in!</p><h3>Global Modal with React and Redux Hooks</h3><p>Assuming you’re hosting your generic and reusable components in an <strong>external library</strong>, you should create a modal directory that has a &lt;Modal /&gt; component that renders its children: &lt;ModalTitle /&gt;, &lt;ModalHeader /&gt;, &lt;ModalBody /&gt;, and&lt;ModalFooter /&gt; as sub and atomic components.</p><p>Consuming modal component in your application is used by creating a &lt;ModalWrapper /&gt; container that renders the modal component and manages its visual state using global state management hooks (e.g Redux hooks). &lt;ModalWrapper /&gt; container will have its view, reducer, constants, and custom Hooks files.</p><p>First, include&lt;ModalWrapper /&gt; in the global level:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/52d20b1052343958003d9b91cfc31569/href">https://medium.com/media/52d20b1052343958003d9b91cfc31569/href</a></iframe><p>Then, create a &lt;ModalWrapper /&gt; container that renders the modal dialog according to the store’s params (size, type, body, title, etc.).</p><p>Displaying a dialog modal is done by dispatching SHOW_MODAL/HIDE_MODAL actions using custom hooks with your requested params.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a79bfa6cff0ad4ba134e3bf3d2236f82/href">https://medium.com/media/a79bfa6cff0ad4ba134e3bf3d2236f82/href</a></iframe><p>You can dynamically render a custom component using <a href="https://reactjs.org/docs/code-splitting.html#reactlazy">react.lazy</a> which takes a function that must call a dynamic import()and must return a Promise which resolves to a module with a default export containing a React component.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/55c6a4c59a277169f3fed31c87ea7e82/href">https://medium.com/media/55c6a4c59a277169f3fed31c87ea7e82/href</a></iframe><p>If you have any special treatment, for a confirmation dialog, for example, you can create a reusable Hook for that, and basically for all of your reusable modal’s logic.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f62aff1c5ef66390041a04ca4fcb777b/href">https://medium.com/media/f62aff1c5ef66390041a04ca4fcb777b/href</a></iframe><h3>Usage Example</h3><ul><li>Rendering a basic modal will be from the component hooks file with useShowModal hook with all of the necessary params.</li><li>Rendering a dynamic component inside a modal is done by passing the absolute path and an optional component props.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2092cf41352d1c17104415f2b080ac7c/href">https://medium.com/media/2092cf41352d1c17104415f2b080ac7c/href</a></iframe><p>That’s it!</p><h3>Summary</h3><p>Modals are common and if you are using the latest React, Redux, and React-Redux versions you can easily create your infrastructure in a modular and a reusable way.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b6bedd052a6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/global-dialog-modal-infrastructure-with-react-hooks-and-redux-hooks-1b6bedd052a6">Build a Global Dialog Modal Infrastructure With React Hooks and Redux Hooks</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Light Authentication with NodeJS, express and external provider]]></title>
            <link>https://itnext.io/https-medium-com-yarindeoh-light-authentication-with-nodejs-express-and-external-provider-3ad65e637608?source=rss-cc8fa2b8ed4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ad65e637608</guid>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[full-stack]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Yarin Dekel]]></dc:creator>
            <pubDate>Sun, 01 Sep 2019 07:19:56 GMT</pubDate>
            <atom:updated>2020-04-26T08:55:22.546Z</atom:updated>
            <content:encoded><![CDATA[<h3>Light Authentication with Node.js, express and external authentication provider</h3><h4>How many times you were asked to ‘create a tool’ or to ‘automate a process’? probably many, and from those times, how did you managed your authentication ? This guide can help you easily add authentication to you application.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ztOLe3R1czY4ZLR7IpleLQ.png" /></figure><h3>Motivation</h3><p>When developing an internal tool, you will probably have 3 options:</p><ol><li>Your app is running without user authentication phase.</li><li>Your ecosystem already has a kind of authentication ‘micro-service’ that provide you all you need.</li><li>You can create a light authentication proxy using external authentication provider such as Jira which supports SSO for multiple applications within a single domain. (yay, who doesn’t have a Jira account these days?)</li></ol><p>When talking about internal tools, you will still prefer to keep up with standard and secured authentication and best practices. You might want to manage permissions and access control, user’s view and groups, and ensuring API calls are secured.</p><p>You guessed it right, we will discuss option number 3!</p><p>Creating a light authentication service with Node.js and external authentication provider will allow you to avoid using any kind of storage/DB component, you will not need to mess around with group and permission logic, tokenization<strong> </strong>and other “boring” security features.</p><p>Using an external authentication provider such as <a href="https://developer.atlassian.com/server/crowd/crowd-rest-apis/">Atlassian Crowd Rest API</a> will provide you a visual portal where you can mange your users, groups and permissions easily and even export existing Jira accounts/groups from different apps.</p><p>The only downside I found is that you are depending on a 3rd party provider. But still, the trade off is pretty clear when you think about how common it is and all these free and cool features you can get.</p><h3>Architecture</h3><h4>High Level Architecture</h4><p>We have 4 players in the game:</p><ul><li><strong>Frontend</strong>- represent all UI components and user perspective.</li><li><strong>Backend Server</strong>- response to business logic calls.</li><li><strong>Web Server</strong>- middle layer component that used as proxy, communicating with all other components in the field.</li><li><strong>Authentication Provider</strong>- external provider such as<a href="https://developer.atlassian.com/server/crowd/crowd-rest-apis/"> Atlassian Crowd Rest API</a>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/471/1*Gu5pzWiT-INXHtaO8_yf3g.png" /></figure><p>The purpose of the system is to provide one source of truth in matters of authentication that will be consumed only by the web server middleware.</p><p>All requests will address from the Frontend to /proxy router. /proxy/* requests will be managed according to the requested path. Proxy router will take requests, authenticate it through the authentication provider, communicate with the Backend server and send back the response to the Frontend.</p><h4>Sequence Diagrams</h4><p><strong>Login</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*O8go_QU2_OaCAICkLrzn6A.png" /></figure><p>A new user is launching the login page inserting username and password. API request is being sent to the web server which is creating a session with the provided credentials. Authentication provider is responding with session object that contains the user token. The web server is sending the encrypted token to the FE which saves it in localStorage.</p><p>In case it’s a returning user in the login page, FE is sending an authentication request with the saved token and redirecting to the application in case it’s validated.</p><p><strong>Authentication Failed</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*ZT4qpyCQPb9O5frWCad2RQ.png" /></figure><p>All Rest requests will be sent to the web server with the user token. Web server will send authentication request with the token and send back error response to the FE that will redirect to login page and clear it’s localStorage.</p><p><strong>Authentication Succeeded</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*RHXiHxUuLmaTmCsGki1gxg.png" /></figure><p>When the web server is receiving a validated token response, it’s addressing the original request according to the requested path url and payload.</p><h3>Show me some code</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3e2a56e5589bcbadb416f9d04e237a3f/href">https://medium.com/media/3e2a56e5589bcbadb416f9d04e237a3f/href</a></iframe><p>Basic Node.js express server with proxy router.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/02f28df7a16eab80ba8589fc1cf0d27c/href">https://medium.com/media/02f28df7a16eab80ba8589fc1cf0d27c/href</a></iframe><p>Proxy router will get all method requests and handle them, except for /proxy/api requests which will be handled by a sub router called login.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/93cde493abbacb04b0b5efd94d0e7ce7/href">https://medium.com/media/93cde493abbacb04b0b5efd94d0e7ce7/href</a></iframe><p>You will need to create a Crowd Server (<a href="https://confluence.atlassian.com/crowd/installing-crowd-and-crowdid-191862.html">follow Jira instructions</a>). And configure it according to your application needs.</p><p>For the above example I used <a href="https://github.com/ghengeveld/atlassian-crowd-client#atlassian-crowd-client">atlassian-crowd-client</a>, which is a promise-based client library to communicate with an Atlassian Crowd server from Node, written in ES6. It only handle the responses and errors for me, you can communicate directly with <a href="https://docs.atlassian.com/atlassian-crowd/3.1.2/REST/?_ga=2.133030030.1220822418.1564918095-843970779.1553945401#admin/1.0/auditlog-getConfiguration">Crowd REST APIs</a> if you wish so.</p><h3>Summary</h3><p>This code is lightweight! you can easily create authentication service for your internal tools and get some free and cool features that will allow you to manage you application like a pro and in a secure manner.</p><p>PM for questions and <strong>follow me on twitter </strong><a href="https://twitter.com/DekelYarin"><strong>@DekelYarin</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ad65e637608" width="1" height="1" alt=""><hr><p><a href="https://itnext.io/https-medium-com-yarindeoh-light-authentication-with-nodejs-express-and-external-provider-3ad65e637608">Light Authentication with NodeJS, express and external provider</a> was originally published in <a href="https://itnext.io/">ITNEXT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React-redux, the one with the hooks]]></title>
            <link>https://medium.com/@yarindeoh/react-redux-the-one-with-the-hooks-502f5111a17?source=rss-cc8fa2b8ed4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/502f5111a17</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[react-redux]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[redux]]></category>
            <dc:creator><![CDATA[Yarin Dekel]]></dc:creator>
            <pubDate>Sun, 02 Jun 2019 14:12:57 GMT</pubDate>
            <atom:updated>2019-06-18T00:40:54.113Z</atom:updated>
            <content:encoded><![CDATA[<h4>Using Redux? Using Hooks? it’s time to test react-redux hooks</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eNikHbzNdtuxZfOX7ccShg.png" /></figure><p>If you’re here, you’ve probably heard about React v16.8 that launched a new approach of creating components and maintaining its life cycle using hooks (<a href="https://reactjs.org/docs/hooks-intro.html">check out the API</a>).</p><p>Although hooks are <a href="https://reactjs.org/docs/hooks-intro.html#no-breaking-changes">backwards-compatible</a>, it’s a very exciting to start using them in our apps, and the good news is that redux hooks joined the party!</p><p>With a fashionably delay, react-redux published an <strong>new </strong>version (<a href="https://github.com/reduxjs/react-redux/releases/tag/v7.1.0">v7.1.0</a>) that offers a set of ‘redux hooks’ API with an alternative to the existing connect()Higher Order Component that allows our functional components to subscribe and communicate with redux store.</p><p>The changes of react hooks and react-redux hooks are leading to potential structure changes in the way we write and organize our code, and the way we treat and think about out logic structure.</p><p>In the following blog I will try to simplify the use of the new redux hooks using a short brief on the API, a structure suggestion and a basic example.</p><h4>react-redux hooks quick overview</h4><p><strong>useSelector(selector: state =&gt; {}, [equalityFn?: () =&gt; {}])</strong> extracts values from the redux store state, essentially similar tomapStateToProps function implemented in a hook, with some small differences. The selector will be run whenever the function component renders, it will also run the selector whenever an action is dispatched to redux store. The default equalityFn is a reference equality ( === ) which means that when an action will be dispatched, the selector will force a re render if one of the fields has changed which is a different from mapState. If you wish to keep mapState behavior, import shallowEqual and pass it as a second param or use a memoized library such as <a href="https://github.com/reduxjs/reselect">reselect</a>.</p><p><strong>useDispatch() </strong>returns a Dispatch function that allows us to dispatch actions to redux store (same API as <a href="https://github.com/facebookincubator/redux-react-hook#usedispatch">react-redux-hooks</a>) similar to mapDispatchToProps . In order to avoid unnecessary renders of child component when references are changing, it’s recommended to memorize it using useCallback .</p><p><strong>useStore() </strong>not a common hook that returns a reference to the same Redux store that was passed in to the &lt;Provider&gt; component.</p><blockquote>Don’t skip redux hooks full API documentation <a href="https://react-redux.js.org/next/api/hooks#hooks">https://react-redux.js.org/next/api/hooks#hooks</a>.</blockquote><h4>Changing the structure</h4><p>In the old world (in redux terms), we used to think about our structure as a molecular model. ‘Components’ are the atoms, stateless functional components and ‘Containers’ are the molecules, stateful and connected component with their own life cycle and subscription to redux store. Now we have one way of creating components which changes the way we think about the structure, should we still divide to components and containers? this is a good question.</p><p>Previously, in large applications, having a container with large list of extracted redux store props and action dispatchers, led to a structure where the view and it’s connected redux store methods were separated:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/371/1*Vhy4uxXEFDxKTrRDAFiCww.png" /><figcaption>TodoList.js is wrapping TodoListView.js with connect() HOC and redux method APIs</figcaption></figure><p>When facing the same scale issue of a container with a lot of hooks and logic, it may look overloaded and not organized. My new approach is to divide the container to a separate hook file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/342/1*mbRETc7A2XUlZqnc4EQDpQ.png" /><figcaption>TodoListHooks.js will contain redux hooks and container’s custom hooks.</figcaption></figure><h3>Basic example</h3><p>Although we are so tired of the famous Todo List example, I still think it would be the clearer and simpler scenario for understanding the new react-redux world.</p><blockquote><strong>Disclaimer </strong>Todo List original code was taken from <a href="https://redux.js.org/basics/example">redux documentations</a>. Below example contains structure changes, hooks refactor and memoized redux state using reselect.</blockquote><p>Todo list app allows users to create new todo items, complete them, displaying and filtering their statuses.</p><p>TodoList is the ‘container’ that renders the addTodo row, todo items and a filter row of ‘completed’, ‘all’ and ‘active’ statuses.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/38a426a8c52242becfc655d3f0e2c7b8/href">https://medium.com/media/38a426a8c52242becfc655d3f0e2c7b8/href</a></iframe><p>Add todo row will get an ‘addTodo’ callback from custom useTodo hook that dispatch an add todo action to redux store whenever you are submitting a todo item.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/08b0adcd0fcd9532d14df4c9984fba16/href">https://medium.com/media/08b0adcd0fcd9532d14df4c9984fba16/href</a></iframe><p>TodoItems displays the extracted object from redux store. Each todo item receives an onclick function that dispatches a changed status action to redux store.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cddb4fd28c993b3a6cb4001d362d6229/href">https://medium.com/media/cddb4fd28c993b3a6cb4001d362d6229/href</a></iframe><p>Filter row provide the ability to filter todo items based on their statuses. The selected filter is being extracted from redux store and the onclick callback is dispatching a filtering action to redux store.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4e66147e709b1a98db2431f3dc353bed/href">https://medium.com/media/4e66147e709b1a98db2431f3dc353bed/href</a></iframe><p>Hooks file contains redux hooks implementation wrapping by custom hooks for each ‘connected’ component. useSelector receives a memoized selector using reselect.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5959e3aa899eef7dffc8e5c44266011d/href">https://medium.com/media/5959e3aa899eef7dffc8e5c44266011d/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a55e69554766b035e7d6cdbe9b1fcdba/href">https://medium.com/media/a55e69554766b035e7d6cdbe9b1fcdba/href</a></iframe><p>Full example can be found in my repo: <a href="https://github.com/yarindeoh/react-redux-alpha">https://github.com/yarindeoh/react-redux-alpha</a></p><h3>Summary</h3><p>The combination of React Context API and useReducer() created a hype and a new set of opinions that state management libraries such as Redux can be avoided. I still can’t give up their awesome debugging capabilities, organized structure, concepts and ecosystem.</p><p>react-redux new hooks are simple to use! Personally, I’ve been waiting for hook’s release to start new projects at work and I had the chance to track react-redux contributors decisions and improvements along the way. It’s API is dynamically changing based on our community feedback which is very powerful. Keep tracking their releases, follow them on twitter and may the force be with us.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/0*L6YRZUeRo6-jIIeW.jpg" /></figure><p><strong>Follow me on twitter </strong><a href="https://twitter.com/DekelYarin"><strong>@DekelYarin</strong></a></p><figure><a href="https://usejournal.com/?utm_source=medium.com&amp;utm_medium=noteworthy_blog&amp;utm_campaign=tech&amp;utm_content=guest_post_image"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PYxBP_WV7LI6zc-zdUkNqQ.png" /></a></figure><p>📝 Read this story later in <a href="https://blog.usejournal.com/r/?url=https%3A%2F%2Fusejournal.com%2F%3Futm_source%3Dmedium.com%26utm_medium%3Dnoteworthy_blog%26utm_campaign%3Dtech%26utm_content%3Dguest_post_read_later_text">Journal</a>.</p><p>👩‍💻 Wake up every Sunday morning to the week’s most noteworthy stories in Tech waiting in your inbox. <a href="https://blog.usejournal.com/r/?url=https%3A%2F%2Fusejournal.com%2Fnewsletter%2Fnoteworthy-in-tech%2F%3Futm_source%3Dmedium.com%26utm_medium%3Dnoteworthy_blog%26utm_campaign%3Dtech%26utm_content%3Dguest_post_text">Read the Noteworthy in Tech newsletter</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=502f5111a17" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>