<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mitch Chimwemwe Chanza</title>
    <description>The latest articles on DEV Community by Mitch Chimwemwe Chanza (@mitch1009).</description>
    <link>https://dev.to/mitch1009</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F734068%2F9c0650b0-d400-44c3-aaba-d94f6e785591.png</url>
      <title>DEV Community: Mitch Chimwemwe Chanza</title>
      <link>https://dev.to/mitch1009</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mitch1009"/>
    <language>en</language>
    <item>
      <title>If CI/CD Pipelines Were Human: A Day in the Life</title>
      <dc:creator>Mitch Chimwemwe Chanza</dc:creator>
      <pubDate>Fri, 24 May 2024 09:53:33 +0000</pubDate>
      <link>https://dev.to/mitch1009/if-cicd-pipelines-were-human-a-day-in-the-life-47d</link>
      <guid>https://dev.to/mitch1009/if-cicd-pipelines-were-human-a-day-in-the-life-47d</guid>
      <description>&lt;p&gt;Imagine if Continuous Integration and Continuous Deployment (CI/CD) pipelines were human. This "person" would be the ultimate multitasker, an unsung hero of the software development world, working tirelessly behind the scenes to ensure that every piece of code is flawlessly integrated and deployed. Let’s explore a day in the life of our humanized CI/CD pipeline.&lt;/p&gt;

&lt;h3&gt;
  
  
  Early Morning: Rise and Shine
&lt;/h3&gt;

&lt;p&gt;Our CI/CD human wakes up early, ready to tackle the day. The first task is a quick review of overnight activities. This includes checking logs and ensuring that all automated tests ran smoothly. Just like a meticulous project manager, they assess the status of the build environment, verifying that everything is in tip-top shape for the day’s work.&lt;/p&gt;

&lt;h3&gt;
  
  
  Morning Routine: Code Integration
&lt;/h3&gt;

&lt;p&gt;With a fresh cup of coffee in hand, the CI/CD human dives into the morning routine: integrating new code changes. Developers from different parts of the world have submitted their code overnight, and it’s up to our CI/CD to merge these changes. They carefully review each commit, ensuring that there are no conflicts and that the new code aligns with the existing codebase. Any discrepancies are flagged and communicated back to the developers for quick resolution.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mid-Morning: Automated Testing
&lt;/h3&gt;

&lt;p&gt;By mid-morning, it’s time for automated testing. Like a diligent quality assurance specialist, our CI/CD human runs a series of tests on the integrated code. Unit tests, integration tests, and regression tests are all part of the repertoire. Each test is meticulously executed, and results are promptly analyzed. If any issues are found, the CI/CD human communicates with the relevant developers to get them fixed before the next deployment.&lt;/p&gt;

&lt;h3&gt;
  
  
  Lunchtime: Monitoring and Optimization
&lt;/h3&gt;

&lt;p&gt;During lunchtime, our CI/CD human takes a brief break but remains vigilant, constantly monitoring the health of the system. They review performance metrics and logs to identify any potential bottlenecks or areas for optimization. Just like a proactive engineer, they tweak configurations and make adjustments to ensure the pipeline runs efficiently.&lt;/p&gt;

&lt;h3&gt;
  
  
  Afternoon: Deployment Prep
&lt;/h3&gt;

&lt;p&gt;The afternoon is dedicated to deployment preparation. Our CI/CD human works like a seasoned operations manager, ensuring that the deployment environment is ready. They verify that all dependencies are in place, database migrations are prepared, and rollback plans are established in case anything goes awry. Communication with stakeholders is key, and our CI/CD human ensures that everyone is aware of the upcoming deployment.&lt;/p&gt;

&lt;h3&gt;
  
  
  Late Afternoon: The Big Deployment
&lt;/h3&gt;

&lt;p&gt;As the day progresses, it’s time for the big deployment. With the precision of a skilled technician, our CI/CD human orchestrates the deployment process. They push the code to production, monitoring every step to ensure a smooth transition. Any issues that arise are swiftly addressed, minimizing downtime and ensuring that end-users experience a seamless update.&lt;/p&gt;

&lt;h3&gt;
  
  
  Evening: Post-Deployment Checks
&lt;/h3&gt;

&lt;p&gt;After the deployment, our CI/CD human performs post-deployment checks, much like a quality control inspector. They verify that the new features are functioning as expected and that there are no critical bugs. They also gather feedback from users and developers, taking notes for future improvements.&lt;/p&gt;

&lt;h3&gt;
  
  
  Night: Maintenance and Learning
&lt;/h3&gt;

&lt;p&gt;As the day winds down, our CI/CD human engages in maintenance tasks. This includes cleaning up old builds, archiving logs, and preparing the pipeline for the next day. They also spend time learning about new tools and technologies, always looking to enhance their skills and improve the pipeline.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion: An Indispensable Ally
&lt;/h3&gt;

&lt;p&gt;In the world of software development, a CI/CD pipeline is an indispensable ally, tirelessly working to ensure that code is seamlessly integrated and deployed. If CI/CD pipelines were human, they would embody the qualities of a project manager, quality assurance specialist, engineer, operations manager, technician, and quality control inspector all rolled into one. Their dedication and efficiency would make them the unsung heroes, ensuring the success of every software project they touch.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Understanding React Custom Hooks: A beginer's guide</title>
      <dc:creator>Mitch Chimwemwe Chanza</dc:creator>
      <pubDate>Mon, 13 Nov 2023 15:29:36 +0000</pubDate>
      <link>https://dev.to/mitch1009/understanding-react-custom-hooks-a-beginers-guide-35io</link>
      <guid>https://dev.to/mitch1009/understanding-react-custom-hooks-a-beginers-guide-35io</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;before we begin lets grow my twitter population 😄 follow me &lt;a href="https://twitter.com/mitch_chanza"&gt;mitch_chanza&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;React hooks have become an integral part of modern React development, offering a way to manage stateful logic in functional components. While React provides several built-in hooks like useState and useEffect, creating custom hooks can further enhance code reusability and maintainability. In this blog, we'll explore the basics of custom React hooks, demystify their creation, and illustrate their practical use.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are React Hooks?
&lt;/h2&gt;

&lt;p&gt;React hooks are functions that allow you to use state and other React features in functional components. They were introduced in React 16.8 to enable functional components to manage state and side effects, which were previously exclusive to class components.&lt;/p&gt;

