<?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>Forem: Rasool Khan</title>
    <description>The latest articles on Forem by Rasool Khan (@rasoolk16).</description>
    <link>https://forem.com/rasoolk16</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%2F400576%2F72ed8428-18bf-4295-b326-a9171f424029.png</url>
      <title>Forem: Rasool Khan</title>
      <link>https://forem.com/rasoolk16</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/rasoolk16"/>
    <language>en</language>
    <item>
      <title>Why “Easy / Medium / Hard” Is a Terrible Way to Think About DSA</title>
      <dc:creator>Rasool Khan</dc:creator>
      <pubDate>Fri, 06 Feb 2026 19:25:05 +0000</pubDate>
      <link>https://forem.com/rasoolk16/why-easy-medium-hard-is-a-terrible-way-to-think-about-dsa-2ll3</link>
      <guid>https://forem.com/rasoolk16/why-easy-medium-hard-is-a-terrible-way-to-think-about-dsa-2ll3</guid>
      <description>&lt;p&gt;One of the most misleading things about DSA is the difficulty label.&lt;/p&gt;

&lt;p&gt;Easy.&lt;br&gt;
Medium.&lt;br&gt;
Hard.&lt;/p&gt;

&lt;p&gt;It looks useful. It feels objective.&lt;br&gt;
But over time, I’ve found it does more harm than good especially when you’re actually trying to get better.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8cvlon4ng1th87byyg6i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8cvlon4ng1th87byyg6i.png" alt=" " width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Difficulty feels random for a reason
&lt;/h2&gt;

&lt;p&gt;If you’ve ever felt this, you’re not alone:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Some “easy” problems feel impossible&lt;/li&gt;
&lt;li&gt;Some “hard” problems click instantly&lt;/li&gt;
&lt;li&gt;You solve a medium one day, struggle with another the next&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At first, it’s easy to blame yourself.&lt;br&gt;
Maybe you’re inconsistent. Maybe you’re not good at DSA.&lt;/p&gt;

&lt;p&gt;But the issue isn’t you.&lt;br&gt;
It’s the label.&lt;/p&gt;




&lt;h2&gt;
  
  
  Difficulty isn’t about complexity
&lt;/h2&gt;

&lt;p&gt;Most people assume difficulty means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;harder math&lt;/li&gt;
&lt;li&gt;trickier code&lt;/li&gt;
&lt;li&gt;more clever ideas&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s rarely true.&lt;/p&gt;

&lt;p&gt;In practice, difficulty mostly reflects how many patterns are involved, and how cleanly they’re combined.&lt;/p&gt;

&lt;p&gt;From my experience:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Easy problems usually test one pattern&lt;/li&gt;
&lt;li&gt;Medium problems combine one or two&lt;/li&gt;
&lt;li&gt;Hard problems usually use two, occasionally three&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Almost never more than that.&lt;/p&gt;

&lt;p&gt;Once you see this, the labels start to lose their power.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why “easy” problems can feel hard
&lt;/h2&gt;

&lt;p&gt;An “easy” problem feels hard when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;you haven’t mastered that specific pattern yet&lt;/li&gt;
&lt;li&gt;the problem hides the pattern behind a story&lt;/li&gt;
&lt;li&gt;the invariant isn’t obvious immediately&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It’s not easy because it’s trivial.&lt;br&gt;
It’s easy because, once you recognize the pattern, the solution is straightforward.&lt;/p&gt;

&lt;p&gt;Without that recognition, even easy problems feel painful.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why “hard” problems sometimes feel easy
&lt;/h2&gt;

&lt;p&gt;On the flip side, a hard problem can feel surprisingly manageable when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;you’ve seen the underlying patterns before&lt;/li&gt;
&lt;li&gt;the combination makes sense to you&lt;/li&gt;
&lt;li&gt;you can reason about the invariants independently&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At that point, you’re not solving a “hard” problem.&lt;br&gt;
You’re just coordinating familiar ideas.&lt;/p&gt;

&lt;p&gt;The label doesn’t reflect your experience anymore your preparation does.&lt;/p&gt;




&lt;h2&gt;
  
  
  Difficulty is subjective, patterns aren’t
&lt;/h2&gt;

&lt;p&gt;This is the part I wish someone told me earlier.&lt;/p&gt;

&lt;p&gt;Difficulty labels are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;subjective&lt;/li&gt;
&lt;li&gt;relative&lt;/li&gt;
&lt;li&gt;influenced by popularity and platform heuristics&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Patterns are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;stable&lt;/li&gt;
&lt;li&gt;reusable&lt;/li&gt;
&lt;li&gt;transferable across problems and companies&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When you focus on patterns, your progress becomes measurable.&lt;br&gt;
When you focus on difficulty, it feels noisy and inconsistent.&lt;/p&gt;




&lt;h2&gt;
  
  
  How I approach problems now
&lt;/h2&gt;

&lt;p&gt;I don’t ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Is this problem hard?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I ask:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How many patterns does this involve?&lt;/li&gt;
&lt;li&gt;Do I already understand them individually?&lt;/li&gt;
&lt;li&gt;Are they interacting, or just sequential?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That framing turns something vague into something concrete.&lt;/p&gt;

&lt;p&gt;A “hard” problem becomes:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Two patterns I already know, combined slightly awkwardly.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That’s a much less scary problem to work on.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why this matters while learning
&lt;/h2&gt;

&lt;p&gt;If you let difficulty labels drive your learning:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;you avoid “hard” problems too early&lt;/li&gt;
&lt;li&gt;you overvalue “easy” problems for too long&lt;/li&gt;
&lt;li&gt;you tie progress to external tags instead of internal clarity&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you let patterns drive your learning:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;you know exactly what you’re weak at&lt;/li&gt;
&lt;li&gt;you know what to practice next&lt;/li&gt;
&lt;li&gt;progress feels intentional, not accidental&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That difference compounds over time.&lt;/p&gt;




&lt;h2&gt;
  
  
  This is also how interviews work
&lt;/h2&gt;

&lt;p&gt;Interviewers don’t think in terms of “this is a hard problem.”&lt;/p&gt;

&lt;p&gt;They think in terms of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which concepts does this test?&lt;/li&gt;
&lt;li&gt;Can the candidate recognize structure?&lt;/li&gt;
&lt;li&gt;Can they reason about constraints clearly?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Difficulty labels are for platforms.&lt;br&gt;
Patterns are what interviews actually evaluate.&lt;/p&gt;




&lt;h2&gt;
  
  
  Where I’m going with this
&lt;/h2&gt;

&lt;p&gt;This way of thinking patterns first, labels last, is what I’m trying to make explicit in my own learning and in what I’m building.&lt;/p&gt;

&lt;p&gt;Once you stop fearing “hard” and start dissecting structure, DSA becomes a lot calmer.&lt;/p&gt;

&lt;p&gt;Still challenging.&lt;br&gt;
But no longer intimidating.&lt;/p&gt;




&lt;h2&gt;
  
  
  What’s coming next
&lt;/h2&gt;

&lt;p&gt;In the next post, I want to write about why mastering arrays alone gets you much further than most people expect, and why arrays quietly sit underneath a huge chunk of DSA.&lt;/p&gt;

