Demystifying Routing: Creating Your Own file-path-based Router

<p>One trend that most JavaScript frameworks are adopting is to provide path-based routing. This means that there is a 1:1 relationship between whatever URL you want to visit and a special folder within your project, containing the route handler functions.</p> <p>That is to say, if you visit&nbsp;<code>http://&lt;your host&gt;/users/list</code>&nbsp;you&rsquo;ll have the handler function inside the&nbsp;<code>users/list.js</code>&nbsp;file (or perhaps within the&nbsp;<code>users/list/index.js</code>&nbsp;depending on your preferences).</p> <p>This is a very nice feature, and one that we take for granted with frameworks like Next, Fresh or others.</p> <p>That said, I hate taking things for granted, so I&rsquo;ll try to reverse-engineer how that works in this article.</p> <p>Let&rsquo;s take a look at how to implement your own version of path-based routing using Express.</p> <p><a href="https://blog.bitsrc.io/demystifying-routing-creating-your-own-file-path-based-router-e5f7245a4925">Read More</a></p>