-
-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filesystem based routing? #65
Comments
+1, I would be really interested in this, I was just about to raise a proposal for this exactly. |
But Elysia doesn't really have frontend part so file based routing for api doesn't make sense..? |
This has nothing to do with frontend or not. For reference, check Next.js route handler implementation for a file-system based api. |
I didn't play with file based api, from one side looks like overhead of splitting everything |
I don't think it would be too hard to make your own simple implementation |
Here's one - https://github.com/wobsoriano/elysia-autoroutes |
I also made an implementation of a file system routing plugin, based on groups, called the group router. |
There are a few options, you could calculate the routes based on the current file path and just pass a helper function to spit out the correct relative path based on the file location, you could also utilize the bun.js macros/build plugins to set the correct path at build time. But what I could not get to work properly was the eden type safety. Since it works without code generation and TS does not support build time macros, I don't really seee a way to pull this off. Maybe one of the elysia devs knows how to implement something like this. |
was just randomly reading the bun docs today and saw it has a native |
elysia-autoroutes uses it! |
@wobsoriano Did you manage to get eden types to work with it? |
No. That's the biggest challenge @m1212e - how do we combine types from the main ElysiaApp instance with the route files? |
I don't see a way to do this without running some kind of process at development time. |
@m1212e what other meta framework do, like Nuxt, is to generate types for each route at dev time |
@wobsoriano Actually, I tried to do something similar here (with not much success): #79 |
Closing as we have several plugins like Elysia Autoroute, Group Router and several other. Elysia is not going to focus on File Based Routing at the moment. |
Hi,
I recently got into bun and was looking for a nice webframework which supports filesystem based routing. I like it because it - by design - enforces a clear structure for the project and you know where to find a certain route. Elysia does a few other things really really well in my opinion so I thought about using it but as far as I see it does not support fs based routes. Is this a thing you considered? Maybe also in a hybrid approach like I did here: https://github.com/m1212e/bun-fs-router-plugin
The text was updated successfully, but these errors were encountered: