error-hunter-middleware
v16.13.2
Published
This package, catches the errors of your code, and it logs them with all necessary info about it such as **statusCode, message, url** that error come from and etc. After logging, it sends message to you via Telegram. So that you can immediately be awared
Downloads
4
Readme
Error Middleware for Both Client and Server Side
This package, catches the errors of your code, and it logs them with all necessary info about it such as statusCode, message, url that error come from and etc. After logging, it sends message to you via Telegram. So that you can immediately be awared that there is an error occured in your system. You have to send a token via this middleware to be able to logged. We will provide this token for you when you register our system.
Installation
npm install error-log-middleware
Error Types
The package includes some specific errors. Optionally, users can import and throw this specific errors to the error middleware. Or they can throw their custom error but the error response format must include the properties:
- status
- statusText
- url
Server Side Usage
const express = require("express");
const {NotFoundError} = require("error-log-middleware/server-res/errors");
const errMidd = require("error-log-middleware/server-res"); // You need to specify server side when import package
const app = express();
app.get("/test", (req, res) => {
**throw new NotFoundError();**
})
**app.use(errMidd(*yourToken*));**
app.listen(process.env.PORT || 4000, () => {});
Client Side Usage
For client side, errors can be thrown in different formats. This packages provides logger for fetch and axios http modules. You need specify that.
Fetch
const midd = require("errors-log-middleware/fetch");
const errHunter = new midd(*yourToken*)
Axios
const midd = require("errors-log-middleware/axios");
const errHunter = new midd(*yourToken*)