c.json( { status: "error", errors: [ { path: "email", message: "Email address does not exist", }, ], }, 400, );
mutationFn: async (data) => { const res = await $post({ json: data }); if (!res.ok) throw new Error(res.statusText); return res.json(); }, onSuccess: (data) => { console.log(data); }, onError: (error) => { return console.log(error); },
const app = new Hono() .post( "/signin", zValidator("json", signInRequestSchema, (result, c) => { if (!result.success) { return c.json( { success: false, errors: errorBag.generateErrors(result.error.errors), }, 400, ); } }), async (c) => { const existingUser = await db.query.usersTable.findFirst({ where: eq(usersTable.email, c.req.valid("json").email), }); if (!existingUser) { return c.json( { success:false, errors: [ { path: "email", message: "Email address does not exist", }, ], }, 400, ); } // More work return c.json({ success: true, data: { user: {} }, }); }, )