&lt;p&gt;If difficulty labels have been messing with your confidence, try ignoring them for a while.&lt;/p&gt;

&lt;p&gt;Focus on the patterns instead.&lt;/p&gt;

&lt;p&gt;It changes everything.&lt;/p&gt;




&lt;p&gt;I’ve been indexing patterns and the signals that point to them in one place &lt;a href="https://www.indexedcode.com" rel="noopener noreferrer"&gt;indexedcode&lt;/a&gt;, mostly as a reference for myself. Writing about it here helps me refine that thinking.&lt;/p&gt;

</description>
      <category>dsa</category>
      <category>interview</category>
      <category>algorithms</category>
      <category>career</category>
    </item>
    <item>
      <title>How I Identify the Right DSA Pattern (Before Writing Any Code)</title>
      <dc:creator>Rasool Khan</dc:creator>
      <pubDate>Mon, 02 Feb 2026 17:08:01 +0000</pubDate>
      <link>https://forem.com/rasoolk16/how-i-identify-the-right-dsa-pattern-before-writing-any-code-inb</link>
      <guid>https://forem.com/rasoolk16/how-i-identify-the-right-dsa-pattern-before-writing-any-code-inb</guid>
      <description>&lt;p&gt;When people ask how to get better at DSA, the advice is usually some version of: &lt;/p&gt;

&lt;p&gt;“Practice more problems.”&lt;/p&gt;

&lt;p&gt;That’s not wrong.&lt;br&gt;
It’s just incomplete.&lt;/p&gt;

&lt;p&gt;What actually made the biggest difference for me was learning how to identify the pattern early often before I thought about code at all.&lt;/p&gt;

&lt;p&gt;Once I got reasonably good at that, the rest of the problem usually unfolded on its own.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8n61g7usacvvianp45yh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8n61g7usacvvianp45yh.png" alt=" " width="800" height="1200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  I don’t start with the problem statement
&lt;/h2&gt;

&lt;p&gt;This might sound odd, but I don’t mentally engage with the whole story upfront.&lt;/p&gt;

&lt;p&gt;Instead, I look for a few very specific signals:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What kind of input am I given?&lt;/li&gt;
&lt;li&gt;What’s the constraint on time and space?&lt;/li&gt;
&lt;li&gt;What exactly is the output asking for?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Those three things eliminate most options very quickly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Constraints do most of the work
&lt;/h2&gt;

&lt;p&gt;If I see:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;“Sorted array”&lt;/li&gt;
&lt;li&gt;“Find a pair/subarray”&lt;/li&gt;
&lt;li&gt;“O(n) expected”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I’m already thinking two pointers or sliding window.&lt;/p&gt;

&lt;p&gt;If the problem:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;asks for ranges&lt;/li&gt;
&lt;li&gt;mentions cumulative values&lt;/li&gt;
&lt;li&gt;wants counts or sums over subarrays&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My brain immediately goes to prefix sums and hashing.&lt;/p&gt;

&lt;p&gt;If the input size is large and the answer space is monotonic, I’m thinking binary search often not over the array, but over the answer itself.&lt;/p&gt;

&lt;p&gt;None of this feels clever anymore.&lt;br&gt;
It feels mechanical.&lt;/p&gt;

&lt;p&gt;And that’s a good thing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keywords matter, but not the way people think
&lt;/h2&gt;

&lt;p&gt;People often memorize keyword → pattern mappings.&lt;/p&gt;

&lt;p&gt;That helps initially, but it breaks down.&lt;/p&gt;

&lt;p&gt;What I pay more attention to is what must stay true as I move through the input.&lt;/p&gt;

&lt;p&gt;That’s usually the invariant.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Am I shrinking a search space?&lt;/li&gt;
&lt;li&gt;Am I maintaining a valid window?&lt;/li&gt;
&lt;li&gt;Am I accumulating something monotonically?&lt;/li&gt;
&lt;li&gt;Am I eliminating options as I go?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once I can articulate that in a sentence, the pattern usually becomes obvious.&lt;/p&gt;

&lt;h2&gt;
  
  
  The moment of clarity usually comes early
&lt;/h2&gt;

&lt;p&gt;There’s a specific feeling I’ve learned to trust.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If, within the first couple of minutes, I can say:&lt;br&gt;
“This feels like X pattern because Y must remain true”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Then I know I’m on the right track even if I don’t yet know all the edge cases.&lt;/p&gt;

&lt;p&gt;If I can’t say that, I slow down.&lt;/p&gt;

&lt;p&gt;That’s usually a sign I’m trying to brute-force my way into insight instead of stepping back.&lt;/p&gt;

&lt;h2&gt;
  
  
  This is why coding comes last for me now
&lt;/h2&gt;

&lt;p&gt;Earlier, I used to jump into code quickly.&lt;/p&gt;

&lt;p&gt;That often led to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;messy logic&lt;/li&gt;
&lt;li&gt;backtracking&lt;/li&gt;
&lt;li&gt;unclear explanations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, if I can’t explain the invariant in plain English, I don’t open the editor.&lt;/p&gt;

&lt;p&gt;Once the pattern is clear:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the loop structure is obvious&lt;/li&gt;
&lt;li&gt;pointer movement decisions make sense&lt;/li&gt;
&lt;li&gt;complexity is almost self-evident&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The code becomes an implementation detail, not the core work.&lt;/p&gt;

&lt;h2&gt;
  
  
  This is what I’m trying to capture
&lt;/h2&gt;

&lt;p&gt;This way of thinking constraints first, invariant second, code last is what I’m slowly trying to document more systematically.&lt;/p&gt;

&lt;p&gt;Not as rules.&lt;br&gt;
Not as templates.&lt;/p&gt;

&lt;p&gt;Just as a way to make DSA feel less random and more… structured.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I’ve been indexing patterns and the signals that point to them in one place (indexedcode.com), mostly as a reference for myself. Writing about it here helps me refine that thinking.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What I’ll write about next
&lt;/h2&gt;

&lt;p&gt;In the next post, I want to dig into why difficulty labels (easy/medium/hard) are often misleading, and why they sometimes do more harm than good when you’re learning.&lt;/p&gt;

&lt;p&gt;If pattern recognition feels fuzzy right now, that’s normal.&lt;br&gt;
It sharpens with repetition the right kind of repetition.&lt;/p&gt;

&lt;p&gt;And once it clicks, you’ll notice you’re solving problems differently than before.&lt;/p&gt;

&lt;p&gt;Slower at first.&lt;br&gt;
Much faster in the long run.&lt;/p&gt;

</description>
      <category>dsa</category>
      <category>interview</category>
      <category>leetcode</category>
      <category>coding</category>
    </item>
    <item>
      <title>Most DSA Problems Are Repetitions</title>
      <dc:creator>Rasool Khan</dc:creator>
      <pubDate>Sat, 31 Jan 2026 16:56:08 +0000</pubDate>
      <link>https://forem.com/rasoolk16/most-dsa-problems-are-repetitions-3m1p</link>
      <guid>https://forem.com/rasoolk16/most-dsa-problems-are-repetitions-3m1p</guid>
      <description>&lt;p&gt;At some point while preparing for interviews, something odd happens.&lt;/p&gt;

