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 🙏

© 2024 – Pkg Stats / Ryan Hefner

tsoa-hono

v1.2.2

Published

A library for integrating the hono router with tsoa

Downloads

279

Readme

tsoa-hono

tsoa-hono is an npm library that integrates tsoa with the hono router. With this library, you can run tsoa seamlessly in a variety of environments, such as Node.js, Cloudflare Workers, Deno, and AWS Edge Lambdas.

Features

  • Provides a template file for easy setup and integration of tsoa with the hono router.
  • Supports a wide range of environments, ensuring versatility and adaptability.

The tsoa-hono uses the fluent API from hono that returns a typed router. This allows you to use the output of the RegisterRoutes function with the hono/testing library:

const app = new Hono();
const tsoaApp = RegisterRoutes<typeof app>(app);

const response = await testClient(tsoaApp).basic.$get();

const body = await response.text();

Installation

Install via npm:

npm install tsoa-hono

Setup

  1. Ensure you have a tsoa configuration file (tsoa.json) in your project root. If not, create one.
  2. Add or modify the configuration as follows:
{
  "entryFile": "src/app.ts",
  "noImplicitAdditionalProperties": "throw-on-extras",
  "controllerPathGlobs": ["src/**/*Controller.ts"],
  "spec": {
    "outputDirectory": "build",
    "specVersion": 3
  },
  "routes": {
    "routesDir": "build",
    "middlewareTemplate": "node_modules/tsoa-hono/hono-router.hbs"
  }
}
  • entryFile: The main entry file for your application.
  • noImplicitAdditionalProperties: Control how additional properties in the request body are treated.
  • controllerPathGlobs: A pattern to find your controllers.
  • spec: Specifications related to your API.
  • routes: Configuration for your route generation.

Usage

Once the tsoa.json configuration is set up, run your tsoa command as you normally would. The integration with the hono router will be handled by the library using the provided template.

Middlewares

The middlewares are based on hono and return a Response object. As the hono Next function doesn't return anything according to the Typescript definition, the tsoa-hono library uses a different Typescript type for the Next function that is part of the package.

async function customMiddleware(ctx: Context, next: Next) {
  const response = await next();

  response.headers.set('customMiddleware', 'true');
  return response;
}

Support

If you encounter any issues or have questions related to the library, please refer to our GitHub repository.

License

MIT


We hope tsoa-hono helps streamline your development process!