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?
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
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.
4 comments
[ 7.3 ms ] story [ 66.1 ms ] threadThe `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
[0] https://github.com/rajnathani/xrest
[1] https://github.com/rajnathani/restree