Closed m1212e closed 11 months ago
+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..?
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.
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 on the other looks like a good solution to extract those and make smaller
I don't think it would be too hard to make your own simple implementation See the "However, it isn't too difficult to make a file-based router. Here's a file-based example code with builder:" part of the Waku docs
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 FileSystemRouter
API that may be of use here
was just randomly reading the bun docs today and saw it has a native
FileSystemRouter
API that may be of use here
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
@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): https://github.com/elysiajs/elysia/issues/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. All the discussion will be moving to #79 or feels free to open a new issue for dedicated topic.
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