All recipes
Express
CodeMiddlewareNode.js
Mount the CheckUpstream middleware before your Express routes. It initializes the SDK once to measure outbound fetch calls; it does not attach incoming route or request context.
SDK access required
Node.js and browser packages are not on public npm yet. Contact us for access before following the installation steps. Check the SDK reference for your runtime and review what the SDK sends.
1. Install
Bash
npm install @checkupstream/sdk2. Mount the middleware
server.ts
import express from "express";
import { checkUpstreamMiddleware } from "@checkupstream/sdk/integrations/express";
const sdkKey = process.env.CHECKUPSTREAM_SDK_KEY;
if (!sdkKey) throw new Error("Set CHECKUPSTREAM_SDK_KEY before starting the app");
const app = express();
app.use(
checkUpstreamMiddleware({
sdkKey,
services: ["api.github.com", "api.stripe.com"],
}),
);
app.get("/api/users", async (_req, res) => {
// Outbound calls here are tracked automatically.
const response = await fetch("https://api.github.com/zen");
res.json({ message: await response.text() });
});
app.listen(3000);Note
Initialize before routes that make outbound requests. The first configuration is retained; mounting the middleware again does not replace it. Add application context explicitly when your investigation needs it.
Related
Continue your setup
Check runtime availability and credentials before deploying an integration.