openafricadata-provost
v1.0.2
Published
Comprehensive error tracking for Node.js projects
Downloads
6
Readme
Provost
Comprehensive Error Tracking for Node.js Projects
Provost is a powerful error tracking tool designed to be easily integrated into Node.js applications, including Express.js, NestJS, React, React Native, and Koa.js. It captures errors, gathers additional system and browser information, and sends the error data to a specified API endpoint for tracking and analysis.
Table of Contents
Installation
To install Provost, use npm or yarn:
npm install provost
or
yarn add provost Usage Basic Setup To start using Provost, you need to initialize it once in your application with your API key and application ID.
javascript
import { Provost, ErrorPriority } from 'provost';
// Initialize Provost
const provost = new Provost({
apiKey: 'your-api-key',
appId: 'your-app-id',
});
provost.start();
Using with Express.js
javascript
Copy code
import express from 'express';
import { Provost, ErrorPriority } from 'provost';
const app = express();
// Initialize Provost
const provost = new Provost({
apiKey: 'your-api-key',
appId: 'your-app-id',
});
provost.start();
app.use((err, req, res, next) => {
provost.logError(err, ErrorPriority.High);
res.status(500).send('Something broke!');
});
app.listen(3000, () => {
console.log('Server is running on port 3000');
});
Using with NestJS typescript
import { Injectable, NestMiddleware } from '@nestjs/common';
import { Provost, ErrorPriority } from 'provost';
const provost = new Provost({
apiKey: 'your-api-key',
appId: 'your-app-id',
});
provost.start();
@Injectable()
export class ErrorLoggingMiddleware implements NestMiddleware {
use(req: Request, res: Response, next: Function) {
try {
next();
} catch (error) {
provost.logError(error, ErrorPriority.High);
next(error);
}
}
}
Using with React javascript
import React, { Component } from 'react';
import { Provost, ErrorPriority } from 'provost';
const provost = new Provost({
apiKey: 'your-api-key',
appId: 'your-app-id',
});
provost.start();
class App extends Component {
componentDidCatch(error, info) {
provost.logError(error, ErrorPriority.Critical);
}
render() {
return (
<div>
<h1>My React App</h1>
</div>
);
}
}
export default App;
Using with React Native javascript
import React, { Component } from 'react';
import { Provost, ErrorPriority } from 'provost';
const provost = new Provost({
apiKey: 'your-api-key',
appId: 'your-app-id',
});
provost.start();
class App extends Component {
componentDidCatch(error, info) {
provost.logError(error, ErrorPriority.Critical);
}
render() {
return (
<View>
<Text>My React Native App</Text>
</View>
);
}
export default App;
Configuration Provost requires the following configuration options:
apiKey: Your API key for authentication. appId: Your application ID. apiUrl: The URL to send error reports to. Example Configuration javascript Copy code const provost = new Provost({ apiKey: 'your-api-key', appId: 'your-app-id', }); Error Handling Provost captures and logs errors, including uncaught exceptions. You can also log errors manually using the logError method.
javascript Copy code try { // Your code here } catch (error) { provost.logError(error, ErrorPriority.High); }
API Reference Provost Class constructor(config: ProvostConfig) Initializes a new instance of Provost with the provided configuration.
logError(error: Error, priority?: ErrorPriority): void Logs an error with the specified priority.
Contributing Contributions are welcome! Please submit a pull request or open an issue to discuss your changes.
License Provost is licensed under the MIT License. See the LICENSE file for more details.
perl Copy code
This README.md
provides clear instructions on how to install, configure, and use the provost
package, along with examples for different frameworks. It also explains the main features and provides an API reference.