wobsoriano/elysia-autoroutes

Generate TypeSafe Signatures from Hooks and ElysiaApp

Closed this issue · 2 comments

framp commented

Thanks a lot for the awesome library!

I created some basic utilities to extend the signature for Params & Body:
https://github.com/framp/elysia-demo/blob/f66ed0e/src/utils.ts

they can be used like this: https://github.com/framp/elysia-demo/blob/f66ed0e/src/http/api/books/%5Bid%5D.ts
but they're not very user friendly

I'm pretty sure we can autogenerate all of this by getting the app as an input and knowing which params have been defined through the filepath and what's the type of the handler.

Another completely different option could be to define a route using an Elysia instance; we should be able to set the type to the parent instance (Elysia App in your example) for type safety and then access the methods from the child instance from autoroutes.

I'll try to come up with a PR to address some of this

I'm going to review this PR today. Thank you!