gaffneyjs
v1.0.3
Published
Lightweight runtime error notifier for Node.js using Proxy-based instrumentation
Downloads
33
Readme
GaffneyJS
GaffneyJS is a lightweight runtime error notifier for Node.js. It captures uncaught exceptions and unhandled promise rejections and can notify you (e.g., via email or webhook). It also provides protect() to wrap functions and objects so thrown errors and rejected promises are reported automatically.
Quick links
- API: docs/API.md
- Configuration: docs/CONFIG.md
Install
Install from npm:
npm install gaffneyjsOr for development:
pnpm buildCLI
The package exposes a CLI command gaffneyjs (installed via the package bin entry).
- Create a config file:
gaffneyjs init(writesgaffney.config.json) - Start monitoring:
gaffneyjs start
Usage (API)
Import and enable the reporter in your application:
import { gaffneyjs, protect } from 'gaffneyjs'
// reads gaffney.config.json from cwd and attaches process handlers
gaffneyjs()
function mayThrow() {
throw new Error('oops')
}
const safe = protect(mayThrow)
safe()Configuration
Create gaffney.config.json (see docs/CONFIG.md) or run gaffneyjs init to generate the default file. The config controls which error types to monitor (uncaught exceptions, unhandled rejections) and notifier settings (email/webhook).
Environment variables
GaffneyJS reads optional environment variables to override config values. Current env vars used by the project:
GAFFNEYJS_EMAIL_FROMGAFFNEYJS_EMAIL_TOGAFFNEYJS_SMTP_HOSTGAFFNEYJS_SMTP_PORTGAFFNEYJS_SMTP_SECUREGAFFNEYJS_SMTP_USERGAFFNEYJS_SMTP_PASS
License
This project is licensed under the MIT License — see the LICENSE file for details.
