Skip to main content
All recipes

Fastify

CodePluginNode.js

The plugin initializes the SDK during registration and starts shutdown from the close hook. For a controlled shutdown, explicitly await the SDK before closing your server.

1. Install

Bash
npm install @checkupstream/sdk

2. Register the plugin

server.ts
import Fastify from "fastify";
import { checkUpstreamPlugin } from "@checkupstream/sdk/integrations/fastify";

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

const app = Fastify();

await app.register(checkUpstreamPlugin, {
  sdkKey,
});

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

await app.listen({ port: 3000 });

Continue your setup

Check runtime availability and credentials before deploying an integration.