docs: replace jsonT with json (#328)

pull/322/head
Sor4chi 2023-12-29 04:25:02 +09:00 committed by GitHub
parent 616afbcd03
commit 009cc77cf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 8 deletions

View File

@ -88,7 +88,7 @@ const app = new OpenAPIHono()
app.openapi(route, (c) => {
const { id } = c.req.valid('param')
return c.jsonT({
return c.json({
id,
age: 20,
name: 'Ultra-man',
@ -157,7 +157,7 @@ app.openapi(
route,
(c) => {
const { id } = c.req.valid('param')
return c.jsonT({
return c.json({
id,
age: 20,
name: 'Ultra-man',
@ -166,7 +166,7 @@ app.openapi(
// Hook
(result, c) => {
if (!result.success) {
return c.jsonT(
return c.json(
{
code: 400,
message: 'Validation Error',
@ -186,7 +186,7 @@ In the case that you have a common error formatter, you can initialize the `Open
const app = new OpenAPIHono({
defaultHook: (result, c) => {
if (!result.success) {
return c.jsonT(
return c.json(
{
ok: false,
errors: formatZodErrors(result),
@ -205,7 +205,7 @@ You can still override the `defaultHook` by providing the hook at the call site
// uses the defaultHook
app.openapi(createPostRoute, (c) => {
const { title } = c.req.valid('json')
return c.jsonT({ title })
return c.json({ title })
})
// override the defaultHook by passing in a hook
@ -213,11 +213,11 @@ app.openapi(
createBookRoute,
(c) => {
const { title } = c.req.valid('json')
return c.jsonT({ title })
return c.json({ title })
},
(result, c) => {
if (!result.success) {
return c.jsonT(
return c.json(
{
ok: false,
source: 'routeHook' as const,
@ -279,7 +279,7 @@ import { hc } from 'hono/client'
const appRoutes = app.openapi(route, (c) => {
const data = c.req.valid('json')
return c.jsonT({
return c.json({
id: data.id,
message: 'Success',
})