mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-01-14 12:14:40 +01:00
eslint fixes
This commit is contained in:
@@ -8,12 +8,12 @@ export default createNuxtApiHandler({
|
||||
* @link https://trpc.io/docs/context
|
||||
*/
|
||||
createContext,
|
||||
onError({ error }) {
|
||||
onError ({ error }) {
|
||||
if (error.code === 'INTERNAL_SERVER_ERROR') {
|
||||
// send to bug reporting
|
||||
console.error('Something went wrong', error)
|
||||
}
|
||||
},
|
||||
}
|
||||
/**
|
||||
* @link https://trpc.io/docs/caching#api-response-caching
|
||||
*/
|
||||
|
||||
@@ -8,8 +8,8 @@ export type Context = inferAsyncReturnType<typeof createContext>
|
||||
* Creates context for an incoming request
|
||||
* @link https://trpc.io/docs/context
|
||||
*/
|
||||
export async function createContext(
|
||||
opts: H3Event,
|
||||
export function createContext (
|
||||
opts: H3Event
|
||||
) {
|
||||
// for API-response caching see https://trpc.io/docs/caching
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { userRouter } from './user'
|
||||
|
||||
export const appRouter = router({
|
||||
todo: todoRouter,
|
||||
user: userRouter,
|
||||
user: userRouter
|
||||
})
|
||||
|
||||
export type AppRouter = typeof appRouter
|
||||
|
||||
@@ -7,7 +7,7 @@ const TodoShape = z.object({
|
||||
userId: z.number(),
|
||||
id: z.number(),
|
||||
title: z.string(),
|
||||
completed: z.boolean(),
|
||||
completed: z.boolean()
|
||||
})
|
||||
|
||||
export type Todo = z.infer<typeof TodoShape>
|
||||
@@ -27,7 +27,7 @@ export const todoRouter = router({
|
||||
.mutation((req) => {
|
||||
return $fetch<Todo>(`${baseURL}/todos`, {
|
||||
method: 'POST',
|
||||
body: req.input,
|
||||
body: req.input
|
||||
})
|
||||
}),
|
||||
})
|
||||
})
|
||||
|
||||
@@ -7,7 +7,7 @@ const UserShape = z.object({
|
||||
id: z.number(),
|
||||
name: z.string(),
|
||||
username: z.string(),
|
||||
email: z.string(),
|
||||
email: z.string()
|
||||
})
|
||||
|
||||
export type User = z.infer<typeof UserShape>
|
||||
@@ -27,7 +27,7 @@ export const userRouter = router({
|
||||
.mutation((req) => {
|
||||
return $fetch<User>(`${baseURL}/users`, {
|
||||
method: 'POST',
|
||||
body: req.input,
|
||||
body: req.input
|
||||
})
|
||||
}),
|
||||
})
|
||||
})
|
||||
|
||||
@@ -5,19 +5,19 @@ import type { Context } from './context'
|
||||
|
||||
const t = initTRPC.context<Context>().create({
|
||||
transformer: superjson,
|
||||
errorFormatter({ shape, error }) {
|
||||
errorFormatter ({ shape, error }) {
|
||||
return {
|
||||
...shape,
|
||||
data: {
|
||||
...shape.data,
|
||||
zodError:
|
||||
error.code === 'BAD_REQUEST'
|
||||
&& error.cause instanceof ZodError
|
||||
error.code === 'BAD_REQUEST' &&
|
||||
error.cause instanceof ZodError
|
||||
? error.cause!.flatten()
|
||||
: null,
|
||||
},
|
||||
: null
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user