@bisontry/node-development
v0.1.8
Published
> Bisontry Node is a library that sends notifications to Slack when an error occurs.
Downloads
2
Readme
Bisontry Node
Bisontry Node is a library that sends notifications to Slack when an error occurs.
🚀 Installation
Install the package using npm:
npm install @bisontry/node
📝 Usage
First, import the library and initialize it with your user configuration. This includes your Slack webhook URL for sending notifications.
import { bisontryInit, KlaytnNetwork, NodeEnv, OraklServiceName } from "@bisontry/node";
const userConfig = {
MESSENGER_ENDPOINT: "" // Replace with bisontry messenger url.
nodeEnv: NodeEnv.local // Change this according to your environment.
network: KlaytnNetwork.baobab, // Change this according to your network.
serviceName: OraklServiceName.test // Change this according to the service you are using.
};
const { BISONTRYLOGGER, bisontryHookConsoleError } = bisontryInit(userConfig);
Next, connect the console error hook:
bisontryHookConsoleError(BISONTRYLOGGER);
try {
throw new Error('This is a test error');
} catch (error) {
BISONTRYLOGGER.error({ name: 'main', error });
}
When you call the BISONTRYLOGGER.error
method with an object containing additional details (like 'name'), it provides more precise information about the error. This information will be sent to Slack.
⚙️ Configuration
The userConfig object can define the following properties:
- MESSENGER_ENDPOINT: The Bisontry Messenger URL.
If additional configurations are needed, modify the userConfig object passed to the bisontryInit function.