update readme

This commit is contained in:
Robert Soriano
2022-05-19 00:38:27 -07:00
parent a3d2f61861
commit 4ac104943d
7 changed files with 130 additions and 60 deletions

View File

@@ -14,6 +14,19 @@ const fakeUsers = [
export const router = trpc
.router<inferAsyncReturnType<typeof createContext>>()
.formatError(({ shape, error }) => {
return {
...shape,
data: {
...shape.data,
zodError:
error.code === 'BAD_REQUEST'
&& error.cause instanceof ZodError
? error.cause.flatten()
: null,
},
}
})
.query('getUsers', {
resolve() {
return fakeUsers