Hono is a small, simple, and ultrafast web framework for the Edges.
If you are using Hono
with typia
, you can use @hono/typia-validator
to validate the request body.
import { Hono } from "hono";
import { typiaValidator } from '@hono/typia-validator'
import typia, { type tags } from "typia";
import { IBbsArticle } from "../structures/IBbsArticle";
/** create a validate function */
const validate = typia.createValidate<IBbsArticle>();
const app = new Hono();
app.post("/",
typiaValidator('json', validate),
(c) => {
const data = c.req.valid("json");
return c.json({
id: data.id,
title: data.title,
body: data.body,
created_at: data.created_at,
});
});
export default app;