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.
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. 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 });Tip
The close hook starts SDK shutdown without awaiting it. In your application shutdown handler, await checkupstream.shutdown() before app.close() and process exit if the final batch must finish.
Related
Continue your setup
Check runtime availability and credentials before deploying an integration.