0.3.5 • Published 1 year ago

@lcdev/hall-monitor v0.3.5

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
1 year ago

Hall Monitor

npm.io npm.io

Tells the teacher when unexpected things go wrong in your services.

yarn add @lcdev/hall-monitor@VERSION

At 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);
0.3.5

1 year ago