typeorm-mongo-health
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

TypeOrm Mongo Health

A health checker for mongodb in typeorm

Table of contents

Installation

npm install --save typeorm-mongo-health@1.0.5

Usage

The simplest way to check mongo health in typeorm is using typeorm-mongo-health:

import { Injectable } from '@nestjs/common';
import { getConnection } from 'typeorm';
import { MongoHealh } from 'typeorm-mongo-health';

@Injectable()
export class HealthService {
  constructor(
    @Inject('DATA_SOURCE') private dataSource: DataSource,
    private mongoHelath: MongoHealh,
  ) {}

  async healthCheck(): Promise<any> {
    // Get the MongoManager from the DataSource
    const mongoManager = this.dataSource.manager;
    const connection = mongoManager.connection;

    const mongoHealth = await this.mongoHelath.mongoHealth(
      connection, // typeorm connection
      'mongodb-name', // mongo name
      10000, // timeout millisecond
    );
    return mongoHealth;
  }
}

Change Log

See Changelog for more information.

Contributing

Contributions welcome! See Contributing.

Author

Amir Kenarang (Amir Kenarang)

License

Licensed under the MIT License - see the LICENSE file for details.

Package Sidebar

Install

npm i typeorm-mongo-health

Weekly Downloads

40

Version

1.0.6

License

MIT

Unpacked Size

9.8 kB

Total Files

13

Last publish

Collaborators

  • kenarang