
Show HN: A file tree based API Router - aliezsid
https://github.com/barelyhuman/routex
======
rajnathani
I created something I believe is exactly like this a while ago, one called
xrest [0] which resolves the API endpoint routes from the file tree structure
at runtime, and another called restree [1] which generates the routes before
runtime by generating code.

[0] [https://github.com/rajnathani/xrest](https://github.com/rajnathani/xrest)

[1]
[https://github.com/rajnathani/restree](https://github.com/rajnathani/restree)

~~~
aliezsid
Oh nice, good approach. I went with Native http for performance reasons

------
MH15
This is very interesting, similar to serverless functions on Vercel or many
other services. Will be interested to give it a try. Can you explain why there
needs to be a compilation step?

~~~
aliezsid
I create a tree similar to the file structure that is used by the actual
router when it handles requests to figure out which handler to pass the `req`
and `res` objects. This is in the stable(`master`) branch.

The `canary` branch implements the same thing but instead of a object tree ,
it creates a flat object and uses regex's to find the registered handler which
is faster but creates an overlap which I'm trying to fix.

In simple senses, it there's to make sure that the router only passes down the
req,res to the valid handler and doesn't do any other processing other than
maybe, query parsing and param parsing

