brrr.now
v1.2.0
Published
Tiny TypeScript client for sending push notifications with brrr.now webhooks
Maintainers
Readme
brrr.now
Minimal TypeScript client for the brrr.now notification service.
Installation
bun add brrr.nownpm install brrr.nowUsage
import { 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",
});
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
API
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}.
SendNotificationParams
titlesubtitlemessagethreadIdsound:NotificationSoundopenUrlimageUrlexpirationDate:string | DatefilterCriteriainterruptionLevel:NotificationInterruptionLevel
Error handling
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);
}
}The supported sound values follow the official brrr.now documentation.
Contributing
Please see CONTRIBUTING.md for contribution guidelines.
License
MIT
