pushoverdotts
v0.0.1
Published
Type-safe Pushover API client for Node.js and Bun
Maintainers
Readme
pushoverdotts
Type-safe Pushover API client for Node.js and Bun.
Installation
bun add pushoverdottsUsage
import { Pushover } from 'pushoverdotts'
const pushover = new Pushover({
token: 'your-app-token',
user: 'your-user-key', // optional default user
})
// Send a simple message
await pushover.send('Hello, World!')
// Send with options
await pushover.send('Server is down!', {
title: 'Alert',
priority: 1,
sound: 'siren',
url: 'https://example.com/status',
urlTitle: 'View Status',
})
// Send to specific user (overrides default)
await pushover.send('Hello', { user: 'other-user-key' })Emergency Priority
Emergency priority (2) requires retry and expire parameters and returns a receipt:
const { receipt } = await pushover.sendEmergency('Critical alert!', {
retry: 60, // retry every 60 seconds
expire: 3600, // stop after 1 hour
callback: 'https://example.com/callback',
})
// Check receipt status
const status = await pushover.getReceiptStatus(receipt)
console.log(status.acknowledged) // 0 or 1
// Cancel emergency notification
await pushover.cancelEmergency(receipt)Validation
// Validate default user
const result = await pushover.validate()
console.log(result.devices) // ['iphone', 'android']
// Validate specific user and device
await pushover.validate('user-key', 'iphone')Glances (Apple Watch)
await pushover.glance({
title: 'Status',
text: 'All systems operational',
count: 42,
percent: 85,
})Available Sounds
const sounds = await pushover.getSounds()
// { pushover: 'Pushover (default)', bike: 'Bike', ... }Message Options
| Option | Type | Description | | ---------- | ----------------------- | --------------------------------- | | title | string | Message title | | url | string | Supplementary URL | | urlTitle | string | Title for the URL | | priority | -2 | -1 | 0 | 1 | 2 | Message priority | | sound | Sound | Notification sound | | device | string | string[] | Target device(s) | | timestamp | number | Date | Message timestamp | | html | boolean | Enable HTML formatting | | monospace | boolean | Use monospace font | | retry | number | Retry interval (priority 2 only) | | expire | number | Expiration time (priority 2 only) | | callback | string | Callback URL (priority 2 only) | | ttl | number | Time to live in seconds | | attachment | { base64, type } | Image attachment |
Error Handling
import { Pushover, PushoverError, PushoverValidationError } from 'pushoverdotts'
try {
await pushover.send('Hello')
} catch (error) {
if (error instanceof PushoverValidationError) {
console.error('Invalid user:', error.errors)
} else if (error instanceof PushoverError) {
console.error('API error:', error.errors)
}
}License
MIT
