cloudflare / chanfana

OpenAPI 3 and 3.1 schema generator and validator for Hono, itty-router and more!
https://chanfana.pages.dev
MIT License
263 stars 35 forks source link

itty-router 5 upgrade? #143

Closed marceloverdijk closed 2 weeks ago

marceloverdijk commented 2 months ago

Are there plans to upgrade itty-router 5?

G4brym commented 2 months ago

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

marceloverdijk commented 2 months ago

Are their any known breaking changes coming that is interesting to know when starting a new project now? Eg using native types vs zod?

G4brym commented 2 months ago

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

marceloverdijk commented 2 months ago

Oké, you also recommend using zod for defining the types in general, instead of the native/legacy approach?

AlecKriebel commented 1 month ago

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!

AlecKriebel commented 1 month ago

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!

marceloverdijk commented 2 weeks ago

This can be closed as Chanfana is now based on itty-router 5 (change)