ethanniser / next-typesafe-url

Fully typesafe, JSON serializable, and zod validated URL search params, dynamic route params, and routing for NextJS.
https://next-typesafe-url.dev
MIT License
362 stars 16 forks source link

Role Based Access Control For Routing #95

Closed balibintang closed 5 months ago

balibintang commented 5 months ago

Hey Ethan,

Love the project and the overall structure of it. We're currently using it for routing at our company but the overall structure of the package and the RouteType.ts files makes it near perfect for route based access control. I was wondering if you'd be open to me extending this with the following proposal:

Proposal

Why this project The work thats been setup in this project to watch the next directory structure as well as it being centralised in routing makes it an ideal candidate for this implementation.

Im happy to fork the project and work on it in isolation but was wondering if you'd be interested in having this within the project itself.

ethanniser commented 5 months ago

Thank you for using the library and thank you for this proposal.

I think producing any side effects, or modifying the control flow of a request (outside of validation failing) is strictly out of scope for this package. In my eyes, next-typesafe-url's role at runtime is only to deserialize and validate the incoming search/route params.

However, I do understand your use case. My recommendation would be to explore something like whopio/next-app-middleware (likely other similar solutions out there as well), in conjunction with next-typesafe-url's parseServerSideParams

Let me know if there is anything else I can help with

balibintang commented 5 months ago

Not a problem,

Thanks for making your work public! That makes sense given the targeted scope of the project.

I just had a read through the linked package and a mixture of both does seem like a good solution, thanks for the recommendation.