-
|
How can I pass the specific context type from app.post(
"/register-user",
zValidator("json", registerUserReqSchema),
registerUser
);
async function registerUser(c: Context) {
const validBody = c.req.valid("json"); // Argument of type 'string' is not assignable to parameter of type 'never'.ts(2345)
const body = await c.req.json<NewUserReq>(); // works correctly
}also tried to infer from c auth.post(
"/register-user",
zValidator("json", registerUserReqSchema),
async (c) => registerUser(c)
);
// c type for /register-user
//(parameter) c: Context<{}, "/register-user", {
// in: {
// json: {
// email: string,
// username: string;
// };
// };
// out: {
// ...;
// };
// }> |
Beta Was this translation helpful? Give feedback.
Answered by
hjaber
Apr 19, 2025
Replies: 1 comment
-
|
You don't. This has been clearly documented for a long time. https://hono.dev/docs/guides/best-practices#don-t-make-controllers-when-possible |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
hjaber
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You don't. This has been clearly documented for a long time.
https://hono.dev/docs/guides/best-practices#don-t-make-controllers-when-possible