&lt;p&gt;You solve a problem, move on, then a few days later you see another one that feels… familiar. Different story, different variables but the same underlying logic.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;At first, it feels like a coincidence. But, it isn’t.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc0mpld8691pk03u0rtpl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc0mpld8691pk03u0rtpl.png" alt=" " width="800" height="1200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The quiet realization
&lt;/h2&gt;

&lt;p&gt;Most DSA problems aren’t truly new.&lt;/p&gt;

&lt;p&gt;They’re variations.&lt;/p&gt;

&lt;p&gt;Different constraints. Slight tweaks. New wording.&lt;br&gt;
But underneath, the same few ideas keep coming back.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Two pointers.&lt;/li&gt;
&lt;li&gt;Sliding windows.&lt;/li&gt;
&lt;li&gt;Prefix sums.&lt;/li&gt;
&lt;li&gt;Binary search.&lt;/li&gt;
&lt;li&gt;A bit of hashing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you notice that, it’s hard to unsee it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this feels uncomfortable at first
&lt;/h2&gt;

&lt;p&gt;A lot of us are taught to treat every problem as something unique.&lt;/p&gt;

&lt;p&gt;Read carefully.&lt;br&gt;
Start from scratch.&lt;br&gt;
Try a few approaches.&lt;br&gt;
Hope something clicks.&lt;/p&gt;

&lt;p&gt;So when problems start repeating, it can feel like you’re “cheating” by reusing ideas like you’re not really learning.&lt;/p&gt;

&lt;p&gt;That framing is what makes DSA feel harder than it needs to be.&lt;/p&gt;

&lt;h2&gt;
  
  
  This is how engineering actually works
&lt;/h2&gt;

&lt;p&gt;In real systems, we don’t reinvent solutions either.&lt;/p&gt;

&lt;p&gt;We recognize structure.&lt;br&gt;
We reuse known approaches.&lt;br&gt;
We adapt patterns to constraints.&lt;/p&gt;

&lt;p&gt;DSA is no different.&lt;/p&gt;

&lt;p&gt;Interview problems aren’t testing how original you are.&lt;br&gt;
They’re testing whether you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;recognize structure&lt;/li&gt;
&lt;li&gt;choose the right abstraction&lt;/li&gt;
&lt;li&gt;reason about trade-offs&lt;/li&gt;
&lt;li&gt;explain why your approach works&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Repetition isn’t a weakness of the system.&lt;br&gt;
It’s the signal.&lt;/p&gt;

&lt;h2&gt;
  
  
  How difficulty really increases
&lt;/h2&gt;

&lt;p&gt;This part took me a while to accept.&lt;/p&gt;

&lt;p&gt;Difficulty usually doesn’t come from brand-new ideas.&lt;br&gt;
It comes from combining familiar ones.&lt;/p&gt;

&lt;p&gt;In practice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Easy problems → one pattern&lt;/li&gt;
&lt;li&gt;Medium problems → one or two patterns&lt;/li&gt;
&lt;li&gt;Hard problems → usually two, occasionally three
That’s it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The jump from easy to medium isn’t about intelligence.&lt;br&gt;
It’s about whether you can hold multiple constraints and invariants in your head at the same time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why grinding eventually stops helping
&lt;/h2&gt;

&lt;p&gt;This is where a lot of people get stuck.&lt;/p&gt;

&lt;p&gt;If you just keep solving problem after problem without pausing to extract the pattern:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;you overfit to specific questions&lt;/li&gt;
&lt;li&gt;you forget solutions quickly&lt;/li&gt;
&lt;li&gt;the next variation still feels “new”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But if you stop and ask:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What pattern is this really testing?&lt;/li&gt;
&lt;li&gt;What invariant is being maintained?&lt;/li&gt;
&lt;li&gt;Which constraints force this approach?
Then repetition becomes an advantage instead of a frustration.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You start recognizing problems earlier sometimes within the first minute.&lt;/p&gt;

&lt;p&gt;That’s when DSA starts feeling manageable.&lt;/p&gt;

&lt;h2&gt;
  
  
  What helped me the most
&lt;/h2&gt;

&lt;p&gt;The biggest shift for me was changing the question I asked myself.&lt;/p&gt;

&lt;p&gt;Instead of:&lt;br&gt;
“Can I solve this problem?”&lt;/p&gt;

&lt;p&gt;I started asking:&lt;br&gt;
“Which pattern is this trying to test?”&lt;/p&gt;

&lt;p&gt;Once I could answer that, everything else followed more naturally:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the approach&lt;/li&gt;
&lt;li&gt;the edge cases&lt;/li&gt;
&lt;li&gt;the complexity&lt;/li&gt;
&lt;li&gt;even the explanation&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;The code itself often became the least interesting part.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Why I’m leaning into this publicly
&lt;/h2&gt;

&lt;p&gt;This idea that DSA is mostly structured repetition is what I’m building around right now.&lt;/p&gt;

&lt;p&gt;Not as shortcuts.&lt;br&gt;
Not as tricks.&lt;/p&gt;

&lt;p&gt;But as a way to make the learning process feel less random and less intimidating.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I’ve been slowly documenting patterns, invariants, and ways to recognize them in one place (indexedcode.com), mostly as a reference I wish I’d had earlier.&lt;br&gt;
This newsletter is where I think out loud as I do that.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What’s next
&lt;/h2&gt;

&lt;p&gt;In the next post, I’ll write about how I identify the right pattern early, usually before thinking about code at all.&lt;/p&gt;

&lt;p&gt;It’s not magic.&lt;br&gt;
It’s mostly about constraints, keywords, and knowing what to ignore.&lt;/p&gt;

&lt;p&gt;If DSA has been feeling repetitive lately, that’s probably a good sign.&lt;/p&gt;

&lt;p&gt;You’re starting to see the structure.&lt;/p&gt;

</description>
      <category>dsa</category>
      <category>interview</category>
      <category>career</category>
      <category>programming</category>
    </item>
    <item>
      <title>[Boost]</title>
      <dc:creator>Rasool Khan</dc:creator>
      <pubDate>Sat, 31 Jan 2026 16:47:51 +0000</pubDate>
      <link>https://forem.com/rasoolk16/-4l59</link>
      <guid>https://forem.com/rasoolk16/-4l59</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/rasoolk16" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F400576%2F72ed8428-18bf-4295-b326-a9171f424029.png" alt="rasoolk16"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/rasoolk16/building-in-public-how-i-think-about-dsa-and-why-im-sharing-it-53dh" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Building in Public: How I Think About DSA (and Why I’m Sharing It)&lt;/h2&gt;
      &lt;h3&gt;Rasool Khan ・ Jan 30&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#dsa&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#interview&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#faang&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>dsa</category>
      <category>interview</category>
      <category>faang</category>
    </item>
    <item>
      <title>Building in Public: How I Think About DSA (and Why I’m Sharing It)</title>
      <dc:creator>Rasool Khan</dc:creator>
      <pubDate>Fri, 30 Jan 2026 19:43:25 +0000</pubDate>
      <link>https://forem.com/rasoolk16/building-in-public-how-i-think-about-dsa-and-why-im-sharing-it-53dh</link>
      <guid>https://forem.com/rasoolk16/building-in-public-how-i-think-about-dsa-and-why-im-sharing-it-53dh</guid>
      <description>&lt;p&gt;I want to build in public, write about how I think, and share what I’ve learned while actually using DSA not just preparing for it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffiq3zahgmrx2dajb3lus.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffiq3zahgmrx2dajb3lus.png" alt=" " width="800" height="1200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How my view on DSA changed
