itty-router 5 upgrade?
marceloverdijk opened this issue · 7 comments
Are there plans to upgrade itty-router 5?
Hey @marceloverdijk yes, there are plans to upgrade, but the new itty-router version includes some breaking changes that we want to bundle with our own breaking changes in a single release
so it is going to take some time
Are their any known breaking changes coming that is interesting to know when starting a new project now? Eg using native types vs zod?
there are still no known breaking changes, neither a date for the new release, we just want to bundle the breaking changes all together, so customers only need to upgrade once
but we do recommend using Zod whenever possible, as that is never going to change
Oké, you also recommend using zod for defining the types in general, instead of the native/legacy approach?
CORS is broken in itty-router
v4, so I attempted to upgrade this library to itty-router
v5. In short, what I found is that, in v4 route handlers are typed as objects:
export type RouteHandler<I = IRequest, A extends any[] = any[]> = {
(request: I, ...args: A): any
}
but in v5, they're typed as functions:
export type RequestHandler<
RequestType = IRequest,
Args extends Array<any> = any[]
> = (request: RequestType, ...args: Args) => any
I assume this means this upgrade will cause some changes to passing in classes.
V5 itty-router is still very much needed for this library, but wanting to bundle with others, I'll hold off on working on this further and putting up a PR. If I can help out here, let me know!
For anyone also experiencing CORS issues, I solved the createCors
issue in my project using itty-router-openapi
by copying itty-router
v5's cors
implementation directly into my project, and using that in place of createCors
.
I'll delete this when itty-router-openapi
upgrades to itty-router
v5!
This can be closed as Chanfana is now based on itty-router 5 (change)