@lcdev/hall-monitor
v0.3.5
Published
Tells the teacher when unexpected things go wrong in your services
Keywords
Readme
Hall Monitor
Tells the teacher when unexpected things go wrong in your services.
yarn add @lcdev/hall-monitor@VERSIONAt the moment, it's very simple. Simply exports koa middleware.
import { reportErrorsMiddleware } from '@lcdev/hall-monitor';
const app = new Koa();
app.use(reportErrorsMiddleware({
serviceName: 'My Service',
slack: {
webhookURL: '...',
notifyUsers: [
// find 'member ID' codes for users to tag
'...',
],
},
}));You can also wrap any arbitrary function, useful for cron jobs or system startup.
import { reportErrors } from '@lcdev/hall-monitor';
async function main() { ... }
// simply wraps the call to main, doing the same error reporting that the middleware does
const mainWithErrorReporting = reportErrors(main, { ...config });
mainWithErrorReporting().catch(err => {
process.exit(1);
});Or, report an error individually.
import { reportError } from '@lcdev/hall-monitor';
await reportError(new Error('something went wrong!'), config);