&lt;/h2&gt;

&lt;p&gt;At some point, DSA stops being about problems.&lt;/p&gt;

&lt;p&gt;You start noticing that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The same ideas keep repeating&lt;/li&gt;
&lt;li&gt;Most “hard” problems aren’t new, they’re combinations&lt;/li&gt;
&lt;li&gt;The real difficulty is recognising what applies, not writing code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That shift didn’t happen because I solved hundreds of problems.&lt;br&gt;
It happened when I stepped back and asked why the same patterns kept showing up.&lt;/p&gt;

&lt;p&gt;Once you see that, DSA feels less like a grind and more like a set of mental models.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I believe now
&lt;/h2&gt;

&lt;p&gt;This is my current, very opinionated take:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You don’t need endless problem-solving&lt;/li&gt;
&lt;li&gt;You need standalone mastery of patterns&lt;/li&gt;
&lt;li&gt;Easy problems usually use one pattern&lt;/li&gt;
&lt;li&gt;Medium problems combine one or two&lt;/li&gt;
&lt;li&gt;Hard problems rarely go beyond that&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you can explain the invariant, you’re most of the way there&lt;/p&gt;

&lt;p&gt;When I say “understand”, I don’t mean memorizing templates.&lt;br&gt;
I mean being able to explain why a certain approach works and why others don’t.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I’ll write about here
&lt;/h2&gt;

&lt;p&gt;This won’t be about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;LeetCode dumps&lt;/li&gt;
&lt;li&gt;Speed-running problem lists&lt;/li&gt;
&lt;li&gt;“Crack X in Y days” content&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead, I’ll write about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How I recognise DSA patterns from constraints&lt;/li&gt;
&lt;li&gt;Why certain patterns work (and when they don’t)&lt;/li&gt;
&lt;li&gt;How difficulty in interviews is often misunderstood&lt;/li&gt;
&lt;li&gt;How these same ideas show up in real systems&lt;/li&gt;
&lt;li&gt;What I’m building, and rethinking, along the way&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Think of this as engineering notes, written out loud.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building in public
&lt;/h2&gt;

&lt;p&gt;Alongside this, I’m building indexedcode, a pattern-first way to learn DSA.&lt;/p&gt;

&lt;p&gt;Not a course.&lt;br&gt;
Not a leaderboard.&lt;br&gt;
Not a grind.&lt;/p&gt;

&lt;p&gt;More like a reference I wish I had earlier, one that focuses on patterns, invariants, and decision-making.&lt;/p&gt;

&lt;p&gt;I’ll share what I build, what I change, and what I get wrong.&lt;br&gt;
If it helps someone else think more clearly, that’s a win.&lt;/p&gt;

&lt;h2&gt;
  
  
  Who this is for
&lt;/h2&gt;

&lt;p&gt;This is probably for you if:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;DSA feels harder than it should be&lt;/li&gt;
&lt;li&gt;You’re preparing for interviews but tired of brute force&lt;/li&gt;
&lt;li&gt;You care more about understanding than memorizing&lt;/li&gt;
&lt;li&gt;You like slowing down and reasoning things through&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If not, that’s okay too.&lt;/p&gt;

&lt;h2&gt;
  
  
  What’s next
&lt;/h2&gt;

&lt;p&gt;I’ll start with things like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Why most DSA problems are repetitions&lt;/li&gt;
&lt;li&gt;How I identify the right pattern early&lt;/li&gt;
&lt;li&gt;Why difficulty labels are misleading&lt;/li&gt;
&lt;li&gt;How mastering array patterns alone gets you surprisingly far&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I don’t have a fixed schedule. I’ll write when there’s something worth sharing.&lt;/p&gt;

&lt;p&gt;If any of this resonates, feel free to stick around.&lt;/p&gt;

&lt;p&gt;I’ll build in public and hopefully, learn alongside a few of you.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Backend engineer. Thinking a lot about DSA, systems, and how engineers actually reason.&lt;br&gt;
Building &lt;a href="https://www.indexedcode.com" rel="noopener noreferrer"&gt;indexedcode&lt;/a&gt; in public.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>dsa</category>
      <category>interview</category>
      <category>faang</category>
    </item>
    <item>
      <title>Elastic Beanstalk - Update Media Upload Size</title>
      <dc:creator>Rasool Khan</dc:creator>
      <pubDate>Thu, 11 Nov 2021 10:58:20 +0000</pubDate>
      <link>https://forem.com/rasoolk16/elastic-beanstalk-update-media-upload-size-53go</link>
      <guid>https://forem.com/rasoolk16/elastic-beanstalk-update-media-upload-size-53go</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Elastic Beanstalk is an AWS service for deploying and scaling web applications. We can upload our project code and elastic beanstalk will automatically handle the deployment, load balancing, auto-scaling, CloudWatch, etc. &lt;/p&gt;

&lt;h2&gt;
  
  
  Media Upload in S3
&lt;/h2&gt;

&lt;p&gt;In a local environment, when we upload a media file to an AWS S3 bucket, the file is first uploaded to our local server and then from our application the file is uploaded to S3 bucket. &lt;/p&gt;

&lt;h4&gt;
  
  
  The Problem
&lt;/h4&gt;

&lt;p&gt;But in production mostly we use Nginx web server. So, the Elastic Beanstalk basically creates an EC2 instance and uses Nginx in front of the node server as a proxy server.&lt;/p&gt;

&lt;p&gt;So, the problem arises here because Nginx server is a proxy server it doesn't allow unlimited upload size. Nginx has a default upload size as 1 MB for all file uploads. That's why when we upload a file which is over 1 MB size to S3 using an application deployed on Elastic Beanstalk it throws an error:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;413 – Request Entity Too Large&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;To solve this issue we have to add a custom Nginx configuration file. &lt;/p&gt;

&lt;h4&gt;
  
  
  Solution
&lt;/h4&gt;

&lt;p&gt;Elastic Beanstalk provides a number of platforms(docker, Go, Node, Java, etc.) which can be used to build our application. The Nginx is installed on the platform so to add a custom Nginx configuration file we need to add nginx.conf file inside of the platform folder. &lt;/p&gt;

