barad-dur
v1.1.47
Published
**Barad-dur** is a tool designed for NestJS projects that provides a comprehensive log of queries in the TypeORM ORM.
Downloads
79
Readme
Barad-dur
Barad-dur is a tool designed for NestJS projects that provides a comprehensive log of queries in the TypeORM ORM.
Features
- Track which specific APIs and queries are called by a user and in which functions they are executed.
- Store the average speed of the queries.
- Track the number of query executions to detect queries that are stuck in loops.
- Store the average speed of APIs.
- Track the number of API executions to isolate and scale specific microservices.
Installation
npm i barad-dur
Configuration
To configure Barad-dur, you need to integrate it into your NestJS project as shown below:
@Module({
imports: [
...,
BaradDurModule.register({
url: 'redis://YOUR_REDIS_IP', // redis_url
password: 'YOUR_REDIS_PASSWORD', // redis_password
tracking: {
socketPort: 9191,
fetchKeyFromToken: string | (req:express.Request) => string, // 'YOUR_CLAIM_IN_TOKEN'
}
}),
...
],
...
})
export class AppModule { }
Redis Dependency
This tool requires Redis to track query timings. The Redis connection is configured using the provided url and password values.
Tracking
Tracking also requires a socket connection. A client listening on the other end will receive the tracking data for the user.
Log Viewer
To display the logs, you'll need a separate application that receives the logs and transforms them into a UI for visualization. You can get such a program from the following repository:
https://gitlab.com/bakhshabadi.javad/analyse-backend
Images
Tracking user Api duration Api counter Query duration Query duration
Simply set up the environment for this project by pointing it to your own project's address and use the same port that was set in the configuration.
Keywords
NestJS, TypeORM, logging, query tracking, Redis, API tracking, microservices, performance monitoring