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

@see7788/testtaro-honolib

v1.0.2

Published

一个为 Hono 框架提供扩展功能的工具库,包含两个独立模块:

Readme

honolib

一个为 Hono 框架提供扩展功能的工具库,包含两个独立模块:

  • taroHc - Taro 环境下的 Hono 客户端适配器
  • vitePkg - 将 Vite 前端应用集成到 Hono 服务器

安装

pnpm add @see7788-testtaro/honolib

模块说明

1. taroHc

功能:Taro 环境下的 Hono 客户端适配器,使 Hono 的 hc 客户端能够在 Taro 应用中正常工作。

适用场景:小程序、H5 等 Taro 环境中的 API 调用。

使用示例

import { taroHc } from '@see7788-testtaro/honolib';
import type { AppType } from '../api/routes'; // 导入 API 类型定义

// 创建客户端
const client = taroHc<AppType>('https://api.example.com');

// 调用 GET 请求
async function getUser() {
  try {
    const response = await client.users.get({
      query: { id: 123 }
    });
    const user = await response.json();
    console.log('User:', user);
  } catch (error) {
    console.error('Error:', error);
  }
}

// 调用 POST 请求
async function createUser() {
  try {
    const response = await client.users.post({
      json: {
        name: 'John Doe',
        email: '[email protected]'
      }
    });
    const result = await response.json();
    console.log('Created user:', result);
  } catch (error) {
    console.error('Error:', error);
  }
}

依赖要求

  • @tarojs/taro (v4.0.0+)
  • hono (v4.0.0+)

2. vitePkg

功能:将 Vite 前端应用集成到 Hono 服务器,实现前后端一体化部署。

适用场景:需要在 Hono 服务器中托管前端应用的场景。

使用示例

import { Hono } from 'hono';
import { serve } from '@hono/node-server';
import { vitePkg } from '@see7788-testtaro/honolib';

// 创建主应用
const app = new Hono();

// 添加 API 路由
app.get('/api/hello', (c) => {
  return c.text('Hello from API');
});

// 添加前端应用
app.route('/frontend', await vitePkg('frontend'));

// 启动服务器
serve({
  fetch: app.fetch,
  port: 3000
});

依赖要求

  • hono (v4.0.0+)
  • @hono/node-server
  • vite

vitePkg 特定配置

开发命令

仅适用于 vitePkg:在 Hono 应用中添加以下开发命令:

"dev:honoapp": "set NODE_ENV=development&&node --loader tsx ./src/index.ts"

注意:使用 tsx 直接运行 TypeScript 文件,无需额外的热更新工具。

环境变量

仅适用于 vitePkg

  • NODE_ENV:用于区分开发模式和生产模式
    • development:使用 Vite 开发服务器
    • production:构建静态文件并使用 serveStatic

路径解析

仅适用于 vitePkgvitePkg 模块使用以下代码解析前端应用的路径:

path.resolve(process.cwd(), '..', ...pkgpath)

pkgpath 参数说明

  • pkgpath 是一个字符串数组,用于指定前端应用的目录路径
  • 从当前工作目录(Hono 服务器所在目录)的上一级目录开始解析

使用示例

  • 前端应用在 ../frontend 目录:vitePkg('frontend')
  • 前端应用在 ../apps/frontend 目录:vitePkg('apps', 'frontend')
  • 前端应用在 ../src/apps/frontend 目录:vitePkg('src', 'apps', 'frontend')

灵活性vitePkg 采用灵活的路径解析方式,不依赖于特定的目录结构。

注意事项

  • taroHc

    • 需要在 Taro 环境中使用
    • 依赖 @tarojs/taro
  • vitePkg

    • 前端应用需要有完整的 Vite 配置
    • 生产模式下会自动构建前端应用到 dist 目录
    • 开发模式下支持热更新和实时编译
  • 通用

    • 使用前请确保已安装 Hono 框架

直接使用

您可以直接在项目中导入并使用 honolib 模块,无需额外配置:

// 在 Taro 项目中使用 taroHc
import { taroHc } from '@see7788-testtaro/honolib';

// 在 Hono 服务器中使用 vitePkg
import { vitePkg } from '@see7788-testtaro/honolib';

使用 honolib 模块

使用 honolib 模块

注意:使用前请确保已安装所需依赖。