HonoH
Hono7mo ago
Sun

Extending the Context type

So, I've made a function to work to with @arrirpc/schema (yes, it's a validator), so I can use it like this
export const routes = new Hono()
  .get("/", async (c) => {
    return respondWith(c, HealthSchema, {
      status: 200,
      title: "Health Check",
      data: {
        message: "Health is OK!",
      }
    });
  });
The "problem" is that it feels kinda weird, having to pass in the context that way. It does't really feel like the rest of the hono stuff (respondWith(c, schema, data) vs c.respondWith(schema, data) or even better, as a middleware, but I don't know how to do that on hono)

Is there a way I can make it better user experience or do I need to create a validator middleware there?
Was this page helpful?