&lt;p&gt;The below example shows how the our app is structured in the Elastic Beanstalk. You can read more about it &lt;a href="https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~/my-app/
|-- web.jar
|-- Procfile
|-- readme.md
|-- .ebextensions/
|   |-- options.config        # Option settings
|   `-- cloudwatch.config     # Other .ebextensions sections, for example files and container commands
`-- .platform/
    |-- nginx/                # Proxy configuration
    |   |-- nginx.conf
    |   `-- conf.d/
    |       `-- custom.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the folder structure we need to follow in order to add custom Nginx config file. Create a &lt;code&gt;.platform&lt;/code&gt; folder in your project's root directory. Then create a file called &lt;code&gt;proxy.conf&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqf2oa8rv8fj8ywi3v0v2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqf2oa8rv8fj8ywi3v0v2.png" alt="Folder Structure" width="195" height="86"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;proxy.conf&lt;/code&gt; file will be placed at &lt;em&gt;".platform/nginx/conf.d/proxy.conf"&lt;/em&gt;. The contents of this file will be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;client_max_body_size 100M;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After adding this file, deploy your app to Elastic Beanstalk. Now, we will be able to upload any file up to size 100MB. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; When deploy our app, Nginx server will automatically reload. If you are still not able to upload above 1MB then, the issue could be that Nginx server was not reloaded properly. To solve this, we can add another file. In the root of &lt;code&gt;.platform&lt;/code&gt; folder create a file called as &lt;code&gt;myconf.config&lt;/code&gt;. This command will basically reload our Nginx server before starting. The contents of this will be as follows:&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;container_commands:
  01_reload_nginx:
    command: "service nginx reload"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; If you are using docker then add the &lt;code&gt;.platform&lt;/code&gt; folder in the root directory along with &lt;code&gt;Dockerrun.aws.json&lt;/code&gt;. Then bundle them as zip and deploy.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;We saw how Nginx server only allows 1MB of file upload when deployed in Elastic Beanstalk. And we saw how to solve this by creating a custom Nginx configuration file.&lt;/p&gt;

&lt;p&gt;Please like and share if you found it useful. And follow me on &lt;a href="https://twitter.com/Dotnetdotnet" rel="noopener noreferrer"&gt;twitter&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Thank you for reading!&lt;/p&gt;

</description>
      <category>nginx</category>
      <category>elasticbeanstalk</category>
      <category>s3</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Building CRUD API with NestJs - Swagger API Documentation.</title>
      <dc:creator>Rasool Khan</dc:creator>
      <pubDate>Wed, 13 Oct 2021 15:53:49 +0000</pubDate>
      <link>https://forem.com/rasoolk16/building-crud-api-with-nestjs-swagger-api-documentation-n6p</link>
      <guid>https://forem.com/rasoolk16/building-crud-api-with-nestjs-swagger-api-documentation-n6p</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In this part, we will integrate Swagger UI which helps us to visualize our API resources and with visual documentation, it is easier for consuming and implementing APIs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Swagger?&lt;/strong&gt;&lt;br&gt;
The swagger UI does the hard work of generating and maintaining our API docs, making sure our documentation stays up-to-date as our application evolves.&lt;/p&gt;

