dpeter
dpeter
HHono
Created by dpeter on 12/28/2024 in #help
Hono not inferring output correctly with RPC
Im having an issue related to the output of hono RPC. I have this route to check if an organization exists by slug.
const app = new Hono<{
Variables: {
session: Session | null
}
}>()
.use(authMiddleware)
.get(
'/:slug/available',
zValidator(
'param',
z.object({
slug: z.string(),
}),
),
async (c) => {
const session = c.get('session')
const user = session?.user

if (!user) return c.body(null, 401)

const { slug } = c.req.valid('param')

const useCase = makeOrgExistsBySlugUseCase()

const { exists } = await useCase.execute({ slug })

return c.json({ available: !exists }, 200)
},
)

export default app
const app = new Hono<{
Variables: {
session: Session | null
}
}>()
.use(authMiddleware)
.get(
'/:slug/available',
zValidator(
'param',
z.object({
slug: z.string(),
}),
),
async (c) => {
const session = c.get('session')
const user = session?.user

if (!user) return c.body(null, 401)

const { slug } = c.req.valid('param')

const useCase = makeOrgExistsBySlugUseCase()

const { exists } = await useCase.execute({ slug })

return c.json({ available: !exists }, 200)
},
)

export default app
And in my AppType the Input is being inferred properly but the output is just an empty object:
MergeSchemaPath<{
"/:slug/available": {
$get: {
input: {
param: {
...;
};
};
output: {};
outputFormat: string;
status: StatusCode;
};
};
}, "/organizations">, "/">
MergeSchemaPath<{
"/:slug/available": {
$get: {
input: {
param: {
...;
};
};
output: {};
outputFormat: string;
status: StatusCode;
};
};
}, "/organizations">, "/">
What am i doing wrong?
17 replies