-
-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to generate tRPC routes under one schema using different procedures? For example I have a users table and I want the fetch routes to be public but the create and update routes are protected. How could I achieve that? Thank you. #1057
Comments
Hi @damonleelcx , trpc routers are objects so I believe you can delete some member procedures of it. I haven't tried it myself yet though. |
Thanks for replaying. |
What I meant was to call // without mutation
const router1 = createRouter(createTRPCRouter, publicProcedure);
delete router1['user']['create'];
...
// all methods
const router2 = createRouter(createTRPCRouter, protectedProcedure); Also maybe a cleaner solution is putting the checking logic inside the procedure middleware so that you can use one procedure for all the routes. |
This will work. Thank you. |
No description provided.
The text was updated successfully, but these errors were encountered: