npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rexeus/typeweaver-hono

v0.3.1

Published

Generates Hono routers and handlers straight from your API definitions. Powered by Typeweaver 🧵✨

Downloads

287

Readme

🧵✨ @rexeus/typeweaver-hono

npm version License TypeScript

Typeweaver is a type-safe HTTP API framework built for API-first development with a focus on developer experience. Use typeweaver to specify your HTTP APIs in TypeScript and Zod, and generate clients, validators, routers, and more ✨

📝 Hono Plugin

This plugin generates type-safe Hono routers from your typeweaver API definitions. For each resource, it produces a <ResourceName>Hono router class that sets up the routes, validates requests via the generated validators, and wires your handler methods with full type safety.


📥 Installation

# Install the CLI and the plugin as a dev dependency
npm install -D @rexeus/typeweaver @rexeus/typeweaver-hono

# Install the runtime as a dependency
npm install @rexeus/typeweaver-core

💡 How to use

npx typeweaver generate --input ./api/definition --output ./api/generated --plugins hono

More on the CLI in @rexeus/typeweaver.

📂 Generated Output

For each resource (e.g., Todo) this plugin generates a Hono router class, which handles the routing and request validation for all operations of the resource. This Hono router class can then be easily integrated into your Hono application.

Generated files are like <ResourceName>Hono.ts – e.g. TodoHono.ts.

🚀 Usage

Implement your handlers and mount the generated router in a Hono app.

// api/user-handlers.ts
import type { Context } from "hono";
import { HttpStatusCode } from "@rexeus/typeweaver-core";
import type { IGetUserRequest, GetUserResponse, UserNotFoundErrorResponse } from "./generated";
import { GetUserSuccessResponse } from "./generated";

export class UserHandlers implements UserApiHandler {
    async handleGetUserRequest(request: IGetUserRequest, context: Context): Promise<GetUserResponse> {
      // Symbolic database fetch
      const databaseResult = {} as any;
      if (!databaseResult) {
        // Will be properly handled by the generated router and returned as a 404 response
        return new UserNotFoundErrorResponse({
          statusCode: HttpStatusCode.NotFound,
          header: { "Content-Type": "application/json" },
          body: { message: "User not found" },
        });
      }

      return new GetUserSuccessResponse({
        statusCode: HttpStatusCode.OK,
        header: { "Content-Type": "application/json" },
        body: { id: request.param.userId, name: "Jane", email: "[email protected]" },
      });
  },
  // Implement other operation handlers: handleCreateUserRequest, ...
}
// api/server.ts
import { serve } from "@hono/node-server";
import { Hono } from "hono";
import { UserHono } from "./generated";
import { UserHandlers } from "./user-handlers";

const app = new Hono();
const userHandlers = new UserHandlers();

// Configure the generated router
const userRouter = new UserHono({
  requestHandlers: userHandlers,
  validateRequests: true, // default, validates requests
  handleValidationErrors: true, // default: returns 400 with issues
  handleHttpResponseErrors: true, // default: returns thrown HttpResponse as-is
  handleUnknownErrors: true, // default: returns 500
});

// Mount the router into your Hono app
app.route("/", userRouter);

serve({ fetch: app.fetch, port: 3000 }, () => {
  console.log("Hono server listening on http://localhost:3000");
});

⚙️ Configuration

TypeweaverHonoOptions<RequestHandlers>

  • requestHandlers: object implementing the generated <ResourceName>ApiHandler interface
  • validateRequests (default: true): enable/disable request validation
  • handleValidationErrors: true | false | (err, c) => IHttpResponse,
    • If true (default), returns 400 Bad Request with validation issues in the body
    • If false, lets the error propagate
    • If function, calls the function with the error and context, expects an IHttpResponse to return, so you can customize the response in the way you want
  • handleHttpResponseErrors: true | false | (err, c) => IHttpResponse
    • If true (default), returns thrown HttpResponse as-is, they will be sent as the response
    • If false, lets the error propagate, which will likely result in a 500 Internal Server Error
    • If function, calls the function with the error and context, expects an IHttpResponse to return, so you can customize the response in the way you want
  • handleUnknownErrors: true | false | (err, c) => IHttpResponse
    • If true (default), returns 500 Internal Server Error with a generic message
    • If false, lets the error propagate and the Hono app can handle it (e.g., via middleware)
    • If function, calls the function with the error and context, expects an IHttpResponse to return, so you can customize the response in the way you want

You can also pass standard Hono options (e.g. strict, getPath, etc.) through the same options object.

📄 License

Apache 2.0 © Dennis Wentzien 2025