Socket
Book a DemoInstallSign in
Socket

barad-dur

Package Overview
Dependencies
Maintainers
0
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

barad-dur

**Barad-dur** is a tool designed for NestJS projects that provides a comprehensive log of queries in the TypeORM ORM.

latest
npmnpm
Version
1.1.62
Version published
Maintainers
0
Created
Source

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 Tracking user Api duration Api duration Api counter Api counter Query duration Query duration 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

FAQs

Package last updated on 18 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts