Skip to main content
All recipes

Hono

CodeMiddlewareNode.js

This example runs Hono on Node.js with @hono/node-server. The middleware initializes the SDK and measures supported outbound fetch calls. Confirm SDK support separately before using an edge runtime.

1. Install

Bash
npm install @checkupstream/sdk

2. Mount the middleware

src/index.ts
import { Hono } from "hono";
import { serve } from "@hono/node-server";
import { checkUpstreamMiddleware } from "@checkupstream/sdk/integrations/hono";

const sdkKey = process.env.CHECKUPSTREAM_SDK_KEY;
if (!sdkKey) throw new Error("Set CHECKUPSTREAM_SDK_KEY before starting the app");

const app = new Hono();

app.use(
  "*",
  checkUpstreamMiddleware({
    sdkKey,
  }),
);

app.get("/api/users", async (c) => {
  const response = await fetch("https://api.github.com/zen");
  return c.json({ message: await response.text() });
});

serve({ fetch: app.fetch, port: 3000 });

Continue your setup

Check runtime availability and credentials before deploying an integration.