&lt;p&gt;Before integrating Swagger UI, let's create some more APIs. In the last part we created a POST API to create new user. Let's create GET APIs to get all users and to get a single user.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Add these APIs in user.controller.ts
@Get('all')
  async getAll(): Promise&amp;lt;User[]&amp;gt; {
    return this.userService.getAll();
  }

  @Get(':userId')
  async getUser(@Param('userId') userId: number): Promise&amp;lt;User&amp;gt; {
    return await this.userService.getUser(userId);
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//user.service.ts
async getAll(): Promise&amp;lt;User[]&amp;gt; {
    return await this.userRepository.findAll();
  }

  async getUser(userId: number): Promise&amp;lt;User&amp;gt; {
    return await this.userRepository.findOne({ id: userId });
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Note:&lt;/em&gt; Here, we are just returning the data from database directly. But, this is not secure at all we shouldn't be exposing the data directly, we have to create response objects and return them to the client. Also, we have not added any validation what happens if the user we are requesting does not exist we are still returning 200 response which is not ideal. Please explore how to handle validation in APIs and how to use response objects to return data to client. Don't worry if you can't understand these, we will look into these in next part.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;We can install the swagger dependencies using npm&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --save @nestjs/swagger swagger-ui-express
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Once the installation is complete we need to initialize Swagger in 'main.ts' file&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;Now, in our browser if we go to: &lt;code&gt;http://localhost:3000/api/&lt;/code&gt;. We can see the list of APIs we have created and we can see all the details of the APIs what parameters it requires and what responses it returns.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdsx88uqgs1tbmfj60a0b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdsx88uqgs1tbmfj60a0b.png" alt="Swagger Page" width="800" height="394"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Swagger Schema
&lt;/h2&gt;

&lt;p&gt;But if we see in schema below it contains 'CreateUserDto' object which we created but it's empty as Swagger is not able to recognize it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjw2mpp7yx01ffxuuff2z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjw2mpp7yx01ffxuuff2z.png" alt="Swagger Schema" width="473" height="212"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We are using Nest CLI, so we need to add the following plugin configuration in 'nest-cli.json' file.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Also, in all the APIs the response objects are empty, as we need to mention them explicitly in controllers. So, let's do it now.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Note:&lt;/em&gt; We have added only response objects for status 200. Please explore what other return statuses are possible and add respective Api Response decorators for them.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fagnybjrpz75poy9l6r8z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fagnybjrpz75poy9l6r8z.png" alt="Swagger Response object" width="800" height="233"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we can see the response objects and the schema objects.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frav1ajdebml09dgxkx9b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frav1ajdebml09dgxkx9b.png" alt="Swagger Schema objects" width="800" height="255"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; If schema objects are still empty, please &lt;em&gt;delete&lt;/em&gt; 'dist' directory and run the server again. This folder contains the file conversions of TypeScript to JavaScript. NestJs is entirely written in TypeScript but it has to be converted to JavaScript which is run by the server. Since we have updated the 'nest-cli.json' file we may have to generate the dist folder again.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;In this tutorial, we explored how we can integrate Swagger UI in our Nest application to document our APIs. We also saw how to add response objects and schema objects in swagger UI.&lt;/p&gt;




&lt;p&gt;GitHub Repository - &lt;a href="https://github.com/rskhan167/movie-review" rel="noopener noreferrer"&gt;https://github.com/rskhan167/movie-review&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it for this part. Please like and share if you found it useful.&lt;br&gt;
Follow me on Twitter: &lt;a href="https://twitter.com/Dotnetdotnet" rel="noopener noreferrer"&gt;https://twitter.com/Dotnetdotnet&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading.&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>nestjs</category>
      <category>node</category>
      <category>swagger</category>
    </item>
    <item>
      <title>Building CRUD API with NestJs - Write First API.</title>
      <dc:creator>Rasool Khan</dc:creator>
      <pubDate>Fri, 08 Oct 2021 18:53:11 +0000</pubDate>
      <link>https://forem.com/rasoolk16/building-crud-api-with-nestjs-write-first-api-46m</link>
      <guid>https://forem.com/rasoolk16/building-crud-api-with-nestjs-write-first-api-46m</guid>
      <description>&lt;h3&gt;
  
  
  Part II
&lt;/h3&gt;

&lt;p&gt;In &lt;a href="https://dev.to/rasoolk16/building-crud-api-with-nestjs-mikro-orm-and-postgres-43b5"&gt;Part I&lt;/a&gt;, we created nestjs project and created a database and then integrated Mikro-Orm. In this part we are going to create entities and start writing APIs.&lt;/p&gt;

&lt;p&gt;We are first going to start with User module. We are going to structure our project like user folder will contain controller, service, repository, entities of it's own and after this module is completed we are going to export this module to our main module i.e. "app.module.ts file".&lt;br&gt;
    First, let's create a "user" named folder in src directory. &lt;/p&gt;
&lt;h2&gt;
  
  
  Create an Entity
&lt;/h2&gt;

&lt;p&gt;Now, let's create a folder "entities" which will contain all the entities related to user. &lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Here we used &lt;code&gt;@Entity&lt;/code&gt; to define an entity. The entity contains many properties and these properties can be defined with either &lt;code&gt;@Property()&lt;/code&gt;, &lt;code&gt;@ManyToOne()&lt;/code&gt;, &lt;code&gt;@OneToMany()&lt;/code&gt;, etc. These are known as decorators, to know more about these checkout out &lt;a href="https://mikro-orm.io/docs/decorators/" rel="noopener noreferrer"&gt;Decorator Reference&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;There are also some optional properties like defining an entity property as nullable using &lt;code&gt;@Property({ nullable: true })&lt;/code&gt; and also setting a default value for a property. Check out &lt;a href="https://mikro-orm.io/docs/defining-entities" rel="noopener noreferrer"&gt;Defining Entities&lt;/a&gt; to know more about how to define an entity and its properties.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We have also used 'class-validator' package which is used to validate an entity property itself. &lt;code&gt;@IsEmail()&lt;/code&gt; decorator will check if the email is valid or not. We can add a lot these validation at entity creation level itself so that no improper data reaches the database.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now let's create user repository. Create this file in the user directory itself.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//user.repository.ts
import { EntityRepository, Repository } from '@mikro-orm/core';
import { User } from './entities/user.entity';

@Repository(User)
export class UserRepository extends EntityRepository&amp;lt;User&amp;gt; {}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now we need to run migration and apply the migration to create this user table in our database. &lt;br&gt;
    Run this command &lt;code&gt;npx mikro-orm migration:create&lt;/code&gt; to create a new migration file. If any new entity is created or a change has been made to the existing entities, a new migration file will be generated. Then, &lt;code&gt;npx mikro-orm migration:up&lt;/code&gt; command will apply the changes to the database.&lt;/p&gt;

&lt;p&gt;Check out these other Mikroorm related commands:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx mikro-orm migration:create   # Create new migration with current schema diff
npx mikro-orm migration:up       # Migrate up to the latest version
npx mikro-orm migration:down     # Migrate one step down
npx mikro-orm migration:list     # List all executed migrations
npx mikro-orm migration:pending  # List all pending migrations
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
This is the migration file that is being generated. After applying  these changes to the database a new table will be created.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy9xzwdqbtx4ocjo5thlf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy9xzwdqbtx4ocjo5thlf.png" alt="User table" width="262" height="86"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flrb9j40znmuhrdfa4h5a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flrb9j40znmuhrdfa4h5a.png" alt="User table columns" width="800" height="114"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  First API
&lt;/h2&gt;

&lt;p&gt;Now that our table is created we can start writing APIs. We will create a controller and a service file. Controller file will handle all our APIs related to user and all the business logic will be written in service file.&lt;/p&gt;

&lt;h3&gt;
  
  
  Controller
&lt;/h3&gt;

&lt;p&gt;We will create a CreateUser API. This API will accept user details and then store it in our user table. First, we need to create a DTO(Data Transfer Object), in simple words DTOs are used to map objects to domain models. &lt;br&gt;
In user directory create "dtos" folder and inside it create "create-user.dto.ts" file.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Here, we have defined all the properties needed to create a new user. As mentioned in previous post to validate a property we are using 'class-validator' library. &lt;/p&gt;

&lt;p&gt;Now we can create user controller file.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;We are injecting UserService here, where we will call database to perform CRUD operation. In controller, we just handle the incoming request and then send the response back to the client.&lt;/p&gt;

&lt;h3&gt;
  
  
  Service
&lt;/h3&gt;

&lt;p&gt;UserService is where we make the database call using ORM to store or retrieve the data. Services in Nestjs are known as Providers. Providers (services, repositories, helpers, etc.) can be injected as dependencies.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;&lt;p&gt;As repositories are also providers these can be injected as dependency too and we inject UserRepository so that UserService can retrieve or store data in the database. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We have a single method inside user service, which first checks if the a user with given email Id is already stored in database or not. Then, we create a User object using the constructor created in user entity. At last, we save the new user object in the database.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Before, we test our API as mentioned earlier, we need to import this user module in our main "app.module.ts" file. Just add the "UserModule" file in imports.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  Test the API.
&lt;/h2&gt;

&lt;p&gt;Run the "npm run start" or "npm run start:dev" command in the terminal to start the application.&lt;br&gt;
For testing we are using Postman, you can download if you don't have it already or you can use postman online in your browser too.&lt;/p&gt;

&lt;p&gt;We send a POST request to the &lt;code&gt;/api/user&lt;/code&gt; endpoint:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0txoer99i3r4ilap3hqa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0txoer99i3r4ilap3hqa.png" alt="API testing using Postman" width="800" height="224"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After successful response we have our first entry in the database.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F88boeclbnozvq6t7fgrx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F88boeclbnozvq6t7fgrx.png" alt="Database" width="800" height="80"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;In this tutorial, we created our first API and learned how to uses Mikro-Orm to store and retrieve data from database. And tested our API with postman.&lt;/p&gt;

&lt;p&gt;Github Repository - &lt;a href="https://github.com/rskhan167/movie-review" rel="noopener noreferrer"&gt;https://github.com/rskhan167/movie-review&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's all for this part see you in the next one. Thanks for reading.&lt;br&gt;
Please Like it and Share with your friends if you found it useful.&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>nestjs</category>
      <category>node</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Building CRUD API with NestJs - Introduction.</title>
      <dc:creator>Rasool Khan</dc:creator>
      <pubDate>Thu, 07 Oct 2021 20:30:33 +0000</pubDate>
      <link>https://forem.com/rasoolk16/building-crud-api-with-nestjs-mikro-orm-and-postgres-43b5</link>
      <guid>https://forem.com/rasoolk16/building-crud-api-with-nestjs-mikro-orm-and-postgres-43b5</guid>
      <description>&lt;p&gt;&lt;a href="https://nestjs.com/" rel="noopener noreferrer"&gt;NestJs&lt;/a&gt; is a Node.js framework for building efficient and scalable server-side applications and the best thing is that it fully supports Typescript.&lt;br&gt;
And we will be using &lt;a href="https://mikro-orm.io/" rel="noopener noreferrer"&gt;Mikro-orm&lt;/a&gt; for data mapping and PostgreSQL, a relational database.&lt;/p&gt;

&lt;p&gt;We are going to create a &lt;em&gt;movie-review&lt;/em&gt; app wherein users can rate and write review about the movies/shows they have watched.&lt;/p&gt;

&lt;p&gt;This will a series, so please follow each blog and at the end of the series hopefully we will have a working back-end application and in doing so we will get better understanding of NestJs.&lt;/p&gt;
&lt;h3&gt;
  
  
  Part I
&lt;/h3&gt;

&lt;p&gt;So, in the first part of this series, we are going to setup our NestJs project, create a PostgreSQL database and connect our application with the database using Mikro-Orm.&lt;/p&gt;

&lt;p&gt;Let's start...&lt;/p&gt;
&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;Install Nest CLI globally in your machine and then using the Nest CLI create a new project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npm i -g @nestjs/cli
$ nest new project-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This will create a new project which already has boilerplate files installed in it. To know what these files are please refer &lt;a href="https://docs.nestjs.com/first-steps" rel="noopener noreferrer"&gt;NestJs&lt;/a&gt; Documentation they have explained it perfectly.&lt;/p&gt;

&lt;p&gt;Your project structure should look something like this &lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb54kmofchsxhnj8xhdqx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb54kmofchsxhnj8xhdqx.png" alt="Initial Project Structure" width="366" height="495"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Database Configuration
&lt;/h2&gt;

&lt;p&gt;We will be using PostgreSQL for database. So, install &lt;a href="https://www.postgresql.org/download/" rel="noopener noreferrer"&gt;PostgreSQL&lt;/a&gt; and &lt;a href="https://www.pgadmin.org/download/" rel="noopener noreferrer"&gt;pgAdmin&lt;/a&gt;(Database management tool). After installing both, open pgAdmin and create new database.&lt;/p&gt;

&lt;p&gt;Now, we need to install an ORM to work with the database we created. Let's install &lt;a href="https://mikro-orm.io/" rel="noopener noreferrer"&gt;Mikro-Orm&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npm i -s @mikro-orm/cli @mikro-orm/core @mikro-orm/postgresql
$ npm i -s @mikro-orm/nestjs @mikro-orm/reflection @mikro-orm/sql-highlighter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;After installing Mikro-Orm, we need to add configuration file in which we will connect to our database. Create &lt;em&gt;mikro-orm.config.ts&lt;/em&gt; file in src folder. &lt;/p&gt;

&lt;p&gt;We can directly configure this in app.module.ts file. But it is better to separate the dbConfig file so that we can write the database and migration details in a clean way. Please Refer Mikro-Orm &lt;a href="https://mikro-orm.io/docs/usage-with-nestjs" rel="noopener noreferrer"&gt;documentation&lt;/a&gt; for other methods of configuring ORM.  &lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;After writing the config file we need to add this file to  &lt;em&gt;app.module.ts&lt;/em&gt;. Just call forRoot() method without any arguments as we have already mentioned everything in our config file.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Now, the EntityManager will be available to inject across entire project (without importing any module elsewhere).&lt;/p&gt;

&lt;p&gt;Also make sure mikro-orm is added in package.json file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"mikro-orm": {
    "useTsNode": true,
    "configPaths": [
      "./src/mikro-orm.config.ts",
      "./dist/src/mikro-orm.config.js"
    ]
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Also make sure the configPaths are given correct. You can verify this by checking your dist folder. Otherwise, you might get some error stating "cannot find mikro-orm.config.js".&lt;/p&gt;

&lt;p&gt;Before moving forward, let's look at our &lt;code&gt;main.ts&lt;/code&gt; file as well. Here, we have to mention the port number our app will be running on. And we have also added a global prefix 'api' to our app. This prefix will be used in all the APIs. Example: &lt;code&gt;http://localhost:3000/api/user&lt;/code&gt;, &lt;code&gt;http://localhost:3000/api/movie/&lt;/code&gt;.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;We are ready to create entities and start writing APIs. I think this is enough for Part I. Let's meet in the Part II of this series. &lt;/p&gt;

&lt;p&gt;Github Repository - &lt;a href="https://github.com/rskhan167/movie-review" rel="noopener noreferrer"&gt;https://github.com/rskhan167/movie-review&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please like and share if you found it helpful. &lt;br&gt;
Thanks for reading.&lt;/p&gt;

</description>
      <category>nest</category>
      <category>postgres</category>
      <category>nestjs</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>API documentation - Swagger UI in .NET Core</title>
      <dc:creator>Rasool Khan</dc:creator>
      <pubDate>Sun, 07 Mar 2021 17:26:58 +0000</pubDate>
      <link>https://forem.com/rasoolk16/api-documentation-swagger-ui-in-net-core-3ln1</link>
      <guid>https://forem.com/rasoolk16/api-documentation-swagger-ui-in-net-core-3ln1</guid>
      <description>&lt;h1&gt;
  
  
  Swagger UI
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;What is Swagger UI?&lt;/em&gt; &lt;br&gt;
&lt;strong&gt;Swagger UI&lt;/strong&gt; is an &lt;strong&gt;API documentation tool&lt;/strong&gt; that helps us to visualize our API resources and with visual documentation, it is easier for consuming and implementing APIs. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Why Swagger?&lt;/em&gt;&lt;br&gt;
As our backend app grows managing APIs become difficult. So it is highly advisable to create API documentation. But generating and maintaining our own API documentation is a painful task this is where Swagger UI comes into the play. The swagger UI does the hard work of generating and maintaining our API docs, making sure our documentation stays up-to-date as our API evolves.&lt;/p&gt;

&lt;p&gt;Let's create a .Net Core app. For this tutorial, we are going to have a simple app with two basic APIs. &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnz4d540hje9itj2sp1et.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnz4d540hje9itj2sp1et.png" alt="Alt Text" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Install Swashbuckle.AspNetCore
&lt;/h2&gt;

&lt;p&gt;This is a NuGet package for Swagger in dotnet. We can install it from the Nuget package manager.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg02dsq8jtu3hjqdtfhyn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg02dsq8jtu3hjqdtfhyn.png" alt="Alt Text" width="800" height="296"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Register Swagger UI in Startup.cs
&lt;/h2&gt;

&lt;p&gt;As we know that we have to register all our services in Startup.cs file. &lt;/p&gt;

&lt;p&gt;We will register Swagger in Startup.cs file's &lt;em&gt;ConfigureServices&lt;/em&gt; method as shown below.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl6csnrcg62hu40wc50un.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl6csnrcg62hu40wc50un.png" alt="Alt Text" width="800" height="251"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;using Microsoft.OpenApi.Models;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: This using namespace has to be added to use &lt;em&gt;OpenApiInfo&lt;/em&gt; class.&lt;/p&gt;

&lt;p&gt;Now, we will add swagger in the Configure method as well.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbrzdhnb0rmceiqj3s95y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbrzdhnb0rmceiqj3s95y.png" alt="Alt Text" width="800" height="679"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it. Now we are ready to use Swagger UI for our APIs.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff01nrbl1mmmkiwzahlys.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff01nrbl1mmmkiwzahlys.png" alt="Alt Text" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, we don't have to configure anything else. As we keep adding more APIs it will start to appear in this Documentation automatically.&lt;/p&gt;

&lt;h3&gt;
  
  
  That's the end.
&lt;/h3&gt;

&lt;p&gt;Thanks for reading.&lt;br&gt;
Please share and ❤️ if this was helpful. &lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>dotnetcore</category>
      <category>swagger</category>
      <category>api</category>
    </item>
    <item>
      <title>Publish NuGet packages with GitHub</title>
      <dc:creator>Rasool Khan</dc:creator>
      <pubDate>Thu, 25 Feb 2021 11:56:28 +0000</pubDate>
      <link>https://forem.com/rasoolk16/publish-nuget-packages-with-github-598h</link>
      <guid>https://forem.com/rasoolk16/publish-nuget-packages-with-github-598h</guid>
      <description>&lt;p&gt;In this blog, we will see how to publish &lt;em&gt;NuGet packages to a GitHub repository&lt;/em&gt;. We can publish NuGet packages either publicly or privately. For publishing NuGet packages in nuget.org (publically available to all developers)  &lt;a href="https://docs.microsoft.com/en-us/nuget/nuget-org/publish-a-package" rel="noopener noreferrer"&gt;Refer this&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;We can publish NuGet to a repo in GitHub using Personal Access Token(PAT) so that the package can be available to our team/organization only(basically anyone who has access to our PAT). &lt;/p&gt;

&lt;p&gt;Let's start,&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Create a new project
&lt;/h2&gt;

&lt;p&gt;Create a new .Net project using Dotnet CLI or from Visual Studio 2019.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftj84dyp7i4yobabkiyv0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftj84dyp7i4yobabkiyv0.png" alt="newproj.png" width="800" height="428"&gt;&lt;/a&gt;&lt;br&gt;
For this blog, I am using an empty demo project. &lt;strong&gt;Note:&lt;/strong&gt; Obviously, we can also use any existing projects and publish them as well.&lt;/p&gt;

&lt;p&gt;When the project is ready to publish, open &lt;em&gt;.csproj file&lt;/em&gt; of the project and add package description inside the &lt;strong&gt;PropertyGroup&lt;/strong&gt; tag.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;``` &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        &amp;lt;PropertyGroup&amp;gt;
        &amp;lt;TargetFramework&amp;gt;netcoreapp3.1&amp;lt;/TargetFramework&amp;gt;
        &amp;lt;PackageId&amp;gt;NugetDemo&amp;lt;/PackageId&amp;gt;
        &amp;lt;Version&amp;gt;1.0.0&amp;lt;/Version&amp;gt;
        &amp;lt;Authors&amp;gt;RK&amp;lt;/Authors&amp;gt;
        &amp;lt;Company&amp;gt;rkblog&amp;lt;/Company&amp;gt;
        &amp;lt;PackageDescription&amp;gt;Demo Description&amp;lt;/PackageDescription&amp;gt;
        &amp;lt;RepositoryUrl&amp;gt;https://github.com/rskhan167/NugetDemo&amp;lt;/RepositoryUrl&amp;gt;
        &amp;lt;/PropertyGroup&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;  ```&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnf1mbr2q2r2xexu0yiua.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnf1mbr2q2r2xexu0yiua.png" alt="desc.png" width="800" height="340"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Create a new repo in GitHub and don't forget to add it's URL inside RepositoryUrl tag.&lt;br&gt;
Our project is now ready. &lt;/p&gt;
&lt;h2&gt;
  
  
  2. Pack the project
&lt;/h2&gt;

&lt;p&gt;Now we need to package our project so that we have the .nupkg file that can be published.&lt;br&gt;
And this is very simple. We can do this in two ways.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Right-click on our project in Visual Studio 2019 and select "Pack" option.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa867ks1d8f79mulpyydq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa867ks1d8f79mulpyydq.png" alt="pack.png" width="507" height="339"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Or we can use Dotnet CLI to pack our project.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;dotnet pack --configuration Release&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;.nupkg file&lt;/strong&gt; will be created in the &lt;em&gt;bin directory&lt;/em&gt; of the project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7pubgmwpu5wv6ozkivjo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7pubgmwpu5wv6ozkivjo.png" alt="nupkg.png" width="800" height="208"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Publish the package
&lt;/h2&gt;

&lt;p&gt;To publish package in GitHub we need to do two things first generate Personal Access Token and second authenticate to GitHub Packages. Refer to &lt;a href="https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token" rel="noopener noreferrer"&gt;official github&lt;/a&gt; docs for generating a PAT. &lt;/p&gt;

&lt;p&gt;Now to authenticate to GitHub Packages we need to create &lt;em&gt;nuget.config&lt;/em&gt; file in our project directory and add the package sources and package source credentials as shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6gbr2sojh15txktyh4tf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6gbr2sojh15txktyh4tf.png" alt="config.png" width="800" height="292"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After generating &lt;em&gt;PAT and adding nuget.config file&lt;/em&gt; run this command.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;dotnet nuget push "bin/Release/NugetDemo.1.0.0.nupkg"  --api-key YOUR_GITHUB_PAT --source "github"&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Voila! Our package is published.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fft9x8sbnlftwecetp50n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fft9x8sbnlftwecetp50n.png" alt="publish.png" width="699" height="87"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can the view package in our GitHub profile.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9boaop4f64ku0grd5gr9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9boaop4f64ku0grd5gr9.png" alt="github.png" width="800" height="264"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But wait it's not finished yet. How will we use this package as dependencies in our next .Net project? Again we have two ways to achieve this, either we can install this package from the command line OR install it from NuGet package manager in Visual Studio 2019.  &lt;/p&gt;

&lt;h2&gt;
  
  
  4. Installing package
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Adding from Command line&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fueiidxbxdjxifpbh77to.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fueiidxbxdjxifpbh77to.png" alt="installpack1.png" width="800" height="217"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;From Nuget Package manager.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To access our packages we need to mention our package source in Nuget manager. Refer to this official &lt;a href="https://docs.microsoft.com/en-us/nuget/consume-packages/install-use-packages-visual-studio#package-sources" rel="noopener noreferrer"&gt;&lt;strong&gt;Microsoft doc&lt;/strong&gt;&lt;/a&gt; to add package source. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: The &lt;em&gt;package name&lt;/em&gt; and &lt;em&gt;package source&lt;/em&gt; should be exactly the same as we have in our nuget.config file. Refer to the nuget.config file that we created earlier before adding package source in Nuget package manager.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F12a6hfhebipn6mfzvbzp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F12a6hfhebipn6mfzvbzp.png" alt="config2.png" width="800" height="91"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  That's it.
&lt;/h2&gt;

&lt;p&gt;Now we can create and publish our projects as NuGet packages and use them within our organization/team in our next .Net projects. &lt;/p&gt;

&lt;p&gt;Please ❤️ this article and share this with others too. &lt;/p&gt;

&lt;h3&gt;
  
  
  Thanks for reading ❤️
&lt;/h3&gt;

</description>
      <category>dotnet</category>
      <category>github</category>
      <category>nuget</category>
      <category>packages</category>
    </item>
  </channel>
</rss>
