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
V9 refactoring and cleanup #732
Conversation
This pull request is being automatically deployed with Vercel (learn more). www – ./www🔍 Inspect: https://vercel.com/trpc/www/9ocnssrTJBNMfbpkMu2KUNoTuDs1 todomvc – ./examples/next-prisma-todomvc🔍 Inspect: https://vercel.com/trpc/todomvc/4AtubuWG1U2EufXWfFgy9zpEqGcL |
# Conflicts: # packages/server/test/index.test.tsx # packages/server/test/middleware.test.ts # www/docs/server/authorization.md
# Conflicts: # packages/server/test/middleware.test.ts
@@ -12,8 +12,7 @@ const JSONRPC2_TO_HTTP_CODE: Record< | |||
> = { | |||
PARSE_ERROR: 400, | |||
BAD_REQUEST: 400, | |||
METHOD_NOT_FOUND: 405, | |||
PATH_NOT_FOUND: 404, | |||
NOT_FOUND: 404, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why no 405 METHOD_NOT_ALLOWED?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's removed now anyway :)
@@ -270,7 +270,7 @@ describe('integration tests', () => { | |||
trpc.router<Context>().query('whoami', { | |||
async resolve({ ctx }) { | |||
if (!ctx.user) { | |||
throw trpc.httpError.unauthorized(); | |||
throw new TRPCError({ code: 'UNAUTHORIZED' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likimng this syntax 👍🏻
Think this PR along with #718 settles what I want to do with the next major update.
Keen to have any input on other fundamentals people / API surfaces or shapes that people think should change (including if you disagree with the changes here) - ping @cyrus-za / @anthonyshort / @peterp / @mmkal .
Summary of changes
TRPCError
s -METHOD_NOT_FOUND
removed &PATH_NOT_FOUND
renamed toNOT_FOUND
(closes ReduceTRPCError
-codes #733)httpErrors
-helper?input
to be an array - now assuming aRecord<number, unknown>
-style dict (changed with backwards compat in fix: batching with zod.optional()
input #669)POST
calls being{ input: x }
(originally from flatten post requests'input
#671)