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.
SDK availability
@checkupstream/sdk 0.1.0 is on npm and records requests made with fetch. The browser package is not published; contact us for access. Check the SDK reference for your runtime and review what the SDK sends.1. Install
Bash
npm install @checkupstream/sdk2. 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 });Note
Use the environment and shutdown facilities of your deployment runtime. This example uses Node.js environment variables; it is not a Cloudflare Workers setup.
Related
Continue your setup
Check runtime availability and credentials before deploying an integration.