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

hono-tencent-cloudbase-cloud-function-adapter

v1.1.1

Published

An adapter for using Hono with Tencent CloudBase Cloud Function

Readme

Hono Tencent CloudBase Cloud Function Adapter

Build NPM Version GitHub License

An adapter for using Hono with Tencent CloudBase Cloud Function.

一个用于在腾讯云开发云函数 中使用 Hono 的适配器。

Requirements

  • Node.js 18.0.0 or higher
  • Tencent CloudBase Cloud Function environment

Installation

npm install hono-tencent-cloudbase-cloud-function-adapter

Usage

CommonJS (Node.js 18+)

const { Hono } = require("hono");
const { handle } = require("hono-tencent-cloudbase-cloud-function-adapter");

const app = new Hono();

app.get("/", (c) => c.text("Hello Hono!"));

exports.handler = handle(app);

ES Module (Node.js 18+)

For ES Module support in Tencent CloudBase, you need a hybrid approach:

index.js (CommonJS entry point - required by CloudBase):

exports.main = async (event, context) => {
    const { entry } = await import('./entry.mjs');
    return entry(event, context);
};

entry.mjs (ES Module):

import { Hono } from "hono";
import { handle } from "hono-tencent-cloudbase-cloud-function-adapter";

const app = new Hono();

app.get("/", (c) => c.text("Hello Hono!"));

const handler = handle(app);

export const entry = (event, context) => {
  return handler(event, context);
};

package.json:

{
  "type": "module",
  "dependencies": {
    "hono": "^4.6.12",
    "hono-tencent-cloudbase-cloud-function-adapter": "^1.0.0"
  }
}

TypeScript

import { Hono } from "hono";
import { handle } from "hono-tencent-cloudbase-cloud-function-adapter";

const app = new Hono();

app.get("/", (c) => c.text("Hello Hono!"));

export const handler = handle(app);

For more details, check out:

Example

Here's a complete example of how to use this adapter in a Tencent CloudBase Cloud Function:

import { Hono } from "hono";
import { handle } from "hono-tencent-cloudbase-cloud-function-adapter";

const app = new Hono();

// Basic route
app.get("/", (c) => c.text("Hello from Tencent CloudBase!"));

// JSON response
app.get("/api/user", (c) => {
  return c.json({ name: "John", age: 30 });
});

// Handle POST requests
app.post("/api/data", async (c) => {
  const body = await c.req.json();
  return c.json({ received: body });
});

// Handle timer trigger events
// Timer events are automatically converted to GET requests with path: /CLOUDBASE_TIMER_TRIGGER/${TriggerName}
app.get("/CLOUDBASE_TIMER_TRIGGER/:triggerName", (c) => {
  const triggerName = c.req.param("triggerName");

  // Access the original timer event from the environment
  const originalTimerEvent = c.env?.originalTimerEvent;

  console.log(`Timer triggered: ${triggerName}`);
  console.log(`Timer event:`, originalTimerEvent);

  // Perform your scheduled task here
  return c.json({
    message: `Timer ${triggerName} executed successfully`,
    timestamp: new Date().toISOString(),
    originalEvent: originalTimerEvent,
  });
});

// Export the handler for CloudBase
export const handler = handle(app);

Timer Trigger Support

This adapter supports Tencent CloudBase timer trigger events. Timer events are automatically converted to HTTP GET requests with a special path format.

Timer Configuration

Configure your timer trigger in the CloudBase function configuration:

{
  "triggers": [
    {
      "name": "myTrigger",
      "type": "timer",
      "config": "*/5 * * * * * *"
    }
  ]
}

Timer Event Handling

Timer events are automatically converted to GET requests with the path /CLOUDBASE_TIMER_TRIGGER/${TriggerName}:

import { Hono } from "hono";
import { handle } from "hono-tencent-cloudbase-cloud-function-adapter";

const app = new Hono();

// Handle timer trigger events
app.get("/CLOUDBASE_TIMER_TRIGGER/:triggerName", (c) => {
  const triggerName = c.req.param("triggerName");

  // Access the original timer event from the environment
  const originalTimerEvent = c.env?.originalTimerEvent;

  console.log(`Timer triggered: ${triggerName}`);
  console.log(`Original event:`, originalTimerEvent);

  // Perform your scheduled task here
  return c.json({
    message: `Timer ${triggerName} executed successfully`,
    timestamp: new Date().toISOString(),
  });
});

export const handler = handle(app);

Timer Event Structure

The original timer event is available in c.env.originalTimerEvent with the following structure:

{
  Message: string;
  Time: string;        // ISO 8601 timestamp
  TriggerName: string; // The name of the timer trigger
  Type: "Timer";
}

Example timer event:

{
  "Message": "",
  "Time": "2025-06-11T05:06:40Z",
  "TriggerName": "myTrigger",
  "Type": "Timer"
}

Event Format

The adapter automatically converts Tencent CloudBase HTTP events to standard Request objects and Response objects back to CloudBase format.

HTTP Event Structure

{
  path: string;
  httpMethod: string;
  headers: Record<string, string>;
  queryStringParameters: Record<string, string>;
  requestContext: {
    requestId: string;
    envId: string;
    appId: number;
    uin: number;
  };
  body: string;
  isBase64Encoded: boolean;
}