Minimal TypeScript client for the brrr.now notification service.
bun add brrr.nownpm install brrr.nowimport { sendNotification } from "brrr.now";
const response = await sendNotification({
webhook: process.env.BRRR_WEBHOOK!,
title: "Coffee Machine Offline",
message: "The coffee machine is currently unreachable.",
threadId: "ops-coffee",
sound: "upbeat_bells",
openUrl: "https://status.example.com/coffee-machine",
interruptionLevel: "time-sensitive",
});
console.log(await response.json()); // { success: true }webhook can be either:
- the full webhook URL from the brrr.now app
- only the secret part, for example
br_usr_a1b2c3
import type {
NotificationInterruptionLevel,
NotificationSound,
SendNotificationParams,
} from "brrr.now";
import { isBrrrNowError, sendNotification } from "brrr.now";sendNotification(params) sends a POST request with a JSON payload and returns the native Response.
On success, the API body is {"success":true}.
titlesubtitlemessagethreadIdsound:NotificationSoundopenUrlimageUrlexpirationDate:string | DatefilterCriteriainterruptionLevel:NotificationInterruptionLevelvolume:number
On non-2xx responses, or when the API returns {"success":false,...}, sendNotification throws an Error object with extra fields:
name: "BrrrNowError"statusstatusTextbodyapiError?
Use isBrrrNowError to narrow the error type:
import { isBrrrNowError, sendNotification } from "brrr.now";
try {
await sendNotification({
webhook: process.env.BRRR_WEBHOOK!,
message: "Hello world!",
});
} catch (error) {
if (isBrrrNowError(error)) {
console.error(error.status, error.apiError ?? error.body);
}
}NotificationInterruptionLevel supports passive, active, time-sensitive, and critical.
The supported sound values follow the official brrr.now documentation, including emergency for critical alerts.
Please see CONTRIBUTING.md for contribution guidelines.
MIT