&lt;p&gt;The most common built-in hooks are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;useState:&lt;/strong&gt; Manages component state.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;useEffect:&lt;/strong&gt; Handles side effects in function components.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;useContext:&lt;/strong&gt; Accesses the value of a React context.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Why Custom Hooks?
&lt;/h2&gt;

&lt;p&gt;Custom hooks empower developers to encapsulate and reuse logic across different components. This can be particularly beneficial when dealing with complex state management, API calls, or any other shared functionality. By creating custom hooks, you can keep your code DRY (Don't Repeat Yourself) and make it more modular.&lt;/p&gt;

&lt;h2&gt;
  
  
  Anatomy of a Custom Hook
&lt;/h2&gt;

&lt;p&gt;A custom hook is just a JavaScript function whose name starts with "use." By convention, this naming signals to both React and other developers that the function is a hook and should be used with the &lt;code&gt;use&lt;/code&gt; keyword.&lt;/p&gt;

&lt;p&gt;Let's create a simple custom hook called &lt;code&gt;useCounter&lt;/code&gt; to manage a counter in our components.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// useCounter.js&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;useCounter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;initialValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;initialValue&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;increment&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;decrement&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;increment&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;decrement&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;useCounter&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, &lt;code&gt;useCounter&lt;/code&gt; initializes a state variable &lt;code&gt;count&lt;/code&gt; with an initial value (defaulting to 0) and provides functions to increment and decrement it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using the Custom Hook
&lt;/h2&gt;

&lt;p&gt;Now that we've created our custom hook, let's use it in a component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// CounterComponent.js&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;useCounter&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./useCounter&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;CounterComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;increment&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;decrement&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useCounter&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;Count&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;increment&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Increment&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;decrement&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Decrement&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;CounterComponent&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By calling &lt;code&gt;useCounter()&lt;/code&gt;, we get access to the state (&lt;code&gt;count&lt;/code&gt;) and functions (&lt;code&gt;increment&lt;/code&gt; and &lt;code&gt;decrement&lt;/code&gt;) returned by our custom hook.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rules of Hooks
&lt;/h2&gt;

&lt;p&gt;When creating custom hooks, it's crucial to follow the "Rules of Hooks":&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Only call hooks at the top level:&lt;/strong&gt; Don't call hooks inside loops, conditions, or nested functions. Always use them at the top level of your functional components.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Only call hooks from React functions:&lt;/strong&gt; Custom hooks should be called from functional components or other custom hooks, not from regular JavaScript functions.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Custom React hooks offer a powerful way to share logic between components and make your code more modular and maintainable. By creating custom hooks, you can encapsulate complex logic and promote reusability, enabling a more efficient and cleaner React codebase. Happy coding!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;ooh yeah about the pupulation, remember to follow me 😄  &lt;a href="https://twitter.com/mitch_chanza"&gt;mitch_chanza&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
    </item>
    <item>
      <title>5 tailwindcss utility classes to up your frontend game</title>
      <dc:creator>Mitch Chimwemwe Chanza</dc:creator>
      <pubDate>Mon, 13 Nov 2023 11:46:32 +0000</pubDate>
      <link>https://dev.to/mitch1009/5-tailwindcss-utility-classes-to-up-your-frontend-game-1dlp</link>
      <guid>https://dev.to/mitch1009/5-tailwindcss-utility-classes-to-up-your-frontend-game-1dlp</guid>
      <description>&lt;p&gt;Tailwind CSS is renowned for its simplicity and power in crafting elegant and responsive user interfaces. In this blog post, we'll delve into five indispensable Tailwind utility classes that will effortlessly enhance your frontend development workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. &lt;code&gt;space-x&lt;/code&gt; and &lt;code&gt;space-y&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Tailwind's &lt;code&gt;space-x&lt;/code&gt; and &lt;code&gt;space-y&lt;/code&gt; classes are your go-to for effortless spacing between child elements. Whether you're horizontally arranging buttons or vertically stacking cards, these classes provide a clean and consistent spacing solution.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- This will create horizontal space between child elements --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"space-x-4"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="c"&gt;&amp;lt;!-- Your horizontally spaced content here --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;&amp;lt;!-- This will create vertically space between child elements --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"space-y-6"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="c"&gt;&amp;lt;!-- Your vertically spaced content here --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These classes simplify layout management, creating a polished and visually pleasing design.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. &lt;code&gt;divide-y&lt;/code&gt; and &lt;code&gt;space-y&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Combine &lt;code&gt;divide-x&lt;/code&gt; for horizontal dividers and &lt;code&gt;space-y&lt;/code&gt; for vertical spacing, achieving a well-structured grid layout.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"divide-y space-y-4"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;" p-4"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    Lorem ipsum dolor sit amet consectetur adipisicing elit. Ducimus porro corporis eum eius voluptate omnis nesciunt exercitationem et inventore autem quis magni alias corrupti optio officia temporibus, ipsum neque magnam?
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;" p-4"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    Lorem ipsum dolor sit amet consectetur adipisicing elit. Ducimus porro corporis eum eius voluptate omnis nesciunt exercitationem et inventore autem quis magni alias corrupti optio officia temporibus, ipsum neque magnam?
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This combination is particularly handy when dealing with lists or grid-based components.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. &lt;code&gt;group&lt;/code&gt; and &lt;code&gt;group-hover&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;group&lt;/code&gt; class, coupled with &lt;code&gt;group-hover&lt;/code&gt;, adds an extra layer of interactivity. Apply these classes to a container, and styles defined within them will only activate on hover, creating a seamless user experience.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"group "&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!-- This will change the bg to green when hovered --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"group-hover:bg-green-200 transition"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!-- While this will be red when the entire group is hovered --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"group-hover:bg-red-200 transition"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is perfect for revealing additional information or highlighting elements on user interaction.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. &lt;code&gt;hover&lt;/code&gt; and &lt;code&gt;scale&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;scale&lt;/code&gt; class provides a straightforward way to add scaling effects to an element. Whether you want to emphasize an image or create a zoom-in effect on a button, &lt;code&gt;scale&lt;/code&gt; has got you covered.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- This will scale the element when hovered --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"hover:scale-105"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"bg-gray-50 rounded-md p-4"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    Lorem ipsum dolor sit amet consectetur adipisicing elit. Ducimus porro corporis eum eius voluptate omnis nesciunt exercitationem et inventore autem quis magni alias corrupti optio officia temporibus, ipsum neque magnam?
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion:
&lt;/h2&gt;

&lt;p&gt;As we conclude this exploration of Tailwind CSS utility classes, remember that these tools are just the tip of the iceberg. Experiment, dive into the &lt;a href="https://tailwindcss.com/docs/installation"&gt;Tailwind documentation&lt;/a&gt;, and uncover even more possibilities. Tailwind CSS stands as a beacon of simplicity and versatility, transforming the way developers approach frontend development. Happy coding!&lt;/p&gt;

&lt;p&gt;Before you go, why not connect with me on &lt;a href="https://twitter.com/mitch_chanza"&gt;Twitter&lt;/a&gt;? Stay updated on the latest web development trends, Tailwind tips, and more&lt;/p&gt;

</description>
      <category>tailwindcss</category>
      <category>frontend</category>
      <category>webdev</category>
      <category>css</category>
    </item>
    <item>
      <title>Modern API Development (Part 3) : Add GraphQL</title>
      <dc:creator>Mitch Chimwemwe Chanza</dc:creator>
      <pubDate>Mon, 13 Nov 2023 08:11:55 +0000</pubDate>
      <link>https://dev.to/mitch1009/modern-api-development-part-3-add-graphql-3don</link>
      <guid>https://dev.to/mitch1009/modern-api-development-part-3-add-graphql-3don</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;This post is a follow-up to the previous one at &lt;a href="https://dev.to/mitch1009/modern-api-developmentpart-2-initialize-server-1b7j"&gt;Part 2: Initiating Server&lt;/a&gt;. If you're looking to integrate GraphQL into an existing REST API, this guide is tailored for you. For those aiming to incorporate GraphQL into a new REST API, please refer to the instructions provided in the earlier posts. you can also follow the guide on my blog &lt;a href="https://blog.mitch.guru/guides"&gt;Mitch Guru&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I'm delighted that you've reached this point, and I hope you're finding the journey enjoyable. As we continue with this series, there's still much more ground to cover. Now, let's shift our focus to the modernization of the API. I understand if you've been pondering, "What's considered modern about this server?" especially since it relies on the trusted 'express.' Take a moment to relax because you're about to delve into the contemporary aspects of this series.&lt;/p&gt;

&lt;p&gt;we are going to cover the following topcs in this guide:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install additional dependencies - &lt;a href="https://the-guild.dev/graphql/tools/docs/introduction"&gt;GraphQl Tools&lt;/a&gt;, &lt;a href="https://www.apollographql.com/docs/apollo-server/getting-started"&gt;Apollo Server 4&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reconfigure the API to have separate routes, one for Graphql and one for REST&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Implement GraphQL Endpont and resolvers&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Test the API &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Alright, no more talking – let's jump right in!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# install all dependencies for graphql to work in our API&lt;/span&gt;
pnpm api add graphql @apollo/server @graphql-tools/load @graphql-tools/graphql-file-loader
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;graphql&lt;/code&gt; package is now installed. we can proceed to configure our API.&lt;br&gt;
firstly we need to create a &lt;code&gt;graphql&lt;/code&gt; folder in the &lt;code&gt;api&lt;/code&gt; folder. this is where our graphql files will be stored. i will create a &lt;code&gt;main.graphql&lt;/code&gt; file in that folder.&lt;/p&gt;

&lt;p&gt;We are going to have three types initialized in this file:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Response - custom type for responses&lt;/li&gt;
&lt;li&gt; Query - required root graphql query type&lt;/li&gt;
&lt;li&gt; Mutation  - required root mution type
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight graphql"&gt;&lt;code&gt;&lt;span class="c"&gt;#api/graphql/main.graphql file&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;type&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;!&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;success&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;!&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;type&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Query&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;hello&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;type&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Mutation&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;hello&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Up next we need to move some code from &lt;code&gt;main.ts&lt;/code&gt; to be isolated to their own module. i am refering to the router which is set inside the main file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;//api/src/main.ts file&lt;/span&gt;
&lt;span class="c1"&gt;// ... rest of code&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;router&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Router&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;// Set initial route&lt;/span&gt;
&lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;send&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Monorepo API Configured!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;success&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="c1"&gt;// .. rest of code &lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We are moving this part to a separate module called &lt;code&gt;api/src/endpoints/rest/restEndpoints.ts&lt;/code&gt;. where we will do some modifications and export the module&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="c1"&gt;// api/src/endpoints/rest/restEndpoints.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Router&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;restEndpoint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Router&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Router&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;// define routes&lt;/span&gt;
&lt;span class="nx"&gt;restEndpoint&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;send&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Rest Endpoint Initialized!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;restEndpoint&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now lets updated &lt;code&gt;api/src/main.ts&lt;/code&gt; to use the rest endpoint.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// api/src/main.ts file&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;restEndpoint&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./endpoints&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// ... rest of code&lt;/span&gt;
&lt;span class="c1"&gt;// Set v1/api endpoint&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/v1/api&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;restEndpoint&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// .. rest of code &lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;As observed, the import originates from the &lt;code&gt;./endpoint&lt;/code&gt; module rather than &lt;code&gt;./endpoint/rest/restEndpoint&lt;/code&gt;. This is accomplished by incorporating a &lt;code&gt;barrel&lt;/code&gt; file within the &lt;code&gt;endpoints&lt;/code&gt; folder, which exports all submodule functionalities.&lt;br&gt;
&lt;a href="https://basarat.gitbook.io/typescript/main-1/barrel"&gt;read more on what a barrel file is here&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We can run our server again to be sure that we did not break anything.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# run server&lt;/span&gt;
pnpm api dev
&lt;span class="c"&gt;# our server should be running properly  as expected. &lt;/span&gt;
&lt;span class="c"&gt;# http://localhost:9100 or http://localhost:9000 depending on the PORT set in .env file&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hold on, this isn't GraphQL yet; we're still operating a REST API! yes you are right, its one of the steps toward adding multiple routes tou our API.&lt;br&gt;
Up next we are going to create another route for our API inside &lt;code&gt;api/src/endpoints/graphql/graphqlEndpoints.ts&lt;/code&gt; module. Additionally we also need to create a resolver module &lt;code&gt;api/src/endpoints/graphql/resolvers.ts&lt;/code&gt; which is going to be responsible for implementating all resolvers. &lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// api/src/endpoints/graphql/graphqlEndpoints.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ApolloServer&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@apollo/server&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;loadSchemaSync&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@graphql-tools/load&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;GraphQLFileLoader&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@graphql-tools/graphql-file-loader&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;resolvers&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// load schema from graphql files&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;typeDefs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;loadSchemaSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./graphql/*.graphql&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;loaders&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;GraphQLFileLoader&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// create apollo server&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;server&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;ApolloServer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="nx"&gt;typeDefs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;resolvers&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// export server&lt;/span&gt;
 &lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  &lt;span class="nx"&gt;server&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;blockquote&gt;
&lt;p&gt;please note this is a minimal configuration for now.&lt;br&gt;
&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// api/src/endpoints/graphql/resolvers.ts&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;resolvers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;Query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;hello&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;`Hello there welcome to api monorepo`&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;Mutation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;hello&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;_&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;unknown&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;args&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;`Hello &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; welcome to api monorepo`&lt;/span&gt;

    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;p&gt;A sigh of relief we are now ready to test our REST + GraphQL APIs running on the same server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# run server&lt;/span&gt;
pnpm api dev
&lt;span class="c"&gt;# our server should be running properly  as expected. &lt;/span&gt;
&lt;span class="c"&gt;# http://localhost:9100/v1/rest and http://localhost:9000/v1/graphql &lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;We can now happily commit our changes.  and push them to our remote repository under the  &lt;a href="https://github.com/mitch1009/api-monorepo/tree/feature/part3"&gt;feature/part3&lt;/a&gt;  branch.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Watch out for &lt;strong&gt;Part 4&lt;/strong&gt; where we are going to integrate prisma ORM and &lt;strong&gt;part 5&lt;/strong&gt; Where we are going to introduce Hasura&lt;/p&gt;

</description>
      <category>graphql</category>
      <category>apolloserver</category>
      <category>express</category>
      <category>api</category>
    </item>
    <item>
      <title>2024's Game-Changers: 2 Unstoppable JavaScript Runtimes Transforming App Development</title>
      <dc:creator>Mitch Chimwemwe Chanza</dc:creator>
      <pubDate>Sun, 12 Nov 2023 15:13:16 +0000</pubDate>
      <link>https://dev.to/mitch1009/2024s-game-changers-2-unstoppable-javascript-runtimes-transforming-app-development-4bbg</link>
      <guid>https://dev.to/mitch1009/2024s-game-changers-2-unstoppable-javascript-runtimes-transforming-app-development-4bbg</guid>
      <description>&lt;p&gt;Each year, emerging technologies reshape the landscape of app development, emanating not only from the vibrant community but also from industry behemoths like Google, Facebook, Microsoft, and others. The current year is no exception, introducing compelling technologies that have stood the test of time.&lt;/p&gt;

&lt;p&gt;Let's delve into the newcomers on the scene, where one is generating considerable buzz while the other is still finding its footing. The key distinction lies in their origins, with the hyped contender emerging from a community member and the other crafted in the esteemed Microsoft forge.&lt;/p&gt;

&lt;p&gt;You're likely familiar with the ubiquitous JS runtime sensation, Burn. Its remarkable performance has captivated developers worldwide. However, before you break into celebration, let me introduce you to its formidable competitor, Rush.io.&lt;/p&gt;

&lt;p&gt;In my pursuit of expediting development and team management, I encountered these two contenders, both proving to be highly proficient. In this post, we'll conduct a head-to-head comparison between &lt;code&gt;rushjs&lt;/code&gt; and &lt;code&gt;bun&lt;/code&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Bun made its debut in the development landscape in January 2023, whereas Rush.js has been in circulation since 2016. Interestingly, Rush.js has garnered adoption from a select group of major tech companies, including Microsoft (its creator), HBO, Wix, and a few others, constituting a minority of the industry players&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Hold on a moment, let's delve into what Rush.js is all about. According to its website at &lt;a href="https://rushjs.io"&gt;rush.io&lt;/a&gt;, Rush is defined as a scalable monorepo manager tailored for the web. This tool, fostered by Microsoft, is designed to facilitate the seamless management of extensive code repositories, providing a solution for efficiently handling large-scale projects.&lt;/p&gt;

&lt;p&gt;On the contrary, Bun.js serves a dual role as both a JavaScript runtime and a package manager, setting the stage for an intriguing competition. As outlined on the &lt;a href="https://bun.sh/"&gt;bun.sh&lt;/a&gt;, website, Bun positions itself as an all-in-one toolkit. While this might sound unconventional, the claim appears to hold merit, indicating a comprehensive solution that spans various aspects of development and runtime management.&lt;/p&gt;

&lt;p&gt;In the realm of JavaScript runtimes, two contenders, Burn.js and Rush.js, emerge with distinctive origins, adoption trajectories, functionalities, and developer experiences.&lt;/p&gt;

&lt;h2&gt;
  
  
  Comparison
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Functionality and Purpose&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the arena of functionality and purpose, &lt;strong&gt;Rush.js&lt;/strong&gt; is a scalable monorepo manager designed to streamline the management of extensive code repositories. Tailored for large-scale projects, it efficiently addresses the challenges of scaling development efforts. Thanks to its Microsoft lineage, it seamlessly integrates with Microsoft-centric development environments and tools.&lt;/p&gt;

&lt;p&gt;On the flip side, &lt;strong&gt;Bun.js&lt;/strong&gt; distinguishes itself as a versatile tool serving as both a JavaScript runtime and a package manager. Positioned as an all-in-one toolkit, Bun.js simplifies various aspects of development and runtime management, offering flexibility in structuring and organizing projects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Developer Experience&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When it comes to the developer experience, &lt;strong&gt;Rush.js&lt;/strong&gt; emphasizes scalability, striving to enhance developers' interactions by providing tools to manage complex monorepos effectively. Despite not enjoying the same widespread community support as Burn.js, the Rush.js community offers valuable resources for developers navigating its ecosystem.&lt;/p&gt;

&lt;p&gt;Conversely, &lt;strong&gt;Bun.js&lt;/strong&gt; positions itself as a versatile tool catering to diverse developer needs. The Bun.js community, while potentially smaller, fosters engagement and collaboration among developers using the toolkit. In this landscape of JavaScript runtimes, each with its unique strengths and community dynamics, developers can choose between the established reliability of Burn.js and the versatile toolkit approach of Bun.js, or opt for Rush.js with its Microsoft-backed scalability and industry legacy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In the dynamic landscape of app development, Burn.js and Rush.js bring their unique strengths to the forefront. Burn.js, a community darling, boasts widespread adoption and a proven track record of performance. Meanwhile, Rush.js, backed by Microsoft, presents a robust solution for managing large-scale projects and complex monorepos.&lt;/p&gt;

&lt;p&gt;The choice between Burn.js and Rush.js extends beyond performance and adoption; it hinges on the specific needs and preferences of developers. Burn.js offers a tried-and-true solution, while Rush.js beckons with the promise of Microsoft-backed innovation and scalability. As we navigate the intricacies of these JavaScript runtimes, the decision ultimately rests on whether to lean towards the established or embrace the evolving landscape of app development in 2024.&lt;/p&gt;

</description>
      <category>bunjs</category>
      <category>rush</category>
      <category>package</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Modern API development(Part 2): Initialize Server</title>
      <dc:creator>Mitch Chimwemwe Chanza</dc:creator>
      <pubDate>Sun, 12 Nov 2023 09:56:47 +0000</pubDate>
      <link>https://dev.to/mitch1009/modern-api-developmentpart-2-initialize-server-1b7j</link>
      <guid>https://dev.to/mitch1009/modern-api-developmentpart-2-initialize-server-1b7j</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Refer to the earlier  post - &lt;a href="https://dev.to/mitch1009/modern-api-development-guide-44j2"&gt;Part 1&lt;/a&gt;,  to familiarize yourself with the configuration outlined there. This will enable you to continue with the instructions provided in this guide.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;Quick Overview&lt;/h2&gt;

&lt;p&gt;in this part we are going to implement the following:&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;
         
            
         
        &lt;span&gt;Install additional dependencies&lt;/span&gt;
    &lt;/li&gt;
    &lt;li&gt;
        
            
         
        &lt;span&gt;Additional project configurations&lt;/span&gt;
    &lt;/li&gt;
    &lt;li&gt;
        
            
         
        &lt;span&gt;Setup minimal server using express &lt;/span&gt;
    &lt;/li&gt;
    &lt;li&gt;
        
            
         
        &lt;span&gt;Test the server  &lt;/span&gt;
    &lt;/li&gt;
   
&lt;/ul&gt;

&lt;h3&gt;Initial Server configuration&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# create a src folder inside api folder&lt;/span&gt;
&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; api/src
&lt;span class="c"&gt;#create main typescript file&lt;/span&gt;
&lt;span class="nb"&gt;touch &lt;/span&gt;api/src/main.ts
&lt;span class="c"&gt;# lets change directory to api&lt;/span&gt;
&lt;span class="nb"&gt;cd &lt;/span&gt;api
&lt;span class="c"&gt;# install additional api dependencies &lt;/span&gt;
pnpm add cors express dotenv
&lt;span class="c"&gt;# this will install three dependencies in devdependencies&lt;/span&gt;
pnpm add &lt;span class="nt"&gt;-D&lt;/span&gt; @types/&lt;span class="o"&gt;{&lt;/span&gt;node,cors,express&lt;span class="o"&gt;}&lt;/span&gt; nodemon

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

&lt;/div&gt;



&lt;p&gt;Important: Additional configuration &lt;/p&gt;

&lt;p&gt;&lt;em&gt;It's worth mentioning that when using pnpm, we have the ability to set filters in order to run scripts globally in the project. Let's go ahead and set up some global scripts with filters. We also need to trim the typescript compile configuration file &lt;code&gt;tsconfig.json&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;package.json&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"scripts"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"api"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"pnpm --filter api"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;rest&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;configuration&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;We need to setup a few additional scripts in this file. we need &lt;code&gt;build&lt;/code&gt; script to help in compiling typescript to javascript. we also need to have a &lt;code&gt;watch&lt;/code&gt; script for compiling on code change. lastly we need a &lt;code&gt;dev&lt;/code&gt; script to run the server using &lt;code&gt;nodemon&lt;/code&gt;. &lt;br&gt;
please refer to the section above on how to install nodemon.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;api/package.json&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"scripts"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"tsc "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"watch"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"tsc -w"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"dev"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"nodemon dist/main.js"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;rest&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;configuration&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Presented below is a revised minimal configuration for the TypeScript compiler in the form of the &lt;code&gt;tsconfig.json&lt;/code&gt; file. This configuration serves as the foundational setup to initiate TypeScript compilation. It is recommended to use this as a starting point for your TypeScript projects, ensuring a solid foundation for further customization based on your specific requirements. Feel free to build upon and tailor this configuration to meet the unique needs of your TypeScript development endeavors.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;tsconfig.json&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"compilerOptions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"incremental"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;  
    &lt;/span&gt;&lt;span class="nl"&gt;"composite"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; 
    &lt;/span&gt;&lt;span class="nl"&gt;"target"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ES2022"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; 
    &lt;/span&gt;&lt;span class="nl"&gt;"module"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"NodeNext"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; 
    &lt;/span&gt;&lt;span class="nl"&gt;"moduleResolution"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"NodeNext"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"rootDirs"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"src"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt; 
    &lt;/span&gt;&lt;span class="nl"&gt;"outDir"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"./dist"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;   
    &lt;/span&gt;&lt;span class="nl"&gt;"strict"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; 
    &lt;/span&gt;&lt;span class="nl"&gt;"noImplicitAny"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; 
    &lt;/span&gt;&lt;span class="nl"&gt;"alwaysStrict"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;   
    &lt;/span&gt;&lt;span class="nl"&gt;"noUnusedLocals"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;  
    &lt;/span&gt;&lt;span class="nl"&gt;"noUnusedParameters"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;  
    &lt;/span&gt;&lt;span class="nl"&gt;"skipLibCheck"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"esModuleInterop"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

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

&lt;/div&gt;
&lt;p&gt;Adding additional settings to our project is optional but can help reduce clutter in your script. Specifically, we need to configure nodemon to run &lt;code&gt;.ts&lt;/code&gt; files without waiting for compilation. This can be achieved by using the &lt;code&gt;ts-node&lt;/code&gt; module. Let's take a look at the configuration.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# we need first to install ts-node&lt;/span&gt;
pnpm api add &lt;span class="nt"&gt;-D&lt;/span&gt; ts-node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Following the installation of ts-node, the next step involves configuring nodemon to operate in conjunction with ts-node. To achieve this, it is necessary to establish a nodemon configuration file, &lt;code&gt;nodemon.json&lt;/code&gt;, located at the root of our project. Additionally, we must modify our &lt;code&gt;dev&lt;/code&gt; script to execute nodemon while adhering to the specified configuration.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;nodemon.json&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"watch"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"src"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;"graphql"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;"hasura"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;"prisma,tsconfig.json,package.json,.env"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"ext"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ts,graphql,json,prisma,js,env"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"ignore"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"**/*.spec.ts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;"**/*.spec.graphql"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;"**/*.spec.json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;"**/*.spec.js"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"execMap"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"ts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ts-node ./src/main.ts"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;

    &lt;/span&gt;&lt;span class="nl"&gt;"exec"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ts-node ./src/main.ts"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

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

&lt;/div&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;api/package.json&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;updated&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;scripts&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;section&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"scripts"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"tsc "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"watch"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"tsc -w"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"dev"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"nodemon"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;rest&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;configuration&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Now that we have prepared the environment for our server to run smoothly, it's time to set up the server and test it. we need to create two files, the main entery file for our api &lt;code&gt;api/src/main.ts&lt;/code&gt; and environmental variables file &lt;code&gt;api/.env&lt;/code&gt;&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// api/src/main.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;json&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;cors&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;cors&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;dotenv&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;dotenv&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;dotenv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;env&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;// Initialse base router&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;router&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Router&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;// Set initial route&lt;/span&gt;
&lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;send&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Monorepo API Configured!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;success&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="c1"&gt;// Set v1/api endpoint&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/v1/api&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// configure cors. the delimeter here can be anything that you have used in your .env file. for my example here am using comma to separate the urls.&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;cors&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;origin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ALLOWED_ORIGINS&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}));&lt;/span&gt;
&lt;span class="c1"&gt;// enable json serialization&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="c1"&gt;// start server&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;9000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Server started on  http://localhost:&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/v1/api`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# .env file&lt;/span&gt;
  &lt;span class="nv"&gt;PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;9100
  &lt;span class="c"&gt;# allowed frontend applications based on the referer/origin.&lt;/span&gt;
  &lt;span class="nv"&gt;ALLOWED_ORRIGINS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;http://localhost:3000,http://localhost:7010
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;







&lt;p&gt;Lets run the server now.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm api dev
&lt;span class="c"&gt;# our server should be up and running on http://localhost:9100/v1/api or http://localhost:9000/vi/api depending on the PORT set in .env file&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>express</category>
      <category>api</category>
      <category>cors</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Modern API Development (Part 1)</title>
      <dc:creator>Mitch Chimwemwe Chanza</dc:creator>
      <pubDate>Sat, 11 Nov 2023 23:59:32 +0000</pubDate>
      <link>https://dev.to/mitch1009/modern-api-development-guide-44j2</link>
      <guid>https://dev.to/mitch1009/modern-api-development-guide-44j2</guid>
      <description>&lt;p&gt;Throughout this series, we will construct a comprehensive backend utilizing contemporary tools and cutting-edge concepts. My earnest desire is for you to accompany this journey from its inception, following the episodes in the order of their publication. This sequential approach is designed to facilitate a thorough understanding of the foundational concepts, making it particularly beneficial for beginners. However, if you happen to be an expert in the field, feel free to leverage your skills and customize the process to align with your specific objectives. Whether you're just starting out or a seasoned professional, there's something valuable for everyone in this series as we delve into the intricacies of backend development.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Please note that there will be coresponding youtube videos for each topic we cover in this series&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Setup
&lt;/h2&gt;

&lt;p&gt;Let's initiate the project setup and push it to GitHub. In this endeavor, we will be employing various frameworks, libraries, and programming languages. The selection of tools is independent of the project structure. Below is a list of tools we will be utilizing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Node.js 18&lt;/li&gt;
&lt;li&gt;PNPM - Package Manager &lt;em&gt;(PNPM will also be employed for managing a monorepo)&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Hasura - GraphQL Tool&lt;/li&gt;
&lt;li&gt;GraphQL - Schema Engine&lt;/li&gt;
&lt;li&gt;Express - Server&lt;/li&gt;
&lt;li&gt;Prisma - ORM&lt;/li&gt;
&lt;li&gt;Postgres - Database&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As the project progresses, additional tools may be incorporated into this list.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create a Monorepo
&lt;/h3&gt;

&lt;p&gt;Assuming PNPM is installed (for installation instructions, refer to &lt;a href="https://pnpm.io"&gt;pnpm&lt;/a&gt;), let's create a monorepo:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;myproject-monorepo
&lt;span class="nb"&gt;cd &lt;/span&gt;myproject-monorepo
&lt;span class="c"&gt;# Create an API folder&lt;/span&gt;
&lt;span class="nb"&gt;mkdir &lt;/span&gt;api
&lt;span class="c"&gt;# Initialize PNPM project&lt;/span&gt;
pnpm init
&lt;span class="c"&gt;# Initialize PNPM monorepo configuration&lt;/span&gt;
&lt;span class="nb"&gt;touch &lt;/span&gt;pnpm-workspace.yaml
&lt;span class="c"&gt;# Add the following in the workspace file&lt;/span&gt;
    packages:
        - &lt;span class="s2"&gt;"api"&lt;/span&gt;
        - &lt;span class="s2"&gt;"frontend"&lt;/span&gt; &lt;span class="c"&gt;# This is optional for now&lt;/span&gt;
&lt;span class="c"&gt;# setup api project&lt;/span&gt;
&lt;span class="nb"&gt;cd &lt;/span&gt;api
&lt;span class="c"&gt;# initialize  project&lt;/span&gt;
pnpm init
&lt;span class="c"&gt;# install initial dependencies&lt;/span&gt;
pnpm add &lt;span class="nt"&gt;-D&lt;/span&gt; typescript @types/node
&lt;span class="c"&gt;# initialize typescript&lt;/span&gt;
npx tsc &lt;span class="nt"&gt;--init&lt;/span&gt; 
&lt;span class="c"&gt;# modify tsconfig.json to suit your development requirements. you might want to enable more features in that file.&lt;/span&gt;


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

&lt;/div&gt;



&lt;p&gt;With these steps completed, we are prepared to weave together the components of our project. This marks the beginning of our successful project journey.&lt;/p&gt;

&lt;p&gt;Dive into &lt;a href="https://dev.to/mitch1009/modern-api-developmentpart-2-initialize-server-1b7j"&gt;part 2&lt;/a&gt; of this series.&lt;/p&gt;

&lt;p&gt;It is advisable to commit our modifications and push them to the GitHub repository. This precaution ensures that, in the event of any issues with our local version, we can easily retrieve the latest version from the remote repository. For further insights on GitHub and its functionalities .&lt;/p&gt;

</description>
      <category>express</category>
      <category>hasura</category>
      <category>api</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Inaugural Correspondence: Google</title>
      <dc:creator>Mitch Chimwemwe Chanza</dc:creator>
      <pubDate>Sat, 11 Nov 2023 15:04:43 +0000</pubDate>
      <link>https://dev.to/mitch1009/inaugural-correspondence-google-3h9d</link>
      <guid>https://dev.to/mitch1009/inaugural-correspondence-google-3h9d</guid>
      <description>&lt;p&gt;Dear Google,&lt;/p&gt;

&lt;p&gt;I extend this letter with admiration for Google's prominent position in the tech industry. I trust that all is thriving at your headquarters in Mountain View, California. This correspondence marks the initiation of a dialogue between the dynamic developer community and your esteemed organization.&lt;/p&gt;

&lt;p&gt;Google is highly esteemed by the global developer community for its significant impact on technology. Pioneering initiatives from your end have not only reshaped the tech landscape but have also remarkably facilitated the journeys of developers worldwide. The community is appreciative of the innovation and resources that Google has contributed to our field.&lt;/p&gt;

&lt;p&gt;This letter primarily serves as an introduction, paving the way for discussions on a myriad of topics in our future correspondences.&lt;/p&gt;

&lt;p&gt;I kindly request your consideration in acknowledging and, where appropriate, responding to these letters. Such engagement would not only keep us abreast of your perspective but also foster trust within the community, underscoring your commitment to both developers and your organization.&lt;/p&gt;

&lt;p&gt;In conclusion, I extend warm regards to your Chief Executive Officer and Chief Operating Officer, expressing our deep respect for their leadership.&lt;/p&gt;

&lt;p&gt;With sincere anticipation, we look forward to the commencement of a fruitful dialogue. Rest assured, we will remain in contact, eager to deepen the connection between our respective realms.&lt;/p&gt;

&lt;p&gt;Yours sincerely,&lt;/p&gt;

&lt;p&gt;Mitch Chimwemwe Chanza&lt;/p&gt;

&lt;p&gt;Tech Community Representative&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>google</category>
      <category>flutter</category>
      <category>firebase</category>
    </item>
    <item>
      <title>Inaugural Correspondence: Microsoft</title>
      <dc:creator>Mitch Chimwemwe Chanza</dc:creator>
      <pubDate>Sat, 11 Nov 2023 12:53:57 +0000</pubDate>
      <link>https://dev.to/mitch1009/inaugural-correspondence-microsoft-3f7k</link>
      <guid>https://dev.to/mitch1009/inaugural-correspondence-microsoft-3f7k</guid>
      <description>&lt;p&gt;Dear Microsoft.&lt;/p&gt;

&lt;p&gt;I am writing this letter with the utmost respect and appreciation for the work that Microsoft, a titan in the tech industry, consistently undertakes. I trust that all is well in Silicon Valley, and I seize this opportunity to formally inaugurate a line of communication between the vibrant developer community and your esteemed organization.&lt;/p&gt;

&lt;p&gt;The developer community, both locally and globally, holds Microsoft in high regard for its profound impact on the world of technology. Your pioneering initiatives have not only transformed the landscape but have also significantly eased the journey of countless developers worldwide. We are grateful for the innovation and resources you have contributed to our field.&lt;/p&gt;

&lt;p&gt;Allow me to clarify that this letter primarily serves as an introductory gesture, as there is a wealth of matters and ideas we aspire to explore in our forthcoming correspondences.&lt;/p&gt;

&lt;p&gt;I kindly request your consideration in acknowledging and, where necessary, responding to these letters. Such engagement will not only help us stay informed about your perspective but will also instill a sense of trust within the community, reaffirming your commitment to them and your organization.&lt;/p&gt;

&lt;p&gt;In closing, I would like to extend my warm regards to your Chief Executive Officer and Chief Operating Officer, conveying our deep respect for their leadership.&lt;/p&gt;

&lt;p&gt;With sincere anticipation, we look forward to the start of a productive dialogue. Please be assured that we will remain in touch, eager to foster a more profound connection between our two worlds.&lt;/p&gt;

&lt;p&gt;Yours sincerely,&lt;/p&gt;

&lt;p&gt;Mitch Chimwemwe Chanza&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tech Community Representative&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>microsoft</category>
      <category>openletters</category>
      <category>community</category>
      <category>technolology</category>
    </item>
    <item>
      <title>Open Letters To Tech Giants &amp; Ants</title>
      <dc:creator>Mitch Chimwemwe Chanza</dc:creator>
      <pubDate>Sat, 11 Nov 2023 12:53:26 +0000</pubDate>
      <link>https://dev.to/mitch1009/open-letters-to-tech-giants-and-ants-40b</link>
      <guid>https://dev.to/mitch1009/open-letters-to-tech-giants-and-ants-40b</guid>
      <description>&lt;p&gt;I humbly ask for your understanding as I embark on this endeavor, for this section is dedicated to open letters addressed to both the tech giants and the rising 'Ants' (smaller companies or establishments) in the tech industry.&lt;/p&gt;

&lt;p&gt;Within these letters, you will find a spectrum of content, ranging from critical assessments to applauding achievements, offering advice, and advocating for change. We intend to explore a multitude of topics within the tech community.&lt;/p&gt;

&lt;p&gt;My mission is not to appease or boast but rather to instigate meaningful change and make a lasting impact. Consequently, the majority of my content will remain impartial and direct.&lt;/p&gt;

&lt;p&gt;Moreover, if you or anyone you know possesses insights or ideas about pressing issues that warrant the attention of tech giants, please feel free to reach out to me. Together, we can craft impactful letters addressing these matters.&lt;/p&gt;

</description>
      <category>google</category>
      <category>aws</category>
      <category>microsoft</category>
    </item>
    <item>
      <title>Optimizing JavaScript Code: Embrace Async/Await for Clarity</title>
      <dc:creator>Mitch Chimwemwe Chanza</dc:creator>
      <pubDate>Fri, 01 Sep 2023 07:42:44 +0000</pubDate>
      <link>https://dev.to/mitch1009/optimizing-javascript-code-embrace-asyncawait-for-clarity-4co3</link>
      <guid>https://dev.to/mitch1009/optimizing-javascript-code-embrace-asyncawait-for-clarity-4co3</guid>
      <description>&lt;p&gt;When it comes to writing clean and maintainable JavaScript code, one of the best practices you can adopt is to leverage the power of async/await. In this tip, we'll explore why using async/await is a game-changer and how it can make your code more accessible and easier to read for developers of all skill levels.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Power of async/await
&lt;/h2&gt;

&lt;p&gt;Async/await is a modern JavaScript feature that simplifies asynchronous programming. It's particularly useful when dealing with tasks like making network requests, handling file operations, or managing timers. Instead of relying heavily on promise chaining, async/await allows you to write asynchronous code that closely resembles synchronous code. &lt;/p&gt;

&lt;h2&gt;
  
  
  Readability and Accessibility
&lt;/h2&gt;

&lt;p&gt;One of the most significant advantages of async/await is its ability to enhance the readability of your code. By using async/await, you can write asynchronous operations in a more linear and structured manner. This makes your code easier to follow, understand, and maintain. Even developers who may not be well-versed in JavaScript will find it more approachable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reducing Callback Hell
&lt;/h2&gt;

&lt;p&gt;Callback hell, also known as the "Pyramid of Doom," occurs when you nest multiple callbacks within each other. This can make your code hard to read and debug. Async/await helps you avoid this problem by allowing you to write asynchronous code in a sequential and structured way. This results in cleaner and more organized code, reducing the likelihood of errors.&lt;/p&gt;

&lt;h2&gt;
  
  
  Error Handling
&lt;/h2&gt;

&lt;p&gt;Async/await also simplifies error handling. You can use try/catch blocks to catch and handle errors in a straightforward manner. This leads to more robust code that's easier to troubleshoot.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started with async/await
&lt;/h2&gt;

&lt;p&gt;To start using async/await in your JavaScript projects, you'll need to define functions as &lt;code&gt;async&lt;/code&gt; and use the &lt;code&gt;await&lt;/code&gt; keyword inside them to wait for promises to resolve. This approach will make your codebase more consistent, readable, and maintainable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// define a named function&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;getInformation&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
&lt;span class="c1"&gt;// a network call - &lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;...&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// the results will be available after the promise resolves above&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;//or use an arrow function&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getInformation&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="c1"&gt;// same code implemented as above&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


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

&lt;/div&gt;



&lt;p&gt;In summary, i highly recommend embracing async/await where possible in your JavaScript code. By doing so, you'll not only make your code more accessible to developers who may be less familiar with JavaScript but also improve the overall readability and maintainability of your codebase. So, why not start integrating async/await into your projects today and experience the benefits firsthand?&lt;/p&gt;

</description>
      <category>async</category>
      <category>await</category>
      <category>javascript</category>
      <category>typescript</category>
    </item>
    <item>
      <title>The Process of creating Software Libraries</title>
      <dc:creator>Mitch Chimwemwe Chanza</dc:creator>
      <pubDate>Wed, 28 Dec 2022 17:16:00 +0000</pubDate>
      <link>https://dev.to/mitch1009/the-process-of-creating-software-libraries-5cd5</link>
      <guid>https://dev.to/mitch1009/the-process-of-creating-software-libraries-5cd5</guid>
      <description>&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;please note that this post is part of a series of posts if you are not familiar with the topic i suggest you go through part 1 of this post.*&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;Creating a software library is a complex process that involves several steps. In this post, we'll outline the general process of creating a software library and discuss the key considerations at each stage.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Identify a need or problem that the library will solve
The first step in creating a software library is to identify a need or problem that it will solve. This could be a specific task that is commonly performed in a particular domain, or a problem that has been identified through your own experiences as a developer.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It's important to be clear and focused about the scope of the library, as trying to solve too many problems or cover too many use cases can make the library complex and difficult to use.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Plan and design the library
Once you have a clear idea of what the library will do, the next step is to plan and design it. This includes deciding on the overall architecture of the library, as well as the specific functions and features it will include.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It's important to consider the needs of the users of the library and design it in a way that is intuitive and easy to use. It's also a good idea to research any existing libraries that might be similar to yours and consider how your library will be different or offer additional value.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Implement the library&lt;br&gt;
The next step is to start implementing the library. This involves writing the actual code for the functions and features you have designed. It's important to follow best practices for writing clean, maintainable code, including commenting your code, using descriptive variable names, and adhering to a consistent style guide.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Test and debug the library&lt;br&gt;
Once the code for the library has been written, it's important to test it thoroughly to ensure that it is working correctly and is free of errors. This may involve writing unit tests to verify the functionality of individual functions, as well as testing the library as a whole in a variety of different scenarios.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If any errors or bugs are discovered during testing, they will need to be fixed in the debugging process.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Document the library&lt;br&gt;
Thorough documentation is crucial for any software library, as it helps users understand how to use the library and how it is intended to be used. Documentation should include a detailed description of the functions and features of the library, as well as examples of how to use them.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Release the library and maintain it over time&lt;br&gt;
Once the library has been tested and documented, it's time to release it to the public. This could involve uploading it to a code repository or hosting it on your own website.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It's important to continue maintaining the library over time, including fixing any bugs that are discovered and adding new features as needed. This will help ensure that the library remains useful and relevant for its users.&lt;/p&gt;

&lt;p&gt;In summary, creating a software library involves a number of steps, including identifying a need or problem, planning and designing the library, implementing the code, testing and debugging, documenting the library, and releasing and maintaining it. By following this process, you can create a high-quality software library that is useful and easy to use for other developers.&lt;/p&gt;

</description>
      <category>emptystring</category>
    </item>
  </channel>
</rss>
