<?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 Aaron Janes on Medium]]></title>
        <description><![CDATA[Stories by Aaron Janes on Medium]]></description>
        <link>https://medium.com/@aaron-janes?source=rss-e8141289aeaf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*KsPB8e3BKgfgJYpC8RjsUg@2x.jpeg</url>
            <title>Stories by Aaron Janes on Medium</title>
            <link>https://medium.com/@aaron-janes?source=rss-e8141289aeaf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 13:21:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aaron-janes/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[Here is an easy way to solve, complex SaaS problems.]]></title>
            <link>https://aaron-janes.medium.com/architecting-success-the-power-of-decomposition-in-saas-leadership-30f7bb7bbff1?source=rss-e8141289aeaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/30f7bb7bbff1</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Aaron Janes]]></dc:creator>
            <pubDate>Sat, 10 Feb 2024 17:08:22 GMT</pubDate>
            <atom:updated>2024-02-13T02:55:45.751Z</atom:updated>
            <content:encoded><![CDATA[<p>Do you want a a clearer path to innovation and market success?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fKCB0rZ18ZMN26-kEPCE7A.png" /></figure><p>In the fast-paced world of SaaS, where agility and innovation are key, understanding the art of breaking down complex software projects into manageable components is not just technical — it’s strategic. This principle, known as decomposition, is at the core of efficient software development and product innovation.</p><p>For us as leaders, the ability to conceptualize the end-to-end system and then methodically deconstruct it into functional units is crucial. It’s about turning visionary ideas into tangible, market-ready solutions. The clearer we are in mapping out each part of the system, the more streamlined the development process becomes, leading to faster delivery and quicker market response.</p><p>The challenge often lies not in the execution but in our depth of understanding. The more intimately we know the problem architecture the easier we can deliver solutions that provide true value.</p><p>Consider this approach as laying the foundation for a building where every brick is essential for stability and functionality. Each component of our software should be crafted with the final structure in mind, ensuring that we not only build robust systems but also maintain flexibility for scaling and evolving with market demands.</p><p>For us, it’s about more than just development; it’s about constructing a competitive edge through strategic software design and delivery.</p><p><em>“We who cut mere stones must always be envisioning cathedrals”</em></p><p>If you found this perspective enlightening, I invite you to share your thoughts and experiences in the comments. Let’s discuss how strategic decomposition has influenced your projects and strategies. And for more insights into mastering SaaS innovation, consider following.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30f7bb7bbff1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tech Lead Insights: 7 Essential Coding Habits You Might Be Overlooking]]></title>
            <link>https://aaron-janes.medium.com/tech-lead-insights-7-essential-coding-habits-you-might-be-overlooking-c193d77b4c26?source=rss-e8141289aeaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/c193d77b4c26</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Aaron Janes]]></dc:creator>
            <pubDate>Thu, 08 Feb 2024 04:16:56 GMT</pubDate>
            <atom:updated>2024-02-08T04:16:56.596Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i1zJimhUbdC17Q7x2L73cA.png" /></figure><p>As software developers progress in their careers, the focus shifts from merely writing functional code to crafting efficient, maintainable, and scalable solutions. Here are seven refined strategies to help you, elevate your coding practices:</p><p><strong>1.Master the Art of Naming</strong></p><p>Choosing clear, descriptive, and unambiguous names goes beyond basic readability. It’s about embedding the essence of an entity’s purpose and functionality within its name. A real-world example: Instead of getUserData(), a more descriptive alternative could be fetchAuthenticatedUserProfile(). This not only clarifies the action performed but also the context and expected outcome.</p><p><strong>2. Embrace Single Responsibility in Functions</strong></p><p>A function should be a testament to elegance and focus, performing one task with precision. This principle is the cornerstone of modular design, facilitating easier testing, debugging, and comprehension. For instance, if a function is validating input and then processing data, split it. Create one function for validation (validateUserInput()) and another for processing (processUserData()). This separation enhances modularity and reusability.</p><p><strong>3. Champion the DRY Principle</strong></p><p>Adherence to “Don’t Repeat Yourself” not only prevents redundancy but also fosters a single source of truth. When you find yourself copying and pasting code, it’s a cue to abstract this logic into a reusable component. Imagine a piece of logic that formats date objects scattered across your codebase. Refactoring this into a single function like formatDateToUserLocale() can save countless hours in future debugging and refactoring.</p><p><strong>4. Prioritize Robust Error Handling</strong></p><p>Effective error handling is the hallmark of resilient software. It’s not just about catching errors but also about foreseeing potential fail points and mitigating them proactively. Implement comprehensive error handling early in the development process to ensure your application can gracefully manage unexpected situations, enhancing reliability and user experience. Further, let’s handle the errors early in your code. It will make your code more readable and your returns faster as you won’t run unnecessary code.</p><p><strong>5. Simplify for Maintainability</strong></p><p>Complexity is the arch-nemesis of maintainability. Strive for simplicity in your code, making it straightforward and intuitive. Use design patterns judiciously to solve common problems in a structured and familiar way. Just because you can write it in one line doesn’t mean you need to. Making your code maintainable and readable will serve you better in the long term. As there will be a less desire by the next developer to refactor your code to improve it or have to open it up to debug it in the future. Remember, the most elegant solutions are often the simplest.</p><p><strong>6. Refactor with Intent</strong></p><p>Refactoring is an art form that involves critically evaluating and improving existing code without altering its external behaviour. It’s about enhancing the internal structure and design. Post-feature completion, review your code with a fresh perspective, asking, “How can I make this more efficient and understandable?” The key is a mindset geared towards continuous improvement.</p><p><strong>7. Comment Wisely</strong></p><p>Comments should not explain “what” the code does but “why” it does it. They are the narrative that can’t be expressed through code alone, explaining the rationale behind complex decisions or clarifying intricate algorithms. Use comments to tell the story of your code, but let the code itself be as self-explanatory as possible through clear structure and naming conventions. For example, if you have to write a comment to explain what a function does, I suggest you need a better name for your function.</p><h3>Elevating Your Code Beyond Basics</h3><p>To further enhance your skills, immerse yourself in code reviews, both as a reviewer and a reviewee. This practice not only sharpens your coding abilities but also fosters a collaborative culture of learning and knowledge sharing. Additionally, keep abreast of the latest trends, tools, and best practices in software development through continuous learning. Platforms like GitHub, Stack Overflow, and coding blogs are treasure troves of knowledge and community wisdom.</p><p>Remember, the journey to mastering coding is ongoing and ever-evolving. Each line of code is an opportunity to learn, improve, and innovate. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c193d77b4c26" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Open Graph Magic: Transform Your Links into Click Magnets with This Simple Guide]]></title>
            <link>https://aaron-janes.medium.com/open-graph-magic-transform-your-links-into-click-magnets-with-this-simple-guide-04769be8c073?source=rss-e8141289aeaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/04769be8c073</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[seo]]></category>
            <category><![CDATA[marketing]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Aaron Janes]]></dc:creator>
            <pubDate>Sun, 07 Jan 2024 21:31:49 GMT</pubDate>
            <atom:updated>2024-01-07T21:39:47.766Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QIQJme-yK9q4H_VNL7TfCQ.png" /></figure><p>As a technical lead developer, business owner and tech enthusiast, I see a lot of links. Some have unique, rich, super engaging content; others flop and have no content. Ever wonder why that is?</p><p>In 2010,Meta (formally Facebook) created a protocol called Open Graph.<br>These tags enable any web page to have the same functionality as a Facebook Page. They allow for the specification of metadata that provides information about the ppage&#39;scontent, such as the title, type, URL, image, and description, when a web page is shared on social networks like Facebook or LinkedIn or over instant messaging services like Slack or Teams, ensuring that the link preview displays the content in a more appealing and informative way.</p><p>You can take your links from this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OA3yW73J4ZVa0SYTCRtxlg.png" /><figcaption>So boring .</figcaption></figure><p>To something like this from my company&#39;s website <a href="https://ignitewebdesign.ca/">here</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*52RcTprkT4SeO23jzjQqCg.png" /></figure><p>Okay, so we all want our links and projects to get clicks, so how can we get this working in our own projects?</p><p>Just add this HTML markup to the head of your HTML document. This will work in react or vanilla HTML I’ll Show you how to do it in Next.js 14 in a min</p><p>Make sure to swap out my info for yours in the content sections. <br>And a quick note on the image path. They need to be absolute paths for your images to show up.</p><pre>&lt;title&gt;Ignite Web Design&lt;/title&gt;<br>&lt;meta name=&quot;description&quot; content=&quot;Providing end-to-end support to grow your business online&quot;/&gt;<br>&lt;meta property=&quot;og:title&quot; content=&quot;Ignite Web Design&quot;/&gt;<br>&lt;meta property=&quot;og:description&quot; content=&quot;Providing end-to-end support to grow your business online&quot;/&gt;<br>&lt;meta property=&quot;og:url&quot; content=&quot;https://ignitewebdesign.ca/&quot;/&gt;<br>&lt;meta property=&quot;og:image:type&quot; content=&quot;image/png&quot;/&gt;<br>&lt;meta property=&quot;og:image:width&quot; content=&quot;1200&quot;/&gt;<br>&lt;meta property=&quot;og:image:height&quot; content=&quot;600&quot;/&gt;<br>&lt;meta property=&quot;og:image&quot; content=&quot;https://ignitewebdesign.ca/opengraph-image.png?457b41e20bfc6c97&quot;/&gt;<br>&lt;meta property=&quot;og:type&quot; content=&quot;website&quot;/&gt;<br><br>&lt;meta name=&quot;twitter:card&quot; content=&quot;summary_large_image&quot;/&gt;<br>&lt;meta name=&quot;twitter:title&quot; content=&quot;Ignite Web Design&quot;/&gt;<br>&lt;meta name=&quot;twitter:description&quot; content=&quot;Providing end-to-end support to grow your business online&quot;/&gt;<br>&lt;meta name=&quot;twitter:image:type&quot; content=&quot;image/png&quot;/&gt;<br>&lt;meta name=&quot;twitter:image:width&quot; content=&quot;1200&quot;/&gt;<br>&lt;meta name=&quot;twitter:image:height&quot; content=&quot;600&quot;/&gt;<br>&lt;meta name=&quot;twitter:image&quot; content=&quot;https://ignitewebdesign.ca/twitter-image.png?457b41e20bfc6c97&quot;/&gt;</pre><p>One more thing to remember while you are developing your next big thing. It is your favicon. That’s the little icon in your browser tab. You will also want to update that to get that polished look.<br>Here the HTML mark for that as well</p><pre>&lt;link rel=&quot;icon&quot; href=&quot;/favicon.ico&quot; type=&quot;image/x-icon&quot; sizes=&quot;16x16&quot;/&gt;</pre><p>You will want to add an icon to your project and name it favicon and again make sure you have the path correct. This one does not have to be an absolute path</p><p>If you enjoyed this article make sure to give me a follow.</p><p>Happy coding.</p><p>PS.</p><p>If you want to achieve this in Next.js 14 using the app router. Just add this to your main layout.js file or the layout in your route and make each page dynamic</p><pre>export const metadata = {<br>  metadataBase: new URL(&#39;https://ignitewebdesign.ca&#39;),<br>  title: &#39;Ignite Web Design&#39;,<br>  description: &#39;Providing end-to-end support to grow your business online&#39;,<br>  openGraph: {<br>    url: &#39;https://ignitewebdesign.ca&#39;,<br>    type: &#39;website&#39;,<br>    title: &#39;Ignite Web Design&#39;,<br>    description: &#39;Providing end-to-end support to grow your business online&#39;,<br>  },<br>  // Including Facebook (Open Graph) metadata<br>  facebook: {<br>    url: &#39;https://ignitewebdesign.ca/&#39;,<br>    type: &#39;website&#39;,<br>    title: &#39;Ignite Web Design&#39;,<br>    description: &#39;Providing end-to-end support to grow your business online&#39;,<br>  },<br>  twitter: {<br>    card: &#39;summary_large_image&#39;,<br>    url: &#39;https://ignitewebdesign.ca/&#39;,<br>    title: &#39;Ignite Web Design&#39;,<br>    description: &#39;Providing end-to-end support to grow your business online&#39;,<br>  },<br>  linkedIn: {<br>    url: &#39;https://ignitewebdesign.ca/&#39;,<br>    title: &#39;Ignite Web Design&#39;,<br>    description: &#39;Providing end-to-end support to grow your business online&#39;,<br>  },<br>};</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=04769be8c073" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Embracing the Future: The Advantages of Micro Frontends in Modern Web Development]]></title>
            <link>https://aaron-janes.medium.com/embracing-the-future-the-advantages-of-micro-frontends-in-modern-web-development-c9014ed4a9b0?source=rss-e8141289aeaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9014ed4a9b0</guid>
            <category><![CDATA[technology-trends]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Aaron Janes]]></dc:creator>
            <pubDate>Tue, 12 Dec 2023 01:16:29 GMT</pubDate>
            <atom:updated>2023-12-12T01:40:13.779Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XRtlc8JKjNB-mv0GfQxoyw.png" /></figure><p>Micro frontends have emerged as a game-changing architectural pattern in the evolving web development landscape. Like their namesake microservices in backend development, micro frontends offer a new way to build, manage, and deploy parts of web applications. This approach significantly impacts scalability, team autonomy, and technology diversity.</p><p>This new architectural pattern offers numerous benefits for developers and businesses by enhancing their ability to scale, pivot, and meet ever-changing business needs. It opens up unprecedented opportunities for growth and flexibility in software development and deployment.</p><p>Let’s explore how micro frontends are reshaping our approach to web development. Here are the standout benefits that are making a real difference for developers and businesses alike:</p><p><strong>Agility in Market Responsiveness: The IKEA Case Study</strong></p><p>A significant benefit of micro frontends is their role in enhancing business agility, exemplified by companies like IKEA. Known for its innovative retail strategies, IKEA’s adoption of micro frontends, guided by Gustaf Nilsson[1] Kotte, showcases its innovative approach to web development. They have embraced a vertical monolith system split into self-contained units combining back and front, enhancing team efficiency and autonomy.<br>A crucial aspect of their strategy is using Edge Side Includes (ESI), enabling different teams to effectively manage web pages and fragments. This approach is evident in how product teams handle elements like product thumbnails, promoting efficiency and reusability across the platform.<br>Furthermore, IKEA’s diverse technology stack in frontend development underlines its adaptability. By not relying on a single framework and utilizing transclusion mechanisms, IKEA achieves flexibility and dynamic responses to market trends. This strategy simplifies their e-commerce management and accelerates adaptation to consumer needs, demonstrating the power of micro frontends in large-scale retail.</p><p><strong>Technological Flexibility: Evolving with Micro Frontends</strong></p><p>Micro frontends redefine technological adaptability in web development. This approach allows teams to independently select the most suitable technology stack for different application parts, free from the constraints of a single, overarching framework. Such flexibility is crucial for incorporating new technologies and practices, enabling a smoother transition without overhauling the entire front end. Reflecting on the shift from JQuery’s dominance to the present diversity, micro frontends offer a strategic ‘escape hatch’ for integrating newer modules seamlessly. This foresight prepares your codebase for future transitions, akin to evolving from JQuery to React and beyond.</p><p><strong>Enhanced Scalability</strong></p><p>Micro frontends excel in scalability. By breaking down the front end into smaller, more manageable parts, development teams can independently scale different application parts. This granular scalability is particularly beneficial for large-scale projects where different application sections may have varying requirements and user traffic patterns.</p><p><strong>Easier Upgrades and Experimentation</strong></p><p>With micro frontends, upgrading and experimenting with new features become more manageable. Teams can test new ideas and technologies in a small section of the application without risking the stability of the entire front end. This approach fosters innovation and continuous improvement</p><p><strong>Enhanced Resilience</strong></p><p>Micro frontends enhance the resilience of web applications. Since each micro frontend is independent, a failure in one part does not necessarily bring down the entire application. This isolation improves the overall stability and reliability of the web application.</p><p><strong>In conclusion</strong></p><p>Micro frontends represent a paradigm shift in web development, offering unparalleled scalability, autonomy, and technological flexibility benefits. This approach not only simplifies the development process but also enhances the adaptability of businesses to evolving market demands. Through real-world examples like IKEA, we see the practical application of this architecture in meeting and exceeding modern digital challenges. Micro frontends are more than just a trend; they are the future of efficient, responsive, and agile web application development.</p><p>[1] Gustaf Nilsson Kotte (2019). “Experiences Using Micro Frontends at IKEA.” InfoQ. [Online]. Available: <a href="https://www.infoq.com/news/2019/12/micro-frontends-ikea/">https://www.infoq.com/news/2019/12/micro-frontends-ikea/</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9014ed4a9b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let’s Encrypt SSL in Just 3 Lines of Code: A Step-by-Step Guide with Nginx on Linux AMI]]></title>
            <link>https://aaron-janes.medium.com/secure-your-amazon-ec2-instance-with-lets-encrypt-ssl-in-just-3-lines-of-code-a-step-by-step-b3fc99d11415?source=rss-e8141289aeaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3fc99d11415</guid>
            <category><![CDATA[amazon-ec2]]></category>
            <category><![CDATA[ssl-certificate]]></category>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[lets-encrypt]]></category>
            <dc:creator><![CDATA[Aaron Janes]]></dc:creator>
            <pubDate>Wed, 22 Feb 2023 15:09:16 GMT</pubDate>
            <atom:updated>2023-03-01T14:47:58.283Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-O10X7l72LZu94bRclVqaA.jpeg" /></figure><p>Setting up SSL does not have to be costly and complicated; this has been the fastest and easiest way to set up SSL for a new web server for me.</p><p>Amazon Linux AMIs come pre-packaged with python and pip, so this is extremely quick and easy <br>Step one:<br>SSH into the EC2 instance <br>Step two:<br>Install cert bot.</p><pre><br>sudo pip3 install certbot certbot-nginx</pre><p>Now that you have installed Certbot, we can configure our Nginx server with SSL. For your installation to be completed, your DNS records must be pointed at your EC2 instance <br>Step three:<br>Install the certificate</p><pre>sudo /usr/local/bin/certbot --nginx -d example.com -d www.example.com  --agree-tos -m your@email.com</pre><p>Now your server is configured with a free SSL cert for 90days</p><p>We can also automate the renewal</p><p>Step four:</p><pre>echo &quot;0 0,12 * * * root /opt/certbot/bin/python -c &#39;import random; import time; time.sleep(random.random() * 3600)&#39; &amp;&amp; sudo certbot renew -q&quot; | sudo tee -a /etc/crontab &gt; /dev/null</pre><p>As promised, three lines of code and you have working SSL certificates for your Nginx server<br>If you enjoyed this article, please make sure to clap and follow<br>your support is appreciated</p><p>Certbot Documentation:</p><p><a href="https://certbot.eff.org/instructions?ws=nginx&amp;os=pip">Certbot Instructions</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3fc99d11415" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlock the Power of Google Analytics 4 in Just 5 Minutes with Next.js and TypeScript (2023 Edition)]]></title>
            <link>https://aaron-janes.medium.com/unlock-the-power-of-google-analytics-4-in-just-5-minutes-with-next-js-and-typescript-2023-edition-4821f1aaa485?source=rss-e8141289aeaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/4821f1aaa485</guid>
            <category><![CDATA[web-analytics]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[google-analytics]]></category>
            <category><![CDATA[website-optimization]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Aaron Janes]]></dc:creator>
            <pubDate>Tue, 21 Feb 2023 13:01:21 GMT</pubDate>
            <atom:updated>2023-02-21T13:01:21.298Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8rTSDjvU1y2yduaH1P6-Ug.jpeg" /></figure><p>If you own a website, you know how important it is to track its performance and make data-driven decisions to improve its user experience and engagement. Google Analytics has been the go-to platform for website owners for over a decade, but with the new GA4, Google is taking website analytics to a whole new level. In this article, I will show you how to set up Google Analytics 4 in just five minutes using Next.js and TypeScript, so you can start taking advantage of the latest features and insights to optimize your website and grow your online business. So, fasten your seatbelt, and let’s dive into the future of website analytics with Google Analytics 4.</p><p>We won’t be installing any third-party packages to do this except for the types package from here</p><p>To Install the types</p><pre>npm install --save-dev @types/gtag.js</pre><p>Let’s declare a triple-slash directive for the types we added to the project. Create a index.d.ts in the root of your project and add this snippet to it</p><pre>/// &lt;reference types=&quot;gtag.js&quot; /&gt;<br>declare module &#39;gtag.js&#39;;</pre><p>An easy way to think of triple-slash-reference-types directives is as an import for declaration packages<br>if you want a deeper dive into this, check out the docs on this</p><p><a href="https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html#-reference-types-">Documentation - Triple-Slash Directives</a></p><p>we will now need to update our tsconfig.json file to include the following glob “ **/*.d.ts”</p><pre>&quot;include&quot;: [&quot;next-env.d.ts&quot;, &quot;**/*.ts&quot;, &quot;**/*.tsx&quot;, &quot;.next/types/**/*.ts&quot;, &quot;**/*.d.ts&quot;],</pre><p>I won’t be covering how to set up the GA4 account with google, but it’s relatively straightforward if you follow this guide</p><p><a href="https://support.google.com/analytics/answer/9304153?hl=en&amp;ref_topic=9303319">[GA4] Set up Analytics for a website and/or app</a></p><p>It only takes about 5 mins to set up today, and we will only focus on the code implementation. Just make sure to note down your GA-ID. It looks like this ‘G-XXXXXXXX</p><p>Now that you have a GA-ID lets add it to your projects .env file</p><p>like so:</p><pre>NEXT_PUBLIC_GA_ID=&quot;G-&lt;YOUR ID&gt;&quot;</pre><p>Let’s set up a lib folder to hold our helper functions. Create a lib folder in the root of your project and create a gtag.ts file in the folder. Add the following snippet to the file.</p><pre>export const GA_TRACKING_ID = process.env.NEXT_PUBLIC_GA_ID<br><br>/**<br> * This function is used to track page views.<br> * https://developers.google.com/analytics/devguides/collection/gtagjs/pages<br> * */<br>export const pageView = (url: URL) =&gt; {<br>  console.log(&#39;pageView&#39;, url)<br>  window.gtag(&#39;config&#39;, GA_TRACKING_ID, {<br>    page_path: url<br>  })<br><br>}<br><br>/**<br> * https://developers.google.com/analytics/devguides/collection/gtagjs/events<br> * If you want to track events, you can use the gtag.js event method.<br> * */<br>export const event = (action: Gtag.EventNames, { event_category, event_label, value }: Gtag.EventParams) =&gt; {<br>  window.gtag(&#39;event&#39;, action, {<br>    event_category,<br>    event_label,<br>    value<br>  })<br>}<br></pre><p>Now lets update the _app.tsx file with the following code. If you are not familiar with how to set up a _app.tsx file check out the Next.js documentation here</p><p><a href="https://nextjs.org/docs/advanced-features/custom-app">Advanced Features: Custom `App` | Next.js</a></p><pre>// add these imports <br>import { useRouter } from &#39;next/router&#39;<br>import { useEffect } from &#39;react&#39;<br>import * as gtag from &#39;../lib/gtag&#39; <br>  <br>export default function App({ Component, pageProps }: AppProps) {<br><br>// add this snippit <br>const router = useRouter()<br>  useEffect(() =&gt; {<br>    const handleRouteChange = (url) =&gt; {<br>      gtag.pageView(url)<br>    }<br>    router.events.on(&#39;routeChangeComplete&#39;, handleRouteChange)<br>    return () =&gt; {<br>      router.events.off(&#39;routeChangeComplete&#39;, handleRouteChange)<br>    }<br>  }, [router.events])<br>// end of snippit <br><br>return (<br>..... your code<br><br>)}</pre><p>Next will update the _document.tsx to load the GA4 script. If your not familiar with setting up a customer _document.tsx here is the documentation</p><pre>import { Head, Html, Main, NextScript } from &#39;next/document&#39;<br>import Script from &#39;next/script&#39;<br>import { GA_TRACKING_ID } from &#39;../lib/ga/gtag&#39;<br><br>export default function Document() {<br>  return (<br>    &lt;Html lang=&#39;en&#39;&gt;<br>      &lt;Head&gt;<br>        &lt;&gt;<br>          &lt;Script<br>            id={GA_TRACKING_ID}<br>            strategy=&#39;afterInteractive&#39;<br>            src={`https://www.googletagmanager.com/gtag/js?id=${GA_TRACKING_ID}`} <br>           /&gt;<br><br>          &lt;Script<br>          id={GA_TRACKING_ID}<br>          strategy=&#39;afterInteractive&#39;<br>          dangerouslySetInnerHTML={{<br>            __html: `<br>            window.dataLayer = window.dataLayer || [];<br>            function gtag(){dataLayer.push(arguments);}<br>            gtag(&#39;js&#39;, new Date());<br>            gtag(&#39;config&#39;, &#39;${GA_TRACKING_ID}&#39;, {<br>              page_path: window.location.pathname,<br>            });<br>          `<br>          }}<br>        /&gt;<br>        &lt;/&gt;<br>      &lt;/Head&gt;<br>      &lt;body className=&#39;bg-white text-black&#39;&gt;<br>      &lt;Main /&gt;<br>      &lt;NextScript /&gt;<br>      &lt;/body&gt;<br>    &lt;/Html&gt;<br>  )<br>}</pre><p>You can now track all your page views if everything is configured correctly. This data gets pushed via the window.data layer we have configured above. For a deeper dive, check out the documentation here</p><p><a href="https://developers.google.com/tag-platform/tag-manager/web/datalayer">The data layer | Google Tag Manager for Web | Google Developers</a></p><p>The data will take about 24–48 hours to populate the GA4 dashboard. Since we don’t want to wait for 24hrs to see if we have done things correctly, here is a bit of a hack Open your browser console up and type</p><pre>console.log(datalayer)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*uq3__q4w1qg1zbKd9JWS5Q.png" /></figure><p>You will be able to see the data you are pushing to the data layer</p><p>You probably only want to push data when you are in production, so let us modify the _document.tsx file to look like this</p><pre>import { Head, Html, Main, NextScript } from &#39;next/document&#39;<br>import Script from &#39;next/script&#39;<br>import { GA_TRACKING_ID } from &#39;../lib/ga/gtag&#39;<br><br>export default function Document() {<br>  return (<br>    &lt;Html lang=&#39;en&#39;&gt;<br>      &lt;Head&gt;<br>        {/*Conditionally render script only if in production */}<br>        {process.env.NODE_ENV === &#39;production&#39; &amp;&amp; (<br>          &lt;&gt;<br>            &lt;Script<br>              id={GA_TRACKING_ID}<br>              strategy=&#39;afterInteractive&#39;<br>              src={`https://www.googletagmanager.com/gtag/js?id=${GA_TRACKING_ID}`} <br>             /&gt;<br><br>            &lt;Script<br>            id={GA_TRACKING_ID}<br>            strategy=&#39;afterInteractive&#39;<br>            dangerouslySetInnerHTML={{<br>              __html: `<br>            window.dataLayer = window.dataLayer || [];<br>            function gtag(){dataLayer.push(arguments);}<br>            gtag(&#39;js&#39;, new Date());<br>            gtag(&#39;config&#39;, &#39;${GA_TRACKING_ID}&#39;, {<br>              page_path: window.location.pathname,<br>            });<br>          `<br>            }}<br>          /&gt;<br>          &lt;/&gt;<br>        )}<br>      &lt;/Head&gt;<br>      &lt;body&gt;<br>      &lt;Main /&gt;<br>      &lt;NextScript /&gt;<br>      &lt;/body&gt;<br>    &lt;/Html&gt;<br>  )<br>}</pre><p>In conclusion, setting up Google Analytics 4 with Next.js and TypeScript is essential for any website owner who wants to make data-driven decisions and optimize their online presence. With the straightforward approach outlined in this article, you can quickly set up the new GA4 and start tracking your website’s performance in real time. So, what are you waiting for? Take five minutes to set up Google Analytics 4, and unlock valuable insights into your website’s traffic, user behaviour, and more.</p><p>Thanks for reading my article on unlocking the power of Google Analytics 4 in just 5 minutes using Next.js and TypeScript! I hope you found it informative and useful. If you’re interested in learning more about website analytics, web development, and other tech-related topics, be sure to check out my blog.</p><p><a href="http://www.stackfails.io/">www.stackfails.io</a></p><p>Good luck, and happy tracking!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4821f1aaa485" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Effortlessly Elevate Your React Code with ESLint and Prettier: A Step-by-Step Guide for 2023]]></title>
            <link>https://aaron-janes.medium.com/effortlessly-elevate-your-react-code-with-eslint-and-prettier-a-step-by-step-guide-for-2023-b7cb065316fa?source=rss-e8141289aeaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7cb065316fa</guid>
            <category><![CDATA[eslint]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[prettier]]></category>
            <dc:creator><![CDATA[Aaron Janes]]></dc:creator>
            <pubDate>Sun, 19 Feb 2023 21:29:25 GMT</pubDate>
            <atom:updated>2023-02-19T22:13:18.152Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ANdtZ816FeMF3gkh8ZegkQ.jpeg" /></figure><p>There are a lot of older tutorials (Pre-Feb 2021) that have an outdated configuration file set up that no longer works.<br>Here is how to set up ESlint and Prettier like a boss in 2023</p><blockquote>The breaking change is listed here: <a href="https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md#version-800-2021-02-21">https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md#version-800-2021-02-21</a></blockquote><p>First off, if you don’t have a project, create one.</p><pre>npx create-react-app stackfailsapp &amp;&amp; cd stackfailsapp</pre><p>To configure ESlint.</p><pre>npm init @eslint/config</pre><p>The command above will start an automated process to configure your project, I will walk you through this below.</p><p>Select: “To check syntax, find problems and enforce code style.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*fRmgAUwsc8FtnHwyGdr6fQ.png" /></figure><p>Select: “JavaScript modules (import/export)”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*DInS7j53bTmjqlmsOhcT9Q.png" /></figure><p>Select: “React”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*nvnvzQCZpm6r3XXatj07cg.png" /></figure><p>Select: If you are using TypeScript, you can select “yes” we will select “no” for the tutorial</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*G3OL4aLlljDn7l_eLkNYAw.png" /></figure><p>Select: “Run code in browser.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*8rcxwVG_z6ImmFzr9MSceQ.png" /></figure><p>Select: “Use a popular style guide.” I prefer Airbnb</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*NqZwD38KCon_Rda-pbtKvA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/1*jvlLzvtcmyd_H6SJt7KmIQ.png" /></figure><p>Select: My preference here is JSON.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*NxHGKT777K2HCDNY4z34qQ.png" /></figure><p>Select: “yes” to install plugins. NPM is my preference here</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*nfDI_KqLUFQso0OJ87UeWg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*sJDEemt9Ecm3sopISAs7gA.png" /></figure><p>Once the install completes, your project will have a .eslintrc.json file in your project. We will update this config to extend from prettier by adding the “prettier” string to the extends code block in your .eslintrc.json file .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*bqiUkJykSYvlALgX9QR9lQ.png" /></figure><p>Now to install and configure prettier to work with ESlint in 2023</p><pre>npm install - save-dev eslint-config-prettier prettier</pre><p>Once that install is finished, it is time to create the prettier config file</p><p>Now create a .pretterrc.json file in the root of your project</p><p>Specifically that file will be on the same level as the .eslintrc.json file created earlier and add this snippet to the .pretterrc.json file</p><pre>{<br> &quot;semi&quot;: true,<br> &quot;tabWidth&quot;: 2,<br> &quot;printWidth&quot;: 100,<br> &quot;singleQuote&quot;: true,<br> &quot;trailingComma&quot;: &quot;all&quot;,<br> &quot;jsxSingleQuote&quot;: true,<br> &quot;bracketSpacing&quot;: true<br>}</pre><p>Now lets put this into action</p><p>In your package.json file, update your scripts to include this snippet.</p><pre>&quot;scripts&quot; :{<br>  &quot;lint&quot;: &quot;eslint src/**/*.{js,jsx}&quot;,<br>  &quot;lint:fix&quot;: &quot;eslint - fix src/**/*.{js,jsx,}&quot;,<br>  &quot;format&quot;: &quot;prettier - write src/**/*.{js,jsx,} - config .prettierrc.json&quot;<br>}</pre><blockquote>A note on the above snippet, you can add other file extensions to the config, such as .scss, .tsx etc, if your project is using them.</blockquote><p>Now you can run these from your command line <br>npm run &lt;command&gt;</p><pre>npm run lint:fix</pre><p>Here is the final .eslintrc.json file.</p><pre><br>{<br>  &quot;env&quot;: {<br>    &quot;browser&quot;: true,<br>    &quot;es2021&quot;: true,<br>      &quot;jest&quot;: true<br><br>  },<br>  &quot;extends&quot;: [<br>    &quot;plugin:react/recommended&quot;,<br>    &quot;airbnb&quot;,<br>    &quot;prettier&quot;<br>  ],<br>  &quot;overrides&quot;: [<br>  ],<br>  &quot;parserOptions&quot;: {<br>    &quot;ecmaVersion&quot;: &quot;latest&quot;,<br>    &quot;sourceType&quot;: &quot;module&quot;<br>  },<br>  &quot;plugins&quot;: [<br>    &quot;react&quot;<br>  ],<br>  &quot;rules&quot;: {<br>    &quot;react/react-in-jsx-scope&quot;: &quot;off&quot;<br>  }<br>}</pre><p>I have included jest in the env key to the config for handling the default tests in a react app. Since React 17, you no longer need to import React in each .jsx file, so I have added the rule to disable that check.</p><p>Here is the final .prettierrc.json file</p><pre>{<br>  &quot;semi&quot;: true,<br>  &quot;tabWidth&quot;: 2,<br>  &quot;printWidth&quot;: 100,<br>  &quot;singleQuote&quot;: true,<br>  &quot;trailingComma&quot;: &quot;all&quot;,<br>  &quot;jsxSingleQuote&quot;: true,<br>  &quot;bracketSpacing&quot;: true<br>}</pre><p>In summary, setting up ESLint and Prettier in your React project is a straightforward process that can significantly improve the quality of your code. Not only does it help catch potential errors and enforce coding standards, but it can also make collaboration with other developers more seamless. With the step-by-step guide and tips outlined in this article, you can easily integrate these tools into your React project and streamline your development workflow. So, if you found this article helpful, be sure to give it a round of applause, share it with your fellow developers, and follow for more useful content like this.</p><p><strong>Handy Reference documentation</strong></p><p>ESlint: <a href="https://eslint.org/docs/latest/rules/">https://eslint.org/docs/latest/rules/</a></p><p>Prettier: <a href="https://prettier.io/docs/en/index.html">https://prettier.io/docs/en/index.html</a></p><p>Looking for a fun and informative source for all things programming and development? Look no further than <a href="http://www.stackfails.io/">www.stackfails.io</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7cb065316fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beating Stress Back: Tips and Tricks for Finding Your Inner Zen]]></title>
            <link>https://aaron-janes.medium.com/beating-stress-back-tips-and-tricks-for-finding-your-inner-zen-3458071e7e87?source=rss-e8141289aeaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/3458071e7e87</guid>
            <category><![CDATA[mindfulness]]></category>
            <category><![CDATA[wellness]]></category>
            <category><![CDATA[stress-management]]></category>
            <category><![CDATA[self-care]]></category>
            <dc:creator><![CDATA[Aaron Janes]]></dc:creator>
            <pubDate>Thu, 16 Feb 2023 04:34:02 GMT</pubDate>
            <atom:updated>2023-02-16T04:34:02.327Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kHAsM6WwRBDcFCXMZTmnfA.jpeg" /></figure><p>Stress is a common problem that many people face on a daily basis, and it can have a negative impact on our physical and mental health. From work-related stress to relationship stress, financial stress, and everything in between, stress can be overwhelming and difficult to manage. Fortunately, there are a variety of techniques that you can use to beat stress back and find your inner zen. In this article, we’ll explore some effective stress management strategies that you can start using today. Whether you’re looking to reduce stress at work, improve your relationships, or feel more relaxed and centred in your daily life, these tips and tricks will help you find the peace and balance you’re looking for. Plus, by incorporating these strategies into your routine, you can improve your overall health and boost your productivity and performance at work. So, let’s dive in and discover how you can start beating stress back today!</p><p>Feeling overwhelmed, anxious, or just plain stressed out? Don’t worry; you are not alone. In today’s fast-paced world, it’s easy to feel like stress is taking over your life. But the good news is, you don’t have to let it. You can beat stress back and reclaim your life with the right tools and mindset. So, please take a deep breath, and let’s explore some strategies to control the pressure and find inner peace.</p><p>Stress is an unavoidable part of life, and it can affect us in many ways, both physically and mentally. While a certain amount of stress can motivate and help us achieve our goals, too much stress can harm our health and well-being. Managing stress is essential for leading a healthy and happy life. In this article, we will discuss some strategies for managing stress.</p><ol><li><strong>Identify the source of stress: </strong>The first step in managing stress is to identify the source of stress. It could be work-related stress, relationship stress, financial stress, or any other kind of stress. Once you’ve identified the source of stress, you can take steps to manage it.</li><li><strong>Develop a stress management plan:</strong> Your plan should be purpose-built and tailored to your specific needs and goals. Your plan could include exercise, meditation, deep breathing exercises, time management, or talking to a therapist. Find what works for you and make it a daily routine.</li><li><strong>Get enough sleep:</strong> Sleep is essential for managing stress. Lack of sleep can increase your stress levels, making it more challenging to manage stress effectively. Aim for seven to eight hours of sleep per night.</li><li><strong>Exercise regularly:</strong> Exercise is a great way to manage stress. It releases endorphins and natural mood boosters and can help you feel more relaxed and focused. Find an exercise routine that works for you and make it a daily routine. If this sounds daunting, start small even a 15 min walk outside or remembering to get up and stretch regularly during the day can work wonders.</li><li><strong>Practice mindfulness</strong>: Mindfulness is being present at the moment and focusing on your thoughts, feelings, and sensations. It can help you manage stress by bringing your attention to the present moment instead of worrying about the past or future. A queue for you to work on is, do you dwell on thoughts? Do things get stuck on repeat? Are you playing scenarios of what if in your head over and over? If so, take a good look at how to become more mindful.</li><li><strong>Take breaks:</strong> Taking breaks throughout the day can help you manage stress. Whether taking a walk, reading a book, or just taking a few deep breaths, taking breaks can help you recharge and refocus.</li><li><strong>Connect with others:</strong> Social support is essential for managing stress. Connecting with others can provide a sense of belonging and support and help you feel more resilient in the face of pressure.</li></ol><p>In conclusion, managing stress is essential for leading a healthy and happy life. By identifying the source of stress, developing a stress management plan, getting enough sleep, exercising regularly, practicing mindfulness, taking breaks, and connecting with others, you can effectively manage stress and lead a more fulfilling life. Remember to take care of yourself and seek help if you need it. You can manage stress and lead a happier, healthier life with the right tools and support.</p><p><strong>P.S. laughing helps too.</strong></p><p>Why did the programmer quit his job?</p><p>Because he couldn’t handle the stress — he kept trying to Ctrl + Z his way out of every problem!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3458071e7e87" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Transform Your Deployment Game: A Step-by-Step Guide to EC2 Instance Provisioning with…]]></title>
            <link>https://aaron-janes.medium.com/transform-your-deployment-game-a-step-by-step-guide-to-ec2-instance-provisioning-with-fa709c6f27e7?source=rss-e8141289aeaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa709c6f27e7</guid>
            <category><![CDATA[ec2-instance]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[sanityio]]></category>
            <category><![CDATA[continuous-integration]]></category>
            <category><![CDATA[cloudformation]]></category>
            <dc:creator><![CDATA[Aaron Janes]]></dc:creator>
            <pubDate>Sat, 11 Feb 2023 22:54:36 GMT</pubDate>
            <atom:updated>2023-02-13T00:42:59.132Z</atom:updated>
            <content:encoded><![CDATA[<h3>Transform Your Deployment Game: A Step-by-Step Guide to EC2 Instance Provisioning with CloudFormation and the Power of NextJS &amp; Sanity Stack</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i37dnj812PFb1QufWNnM6Q.jpeg" /></figure><p>What a week! Incredible how fast 2023 is going by.</p><p>For this tutorial, I will describe how you can maximize your deployment process by using a CloudFormation template</p><p>This is the same CloudFromation template I use to deploy my blog site <a href="http://www.stackfails.io/">www.stackfails.io.</a> The tech stack is Nextjs and sanity.io.</p><p><em>Side note; If you haven’t tried this Stack out yet it is a powerful combination of Next.js and sanity.io. You can achieve incredible Lighthouse scores like I did. So why wait? Embrace the latest technology and elevate your online presence today. Follow me on Medium and clap for this article to stay up to date with all my tips and tricks on boosting your blog’s performance!</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kV5OW9adEzYz5MHjicoZYw.png" /></figure><p>By the end of this tutorial, you will have a solid understanding of how to provision the CloudFormation template. This template will provision an EC2 instance with Nginx running a reverse proxy. In addition, we will set up the code deploy agent so that you can include this instance in your continuous integration (CI) and continuous delivery (CD) pipeline. (I will cover this in a future article). Also we will provision two security groups, one for SSH access and one for TCP connections on HTTP and HTTPS.</p><p>We will set up an AWS IAM ROLE for your instance to assume to connect to an S3 bucket to pull template files in. We will configure SSH Access for git hub( you can easily swap to bit bucket or another provider). Finally we will assign a predefined Elastic IP so your site will always stay up.</p><p>Before we dive in, let’s go over a few assumptions. Firstly, you should already have an AWS account and domain name.</p><p>Secondly, your code should be hosted on a service such as GitHub or Bitbucket. Thirdly, you will have to create an elastic IP address for the EC2 instance we will make. If you need to learn how to do it, check out this link<strong> </strong>from AWS on how to create one.</p><p><a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html#eip-basics">Elastic IP addresses</a></p><p>Once you have completed your Elastic IP, take note of the Allocation ID, as we will need it for the CloudFormation template and the ALIAS record you will create with your DNS provider.</p><p>I am not going to touch on how to create an ALIAS record as it varies from provider to provider, but if you’re wondering what an ALIAS record is and why you should use one with AWS, make sure to check out this article I wrote here:</p><p><a href="https://aaron-janes.medium.com/are-you-using-route53-with-cname-or-alias-records-to-route-dns-requests-in-your-organization-56166ded5cd4">Are you using Route53 with CNAME or Alias records to route DNS requests in your organization?</a></p><p>With AWS, managing parameters is easy. Go to the AWS Console and navigate to the Parameter Store. In this tutorial, we will need to create two parameters to store your SSH key for automated GitHub access and your .env values that will be injected into the build via the {{resolve:ssm:ssh-key}} syntax in the CloudFormation template.</p><p>If you have never used AWS Parameter Store before check out the documentation here:</p><p><a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-parameter-store.html">AWS Systems Manager Parameter Store</a></p><p><strong><em>One word of note; </em></strong><em>AWS has a newer service called AWS Secrets Manager. Which they do recommend using now over the parameter store. One significant benefit of Secrets manager over the parameter store is it can automate the rotation of passwords. These parameters are very static so the parameter store will be fine in this case.</em></p><p><strong><em>Now for the magic!</em></strong></p><p><strong>Here is the template which will turn you into a Dev Ops guru. All joking aside, this is going to make your life easier.</strong></p><pre>AWSTemplateFormatVersion: &quot;2010-09-09&quot;<br>Description:<br>  Deploy any node based app to an Nginx server in minutes ,<br>  This templates creates a instance with code deploy agent for use with a code deploy pipeline<br>  ec2 server is configured with node 16 and git.<br>  www.StackFails.io Aaron Janes<br><br>Parameters:<br>  #  Will retrieve the latest linux AMI<br>  LatestAmiId:<br>    Type: &#39;AWS::SSM::Parameter::Value&lt;AWS::EC2::Image::Id&gt;&#39;<br>    Default: &#39;/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2&#39;<br>  SiteName:<br>    Description: Url of the site provide the apex and the www value<br>    Type: String<br>    Default: &quot;stackfails.io www.stackfails.io&quot;<br>    MinLength: 1<br>  MyS3BucketName:<br>    Description: Name of an existing S3 bucket to download template files from. Not required<br>    Type: String<br>    Default: &quot; &quot;<br>  ElasticIPAddress:<br>    Description: The allocation Id of the EIP you created<br>    Type: String<br>    Default: &quot;Your EIP&quot;<br>    MinLength: 1<br>  GitCloneLink:<br>    Description: Provide the clone link for your version controlled repo<br>    Type: String<br>    Default: &quot;git@github.com:username/your-repo-folder.git&quot;<br>    MinLength: 1<br>  RepoFolderName:<br>    Description: The name of the folder your app clones into<br>    Type: String<br>    Default: &quot;your-repo-folder&quot;<br>    MinLength: 1<br>  KeyName:<br>    Description: The name of your ssh key pem file to ssh to your instance<br>    Type: String<br>    Default: &quot;Your ssh.pem file&quot;<br>    MinLength: 1<br>Resources:<br>  Webserver:<br>    Type: AWS::EC2::Instance<br>    Metadata:<br>      Comment: Basic Nginx Server Setup<br>      AWS::CloudFormation::Init:<br>        config:<br>          packages:<br>            yum:<br>              ruby: [ ]<br>              wget: [ ]<br>              git: [ ]<br>          files:<br>            # Configure the reverse proxy for the site domain<br>            # ideally this will come from the S3 bucket, but it is here to highlight the base config<br>            /etc/nginx/conf.d/stackfails.conf:<br>              content: !Sub |<br>                server {<br>                  client_max_body_size 64M;<br>                  listen 80;<br>                  server_name  ${SiteName};<br>                     location / {<br>                        proxy_pass             http://127.0.0.1:3000;<br>                        proxy_read_timeout     60;<br>                        proxy_connect_timeout  60;<br>                        proxy_redirect         off;<br>                       }<br>                    }<br><br>            &quot;/etc/cfn/cfn-hup.conf&quot;:<br>              content:<br>                !Sub |<br>                [main]<br>                stack=${AWS::StackId}<br>                region=${AWS::Region}<br>                mode: &quot;000400&quot;<br>                owner: &quot;root&quot;<br>                group: &quot;root&quot;<br>            &quot;/etc/cfn/hooks.d/cfn-auto-reloader.conf&quot;:<br>              content: !Sub |<br>                [cfn-auto-reloader-hook]<br>                triggers=post.update<br>                path=Resources.WebServerHost.Metadata.AWS::CloudFormation::Init<br>                action=/opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource WebServerHost --region ${AWS::Region}<br>              mode: &quot;000400&quot;<br>              owner: &quot;root&quot;<br>              group: &quot;root&quot;<br><br>          commands:<br>              # Add your ssh key from AWS SSM to your instance<br>            00-create-ssh-key:<br>              command: !Sub |<br>                touch ~/.ssh/id_rsa<br>                echo &quot;{{resolve:ssm:ssh-key}}&quot; &gt;&gt; ~/.ssh/id_rsa<br>                chmod 700 ~/.ssh/<br>                chmod 600 ~/.ssh/id_rsa<br><br>            #Install code deploy agent so instance can be used by cd pipeline<br>            01-install-cd:<br>              command: !Sub |<br>                wget https://aws-codedeploy-${AWS::Region}.s3.amazonaws.com/latest/install<br>                chmod +x ./install<br>                ./install auto<br>                service codedeploy-agent status<br><br>            02-install-nginx:<br>              command: sudo amazon-linux-extras install nginx1 -y<br>            03-run-nginx:<br>              command: sudo service nginx start<br><br>              # Install node 16<br>            04-install-node:<br>              command: !Sub |<br>                curl --silent --location https://rpm.nodesource.com/setup_16.x | bash -<br>                yum -y install nodejs<br><br>              #Clone your app from git hub but can be configured to use any version control<br>            05-clone-app:<br>              command: !Sub |<br>                mkdir /var/webapp<br>                cd  /var/webapp<br>                ssh -o &quot;StrictHostKeyChecking=no&quot; git@github.com<br>                git clone ${GitCloneLink}<br><br>              # Add environment variables from aws SSM<br>            06-add-app-env:<br>              command: !Sub |<br>                cd /var/webapp/{RepoFolderName}<br>                touch .env<br>                echo &quot;{{resolve:ssm:stack-fail-env}}&quot; &gt;&gt; /var/webapp/${RepoFolderName}/.env<br>              #Install and build app<br>            07-install-start-app:<br>              command: !Sub |<br>                cd /var/webapp/${RepoFolderName}<br>                npm install <br>                npm run build<br>              # Set up a process manager https://pm2.keymetrics.io/docs/usage/quick-start/<br>            08-install-start-process-manager:<br>              command: !Sub |<br>                cd /var/webapp/${RepoFolderName}<br>                npm install -g pm2<br>                pm2 start npm --name &quot;${RepoFolderName}&quot; -- start<br>                pm2 startup<br>                pm2 save<br><br>          Services:<br>            sysvinit:<br>              codedeploy-agent:<br>                enabled: true<br>                ensureRunning: true<br>              nginx:<br>                enabled: true<br>                ensureRunning: true<br>                files:<br>                  - /etc/nginx/conf.d/stackfails.conf<br>              cfn-hup:<br>                enable: &#39;true&#39;<br>                ensureRunning: &#39;true&#39;<br>                files:<br>                  - &quot;/etc/cfn/cfn-hup.conf&quot;<br>                  - &quot;/etc/cfn/hooks.d/cfn-auto-reloader.conf&quot;<br><br>      # Define S3 access credentials<br>      AWS::CloudFormation::Authentication:<br>        S3AccessCreds:<br>          type: S3<br>          buckets:<br>            - !Sub ${MyS3BucketName}<br>          roleName: !Ref InstanceRole<br>    CreationPolicy:<br>      ResourceSignal:<br>        Timeout: PT15M<br>        Count: 1<br>    Properties:<br>      # Always use the latest Linux AMI<br>      ImageId: !Ref LatestAmiId<br>      AvailabilityZone: us-east-1a<br>      InstanceType: t2.small<br>      KeyName: !Ref KeyName<br>      SecurityGroups:<br>        - !Ref SSHSecurityGroup<br>        - !Ref ServerSecurityGroup<br>      UserData:<br>        Fn::Base64:<br>          !Sub |<br>          #!/bin/bash -xe<br>            # Get the latest CloudFormation helper scripts<br>            yum install -y aws-cfn-bootstrap<br>          <br>            # Start cfn-init<br>            /opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource Webserver --region ${AWS::Region}<br>          <br>            # cfn-init completed so signal success or not<br>            /opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource Webserver --region ${AWS::Region}<br>  InstanceRole:<br>    Type: AWS::IAM::Role<br>    Properties:<br>      AssumeRolePolicyDocument:<br>        Statement:<br>          - Action: &#39;sts:AssumeRole&#39;<br>            Principal:<br>              Service: ec2.amazonaws.com<br>            Effect: Allow<br>            Sid: &#39;&#39;<br>      Policies:<br>        - PolicyName: AuthenticatedS3GetObjects<br>          PolicyDocument:<br>            Version: 2012-10-17<br>            Statement:<br>              - Action:<br>                  - &#39;s3:GetObject&#39;<br>                Resource: !Sub &#39;arn:aws:s3:::${MyS3BucketName}/*&#39;<br>                Effect: Allow<br>  InstanceProfile:<br>    Type: AWS::IAM::InstanceProfile<br>    Properties:<br>      Path: /<br>      Roles:<br>        - !Ref InstanceRole<br>  SSHSecurityGroup:<br>    # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-security-group.html<br>    Type: AWS::EC2::SecurityGroup<br>    Properties:<br>      GroupDescription: Enable SSH access via port 22 you should limit the ip address<br>      SecurityGroupIngress:<br>        - IpProtocol: tcp<br>          FromPort: 22<br>          ToPort: 22<br>          CidrIp: 0.0.0.0/0<br>  ServerSecurityGroup:<br>    # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-security-group.html<br>    Type: AWS::EC2::SecurityGroup<br>    Properties:<br>      GroupDescription: Allow HTTP and HTTPS connections from specified CIDR ranges<br>      SecurityGroupIngress:<br>        - IpProtocol: tcp<br>          FromPort: 80<br>          ToPort: 80<br>          CidrIp: 0.0.0.0/0<br>        - IpProtocol: tcp<br>          FromPort: 443<br>          ToPort: 443<br>          CidrIp: 0.0.0.0/0<br><br><br>  EIPAssociation:<br>    Type: &quot;AWS::EC2::EIPAssociation&quot;<br>    Properties:<br>      AllocationId: !Ref ElasticIPAddress<br>      InstanceId: !Ref Webserver<br><br><br>Outputs:<br>  InstanceId:<br>    Description: The ID of the instance<br>    Value: !Ref Webserver<br>  PublicIP:<br>    Description: The public IP of the instance<br>    Value: !GetAtt Webserver.PublicIp<br>  PublicDNS:<br>    Description: The public DNS name of the instance<br>    Value: !GetAtt Webserver.PublicDnsName<br>  SecurityGroup:<br>    Description: The security group of the instance<br>    Value: !Ref ServerSecurityGroup<br>  SSHSecurityGroup:<br>    Description: The security group of the instance<br>    Value: !Ref SSHSecurityGroup</pre><p>Head to CloudFormation in the AWS console and click on create a stack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zuXUnuJoan9bYJpbfNnQdg.png" /></figure><p>Once the subsequent page loads, select:</p><p><em>The template is ready. Upload the template </em>from file and then click next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9kvW6Oeh36JJXRP56cddlQ.png" /></figure><p>Then enter your stack name and fill in the required parameters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vXFnb3x6C-xOnUqZ7rxXVQ.png" /></figure><p>I have set up the parameters to accept an S3 Bucket so that this template can access additional files. You can optimize the Nginx server configuration for production, and ideally you will download that from the S3 at run time. I have configured that feature of the CloudFormation stack for you, but it is beyond the scope of this Tutorial.</p><p>Click next after completing the form.</p><p>On the next screen, we will accept all the default values and click next and on the subsequent page, we will also take the default values.</p><p>Now your stack will run, create the desired resources, and launch your web app. Visit the URL you provided in the configuration to visit your newly deployed site.</p><p><strong>Here are a few tips:</strong></p><p>This template uses the cfn-init scripts to configure things. If you run into trouble, you can SSH into the instance and check the logs to see what has failed.</p><pre>sudo su<br>cat /var/log/cfn-init.log</pre><p>The logs will show you where the issue is in your configuration.</p><p>My next article will walk you through configuring HTTPS for this stack.</p><p>You can easily set up dev and staging environments now by configuring the branch that the CloudFormation template pulls from</p><p>In conclusion, setting up an EC2 instance with Nginx and CloudFormation is a great way to streamline your DevOps workflow and take your web applications to the next level. Following the steps outlined in this article, you can quickly and easily deploy a highly scalable and secure environment perfect for your next project.</p><p>If you found this article helpful, please hit the clap button and show your support. And if you are interested in learning more about DevOps and Front-end technology related topics, be sure to follow me on Medium for more great content.</p><p>Thank you for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa709c6f27e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlock the Power of React.memo: Learn to Optimize Your Components and Boost Your React Performance]]></title>
            <link>https://aaron-janes.medium.com/unlock-the-power-of-react-memo-learn-to-optimize-your-components-and-boost-your-react-performance-59d57a33ce65?source=rss-e8141289aeaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/59d57a33ce65</guid>
            <category><![CDATA[react-tips]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react-performance]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Aaron Janes]]></dc:creator>
            <pubDate>Sat, 04 Feb 2023 02:19:12 GMT</pubDate>
            <atom:updated>2023-02-04T17:00:43.422Z</atom:updated>
            <content:encoded><![CDATA[<p>A Practical Guide to Enhancing Your React Development Skills with React.memo</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g2JlQshysobmJaL9Fqb72A.jpeg" /></figure><p>Thank you for taking the time to read this article. As a token of our appreciation, we’d start things off with a bit of humour. Why did the React component break up with its significant other? Because it couldn’t handle the constant re-renders! Like the joke, React components can often be the source of frustration for developers, but with the proper knowledge and understanding, they can be tamed and optimized to run smoothly. In this article, we will discuss the common mistakes to watch out for when using React.memo.</p><p>React.memo is a powerful optimization tool in React, used to prevent unnecessary re-renders in functional components. However, like any tool, it’s essential to use it correctly to ensure it works as expected.</p><p>The basic premise of React.memo is to wrap functional components and make them “memoized.” Once completed, the component will only re-render if its props have changed, rather than re-rendering on every update.</p><p>React.memo can be helpful when you have a component that is not critical to the application’s functionality but has a potentially expensive render method. By wrapping the component with React.memo, you can improve the performance of your application by avoiding unnecessary re-renders. It is important to note that React.memo only shallowly compares props, so if your props contain complex data structures, you should pass a custom comparison function as the second argument to React.memo to ensure the correct comparison.</p><p>In general, you should use React.memo for pure components, meaning they only render based on their props and don’t have any internal state.</p><p>Here are some common mistakes to watch out for when using React.memo.</p><p><strong>Not Memoizing All the Right Components:</strong> React.memo only works for functional components, not class components. Also, it’s important to note that not all functional components should be memoized. Use React.memo for costly components to render and whose props are unlikely to change frequently. You may be wondering what makes a component expensive to render; a few examples are:</p><ul><li>Complex calculations: Components that perform complex calculations during rendering, such as large data sets or intensive mathematical operations — This calculation is probably best moved to a `useMemo` function more on this below</li><li>Deep component nesting: Components that are deeply nested, with many levels of child components, can be costly to render as each component must be processed</li><li>Unoptimized styles: Components with a large number of styles, especially styles that change frequently, can be costly to render as the browser must recalculate the layout and styles for the component</li></ul><p><strong>Memoizing Too Much: </strong>Using React.memo can result in poor performance, as it adds extra overhead to the component re-render process. If a component’s props are likely to change frequently, memoizing it may slow down your application. In these cases, it’s better to avoid React.memo and let React handle the re-rendering process as they designed it.</p><p><strong>Not Updating the Compare Function Properly:</strong> React.memo provides an optional second argument, which is a comparison function that allows you to determine when a component should re-render. If you miswrite the comparison function, it may prevent the element from re-rendering or re-render more then it should. Let us take a look at an example of using React.memo to compare a deeply nested object</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t5GRCr8QbGctZcit9_O2nQ.png" /></figure><p><strong>Understand the Limitations of React.memo:</strong> React.memo is not a silver bullet solution to all performance issues. It is only effective for preventing re-renders in components that receive a significant amount of props that are unlikely to change frequently. If your component’s state changes frequently or gets new props, React.memo may not be enough to prevent unnecessary re-renders.</p><blockquote>It is worth mentioning that React.memo is different from useMemo in React. The React hook useMemo, allows you to memoize a function’s result so that it only re-evaluates if one of its dependencies changes. <br>useMemo is another way to improve performance by avoiding expensive calculations on every render, and we will take an in-depth look at it in another article.</blockquote><p>In conclusion, React.memo is a great optimization tool for functional components in React, but it’s essential to use it correctly to ensure it works as expected. By avoiding these common mistakes, you can get the most out of React.memo and improve the performance of your application.</p><p>We hope this article has provided valuable insights and tips for optimizing your React components using React.memo. By avoiding common mistakes and understanding how to use React.memo effectively, you can take your React development skills to the next level and create fast and efficient applications. If you found this article helpful, please clap for it and follow us for more great content on React development and web technology. Thank you for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59d57a33ce65" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>