Comments (16)
Here's one - https://github.com/wobsoriano/elysia-autoroutes
from elysia.
I also made an implementation of a file system routing plugin, based on groups, called the group router.
from elysia.
@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
from elysia.
+1, I would be really interested in this, I was just about to raise a proposal for this exactly.
from elysia.
But Elysia doesn't really have frontend part so file based routing for api doesn't make sense..?
from elysia.
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.
from elysia.
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
from elysia.
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
from elysia.
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.
from elysia.
was just randomly reading the bun docs today and saw it has a native FileSystemRouter
API that may be of use here
https://bun.sh/docs/api/file-system-router
from elysia.
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!
from elysia.
@wobsoriano Did you manage to get eden types to work with it?
from elysia.
No. That's the biggest challenge @m1212e - how do we combine types from the main ElysiaApp instance with the route files?
from elysia.
I don't see a way to do this without running some kind of process at development time.
from elysia.
@m1212e what other meta framework do, like Nuxt, is to generate types for each route at dev time
from elysia.
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.
from elysia.
Related Issues (20)
- t.Literal type is ignored in favor of string during validation
- Eden Treaty ignores t.Transform()
- "default" option is not being applied on validation HOT 5
- Ability to create and remove websocket endpoints at runtime.
- Macro modify schema HOT 1
- Rxjs pipe syntax
- Nullable field for types as documented in OpenAPI 3.0 HOT 1
- Support for classes and getter fields
- Transform type (include Date) won't transform in Array schema
- Decorates are replacing each other HOT 5
- Query params validation for array of string fail at 1.0.23 HOT 5
- Plugin registered by async inline function don't work
- Cookie Schema doesn't work in instances HOT 1
- Return 405 error for wrong method on a resource, rather than 404
- Failed to bind socket in linux
- `mapResponse` is completely ignored HOT 2
- Please Export Typebox Types HOT 1
- staticPlugin didn't supply chinese path
- Context object not correctly passed to handler HOT 2
- Cannot use Plain Typebox Types for Schema
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elysia.