Giter VIP home page Giter VIP logo

terminus's Introduction

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications, heavily inspired by Angular.

NPM Version Package License NPM Downloads Discord Backers on Open Collective Sponsors on Open Collective

Description

This module contains integrated healthchecks for Nest.

Installation

@nestjs/terminus integrates with a lot of cool technologies, such as typeorm, grpc, mongodb, and many more! In case you have missed a dependency, @nestjs/terminus will throw an error and prompt you to install the required dependency. So you will only install what is actually required!

npm install --save @nestjs/terminus

Usage

  1. Import the Terminus module
  2. Make sure the additionally needed modules are available to (e.g. TypeOrmModule), in case you want to do Database Health Checks.
// app.module.ts

@Module({
  controllers: [HealthController],
  imports:[
    // Make sure TypeOrmModule is available in the module context
    TypeOrmModule.forRoot({ ... }),
    TerminusModule
  ],
})
export class HealthModule { }
  1. Setup your HealthController which executes your Health Check.
// health.controller.ts

@Controller('health')
export class HealthController {
  constructor(
    private health: HealthCheckService,
    private db: TypeOrmHealthIndicator,
  ) {}

  @Get()
  @HealthCheck()
  readiness() {
    return this.health.check([
      async () => this.db.pingCheck('database', { timeout: 300 }),
    ]);
  }
}

If everything is set up correctly, you can access the healthcheck on http://localhost:3000/health.

{
  "status": "ok",
  "info": {
    "database": {
      "status": "up"
    }
  },
  "details": {
    "database": {
      "status": "up"
    }
  }
}

For more information, see docs. You can find more samples in the samples/ folder of this repository.

Contribute

In order to get started, first read through our Contributing guidelines.

Setup

Setup the development environment by following these instructions:

  1. Fork & Clone the repository
  2. Install the dependencies
npm install

# To rebuild the project, run
npm run build

Test

For unit testing run the following command:

npm run test

For e2e testing, make sure you have docker installed

docker-compose up -d
npm run test:e2e

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

Stay in touch

License

Nest is MIT licensed.

terminus's People

Contributors

abt0 avatar brunnerlivio avatar caucik avatar danielebarbaro avatar dependabot[bot] avatar erajabzadeh avatar gabormagyar avatar galkin avatar jbw avatar jeffminsungkim avatar jonahsnider avatar kamilmysliwiec avatar kaznovac avatar lp-francois avatar micalevisk avatar mvandervliet avatar ostkrok avatar pidelport avatar renovate-bot avatar renovate[bot] avatar rubiin avatar skywalker512 avatar sophiah67 avatar stefanprintezis avatar svenddomdey avatar thekhanj avatar tkjaergaard avatar tony133 avatar trescube avatar weeco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

terminus's Issues

@nestjs/terminus on npm

I'm submitting a...


[ ] Regression 
[ ] Bug report
[ ] Feature request
[x] Documentation issue or request
[] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

when @nestjs/terminus available on npm?
is there a way i can test?

Expected behavior

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Nest version: X.Y.Z

 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

Invalid ping query for TypeOrmHealthIndicator using oracle connection

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Fails when using TypeOrmHealthIndicator with TypeOrmModule configuration for an type: 'oracle' connection. The issue is due to the invalid SELECT 1 query used as the ping.

Expected behavior

The proper statement for type: 'oracle' should be SELECT 1 FROM DUAL

Minimal reproduction of the problem with instructions

  1. Create TypeOrm connection with type: 'oracle'
  2. Create HealthIndicator for TypeORM as described in docs
  3. Load /health and see 503 with status: 'down' and no message

What is the motivation / use case for changing the behavior?

Make TypeORM health indicator function for all supported connection types

Environment


Nest version: 6.7.1

 
For Tooling issues:
- Node version: v10.16.3  
- Platform:  Mac, Docker/Linux

Others:

Import of TerminusModule does not work has expected

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Import of TerminusModule is broken

Expected behavior

Import of TerminusModule should works

Minimal reproduction of the problem with instructions

Simply try to import like that :
import { TerminusModule } from '@nestjs/terminus';

And run your app, you'll see that Nest displays an error message:
Nest can't resolve dependencies of the TerminusBootstrapService (TerminusModuleOptions, TerminusLib, ?). Please make sure that the argument at index [2] is available in the TerminusModule context.

What is the motivation / use case for changing the behavior?

When looking in terminus-bootstrap.service.d.ts, it seems that HttpAdapterHost import is broken, I do not see this package in @nestjs/core, maybe an update in @nestjs/core has been done.

Environment


Nest version: 5.4.0

 
For Tooling issues:
- Node version: v10.12.0
- Platform:  Mac

Others:

Possible memory leak when using microservice for Redis

I'm submitting a...


[ ] Regression 
[X] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

There seems to be a memory leak in how this library checks that Redis is connected.

Expected behavior

There should be no memory leak.

Minimal reproduction of the problem with instructions

This issues manifests itself fairly easily when running a health-check every 10s in a containerized environment.

Our implementation was copy pasted from the example

What is the motivation / use case for changing the behavior?

See expected behavior

Environment

"@godaddy/terminus": "4.1.2",
"@nestjs/common": "6.5.3",
"@nestjs/core": "6.5.3",
"@nestjs/microservices": "6.5.3",
"@nestjs/platform-express": "6.5.3",
"@nestjs/terminus": "6.5.0"

For Tooling issues:

  • Node version: 10.16.0 (LTS)
  • Platform: MacOS, Alpine Linux (node:10.16-alpine)

Others:

I'm not sure what library Nest uses under the hood, but it seems like every time this endpoint is hit, it attempts to establish a new connection to Redis.
I don't see a place where it disconnects.

Tangentially, there must be a better way of "pinging" the service than attempting to connect to it?

Please see attached graph. Before is with Redis healthcheck, after is without Redis healtcheck

Screen Shot 2019-08-15 at 2 45 53 PM

Screen Shot 2019-08-15 at 2 45 57 PM

Screen Shot 2019-08-15 at 2 46 01 PM

Incompatible with mongo < 4.0

I'm submitting a...


[ ] Regression 
[X] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Currently MongooseHealthIndicator calls connection.startSession() and returns an non descriptive error if mongo does not support sessions. After some digging I found that mongo returns MongoError: Current topology does not support sessions. And that is why mongo health check fails.

Expected behavior

Mongo health check doesn't fail if mongo version is below 4.0

Minimal reproduction of the problem with instructions

Install mongo with version below 4.0 and try to run mongo sample.

Environment


Nest version: 6.0.0
 
For Tooling issues:
- Node version: 12.3.1  
- Platform: Linux Ubuntu 16.04 LTS

Update samples to use v7 API

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Currently, only the samples with the deprecated v6 API exist.

Expected behavior

We should update these samples to use the new v7 API.

build throwing errors when dependencies are installed with `yarn --ignore-optional`

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

I installed dependencies with --ignore-optional for CI Builds
yarn --no-cache --ignore-optional --frozen-lockfile

When try to build got following errors.

ERROR in /Developer/Work/SPA/ngx-starter-kit/node_modules/@nestjs/terminus/dist/health-indicators/database/database-health-indicator.d.ts
ERROR in /Developer/Work/SPA/ngx-starter-kit/node_modules/@nestjs/terminus/dist/health-indicators/database/database-health-indicator.d.ts(1,50):
TS2307: Cannot find module 'mongoose'.

ERROR in /Developer/Work/SPA/ngx-starter-kit/node_modules/@nestjs/terminus/dist/health-indicators/database/mongoose.health.d.ts
ERROR in /Developer/Work/SPA/ngx-starter-kit/node_modules/@nestjs/terminus/dist/health-indicators/database/mongoose.health.d.ts(1,28):
TS2307: Cannot find module 'mongoose'.

ERROR in /Developer/Work/SPA/ngx-starter-kit/node_modules/@nestjs/terminus/dist/health-indicators/databse-ping-check-settings.interface.d.ts
ERROR in /Developer/Work/SPA/ngx-starter-kit/node_modules/@nestjs/terminus/dist/health-indicators/databse-ping-check-settings.interface.d.ts(4,50):
TS2307: Cannot find module 'mongoose'.

ERROR in /Developer/Work/SPA/ngx-starter-kit/node_modules/@nestjs/terminus/dist/health-indicators/microservice/microservice.health.d.ts
ERROR in /Developer/Work/SPA/ngx-starter-kit/node_modules/@nestjs/terminus/dist/health-indicators/microservice/microservice.health.d.ts(3,31):
TS2307: Cannot find module '@nestjs/microservices'.

Expected behavior

since I don't have explicit dependency on mongoose and @nestjs/microservices, I shouldn't be forced to install those dependencies
don't have similar issues with other nestjs modules

Minimal reproduction of the problem with instructions

https://github.com/xmlking/ngx-starter-kit

What is the motivation / use case for changing the behavior?

i am trying to speedup npm install process for CI docker builds by using --ignore-optional flag

Environment


Nest version: X.Y.Z

 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

MongooseHealthIndicator fail with a connection name

I'm submitting a...


[ ] Regression 
[X] Bug report
[ ] Feature request
[X] Documentation issue or request
[ ] Support request

Current behavior

When using MongooseHealthIndicator, if MongooseModule is used with the connectionName option (because I have two mongoose connections):

MongooseModule.forRoot(resourcesUri, { useNewUrlParser: true, connectionName: 'resources' }),

The health check will fail even if I'm using the connection option:

healthIndicators: [
  async () => await this.mongoose.pingCheck('mongo', { connection: 'resources' }),
],

Health check response: HTTP 503

{
  "status": "error",
  "error": {
    "memory_heap": {
      "status": "up"
    },
    "memory_rss": {
      "status": "up"
    },
    "mongo": {
      "status": "down"
    }
  },
  "details": {
    "memory_heap": {
      "status": "up"
    },
    "memory_rss": {
      "status": "up"
    },
    "mongo": {
      "status": "down"
    }
  }
}

Expected behavior

    "mongo": {
      "status": "up"
    }

Since the other routes using this connection are working.

Minimal reproduction of the problem with instructions

See current behavior

What is the motivation / use case for changing the behavior?

I want to be able to specify the connectionName and have a correct health check response.

Environment


Nest version: 6.5.2
Terminus version: 4.1.2
NestJS terminus version: 6.5.0
 
For Tooling issues:
- Node version: 10.16.0
- Platform:  Linux, Docker

graceful shutdown

Hi I'm Ingyu Yoon

These days, I have studied graceful shutdown and I want to use terminus in my nest app.
and I got to know this lib after searching.
I think this library doesn't provide onShutdown callback function like terminus.
Could you tell me why you didn't support that options?

Rename DatabaseHealthIndicator to TypeOrmHealthIndicator

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Expected behavior

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Related #36

Environment


Nest version: X.Y.Z

 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

Incompatible with nestjs v7

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When using nestjs v7, eslint will throw errors about not being able to find microservice-configuration.interface

Expected behavior

to work with v7

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Nest version: 7.0.5

 
For Tooling issues:
- Node version: All compatible
- Platform:  All

Others:

Cannot find module '@nestjs/common/interfaces/microservices/microservice-configuration.interface'

Bug Report

Current behavior

node_modules/@nestjs/terminus/dist/health-indicators/microservice/grpc.health.d.ts:1:29 - error TS2307: Cannot find module '@nestjs/common/interfaces/microservices/microservice-configuration.interface'.

1 import { GrpcOptions } from '@nestjs/common/interfaces/microservices/microservice-configuration.interface';
                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@nestjs/terminus/dist/health-indicators/microservice/microservice.health.d.ts:1:93 - error TS2307: Cannot find module '@nestjs/common/interfaces/microservices/microservice-configuration.interface'.

1 import { RedisOptions, NatsOptions, MqttOptions, GrpcOptions, RmqOptions, TcpOptions } from '@nestjs/common/interfaces/microservices/microservice-configuration.interface';
                                                                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Found 2 error(s).

Input Code

create a simple project and add the terminus packages. update to latest packages.

src/app.health.indicator.ts

import { HealthCheckError } from "@godaddy/terminus";
import { Injectable } from "@nestjs/common";
import { HealthIndicator, HealthIndicatorResult } from "@nestjs/terminus";

@Injectable()
export class AppHealthIndicator extends HealthIndicator {
  async isHealthy(): Promise<HealthIndicatorResult> {
    const isHealthy = true;
    const result = super.getStatus("app", isHealthy);
    if (isHealthy) {
      return Promise.resolve(result);
    }
    throw new HealthCheckError("Action failed.", result);
  }
}

Expected behavior

To run correctly.

Possible Solution

Environment


Nest version: 7.0.1

"dependencies": {
  "@godaddy/terminus": "^4.3.1",
  "@nestjs/common": "^7.0.1",
  "@nestjs/config": "^0.4.0",
  "@nestjs/core": "^7.0.1",
  "@nestjs/graphql": "^7.0.1",
  "@nestjs/jwt": "^7.0.0",
  "@nestjs/passport": "^7.0.0",
  "@nestjs/platform-express": "^7.0.1",
  "@nestjs/swagger": "^4.4.0",
  "@nestjs/terminus": "^6.5.6",
  "@nestjs/typeorm": "^7.0.0",
  "@sentry/node": "^5.14.2",
  "aws-sdk": "^2.639.0",
  "cache-manager": "^3.2.0",
  "cache-manager-ioredis": "^2.0.0",
  "class-transformer": "^0.2.3",
  "class-validator": "^0.11.0",
  "cookie-parser": "^1.4.4",
  "cors": "^2.8.5",
  "crypto-random-string": "^3.2.0",
  "csurf": "^1.11.0",
  "elastic-apm-node": "^3.5.0",
  "express-rate-limit": "^5.1.1",
  "hashids": "^2.2.1",
  "helmet": "^3.21.3",
  "imgproxy": "^0.1.2",
  "kaop-ts": "^4.3.0",
  "lodash": "^4.17.15",
  "mime": "^2.4.4",
  "mime-types": "^2.1.26",
  "mmmagic": "^0.5.3",
  "moment": "^2.24.0",
  "mongoose": "^5.9.4",
  "ms": "^2.1.2",
  "multer": "^1.4.2",
  "mysql": "^2.18.1",
  "passport": "^0.4.1",
  "passport-anonym-uuid": "^1.0.3",
  "passport-jwt": "^4.0.0",
  "passport-local": "^1.0.0",
  "passport-telegram-official": "^1.1.0",
  "passport-unique-token": "^1.0.0",
  "prom-client": "^12.0.0",
  "prometheus-gc-stats": "^0.6.2",
  "reflect-metadata": "^0.1.13",
  "rimraf": "^3.0.2",
  "rxjs": "^6.5.3",
  "source-map": "^0.7.3",
  "source-map-support": "^0.5.16",
  "swagger-ui-express": "^4.1.3",
  "typeorm": "^0.2.24",
  "uuid": "^7.0.2"
},
"devDependencies": {
  "@commitlint/cli": "^8.3.5",
  "@commitlint/config-angular": "^8.3.4",
  "@commitlint/prompt": "^8.3.5",
  "@commitlint/prompt-cli": "^8.3.5",
  "@nestjs/cli": "^7.0.0",
  "@nestjs/schematics": "^7.0.0",
  "@nestjs/testing": "^7.0.1",
  "@types/aws-lambda": "^8.10.46",
  "@types/bluebird": "^3.5.30",
  "@types/cache-manager": "^2.10.2",
  "@types/connect": "^3.4.33",
  "@types/cookie-parser": "^1.4.2",
  "@types/cors": "^2.8.6",
  "@types/csurf": "^1.9.36",
  "@types/express": "^4.17.3",
  "@types/express-rate-limit": "^5.0.0",
  "@types/hashids": "^1.0.30",
  "@types/helmet": "0.0.45",
  "@types/jest": "^25.1.4",
  "@types/lodash": "^4.14.149",
  "@types/mime-types": "^2.1.0",
  "@types/mmmagic": "^0.4.29",
  "@types/mongoose": "^5.7.6",
  "@types/ms": "^0.7.31",
  "@types/multer": "^1.4.2",
  "@types/node": "^13.9.1",
  "@types/passport-jwt": "^3.0.3",
  "@types/passport-local": "^1.0.33",
  "@types/passport-unique-token": "^1.0.2",
  "@types/prometheus-gc-stats": "^0.6.1",
  "@types/source-map-support": "^0.5.1",
  "@types/supertest": "^2.0.8",
  "@types/uuid": "^7.0.0",
  "@typescript-eslint/eslint-plugin": "^2.23.0",
  "@typescript-eslint/parser": "^2.23.0",
  "conventional-changelog": "^3.1.18",
  "conventional-changelog-cli": "^2.0.31",
  "eslint": "^6.8.0",
  "eslint-config-prettier": "^6.10.0",
  "eslint-plugin-jest": "^23.8.2",
  "eslint-plugin-prettier": "^3.1.2",
  "husky": "^4.2.3",
  "hygen": "^5.0.3",
  "jest": "^25.1.0",
  "lint-staged": "^10.0.8",
  "prettier": "^1.18.2",
  "supertest": "^4.0.2",
  "ts-jest": "^25.2.1",
  "ts-loader": "^6.1.1",
  "ts-node": "^8.6.2",
  "tsconfig-paths": "^3.9.0",
  "typescript": "^3.8.3"
},

For Tooling issues:
- Node version: v13.11.0  
- Platform: Mac v10.15.3 

Others:
- IDE: vscode v1.43.0
- package manager: npm v6.14.2

TypeOrmHealthIndicator pingCheck is not working for mongo

I'm submitting a...


[ ] Regression 
[x ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

TypeOrmHealthIndicator pingCheck is calling 'select 1' which will not work for Mongo.

Expected behavior

TypeOrmHealthIndicator pingCheck should work for mongo

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Nest version: X.Y.Z

 6.2.0

For Tooling issues:
- Node version: XX  
- Platform:  

Others:

Add `info` property even when the health check fail

I'm submitting a...


[ ] Regression 
[ ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Expected behavior

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Nest version: X.Y.Z

 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

7.0.0 proposal - Removal of `@godaddy/terminus`

Limitations

At the moment @nestjs/terminus is underlying some harsh limitations.

Some of which are:

  • Swagger compatibility #32
  • Compatibility with middlewares #33
  • OnApplicationShutdown hook #312
  • Get Health Status programmatically #9

The named issues are hardly or impossible to fix because of restrictions of the underlying @godaddy/terminus library. Surely, it would be possible to create pull requests to the underlying library, so the named issues would be possible. Though in that case there would not be much benefit of relying on the library at all.

Proposal

What I am proposing is the removal of the dependent @godaddy/terminus library.

The main points which is currently handled by @godaddy/terminus and would need to take over to the codebase of @nestjs/terminus:

  • Register the health check route to the http server (enabler of #32, #33)
    @godaddy/terminus registers health checks directly to the underlying http instance.
    The problem with that approach is, NestJS "does not know" these routes exist.
    Currently it is not possible to let NestJS know about these routes, and therefore there
    is no way to add Swagger, Middleware or else compatibility. Related issue nestjs/nest#1438.

  • Handle life-cycle management (enabler of #312)
    @godaddy/terminus registers listeners to system signals. Unfortunately NestJS should need
    to handle the system signals handling by itself, using onApplicationShutdown or beforeApplicationShutdown.

  • Handle the health indicator execution manager (enabler of #9)
    Currently @godaddy/terminus does not allow to compute the current outcome of
    the health status, without requesting the health check url.

  • Handle response codes on failure / succcess.
    No benefit in handling it ourselves, but it still allows for flexibility in the future.

Breaking changes

Most users most probably won't need to migrate. The only thing which would be beneficial for all users is to remove the @godaddy/terminus so your project does not have an unneeded dependency (npm uninstall @godaddy/terminus).

For all users who have built custom health indicators will need to change how you had to handle unhealthy response codes. Essentially it boils down to changing the following line:

import { HealthCheckError } from '@godaddy/terminus';

to

import { HealthCheckError } from '@nestjs/terminus';

and that's it.

Since this is a breaking change, I want to align with you before-hand. Please let me know whether my strategy is sufficient for your project. Maybe you have a better idea? Let me know :)

Add ApolloHealthIndicator

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Expected behavior

Apollo has a build in health check endpoint: '/.well-known/apollo/server-health'

How to use existed DNSHealthIndicator to ping current server? Or add a new ApolloHealthIndicator?

See https://www.apollographql.com/docs/apollo-server/features/health-checks

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Nest version: X.Y.Z

 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

Add Sequelize Health Indicator

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Expected behavior

Create a Sequelize Health Indicator, similar to the TypeOrm and Mongoose Health Indicators.

Add predefined health checks

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Expected behavior

As discussed on nestjs/nest#966 there should be prefedined health checks, so the user can easily access data like (as @weeco mentioned)

  • When all initialization stuff is done (asynchronous connections, binding routes, asynchronous modules, etc..)
  • When the status of the connections to the infrastructure services (such as a database) is good

Incompatible with NestFactory.createApplicationContext()

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When using `NestFactory.createApplicationContext(), this module produces an error during initialization:

TypeError: Cannot read property 'getHttpServer' of null
    at TerminusBootstrapService.onApplicationBootstrap (/app/node_modules/@nestjs/terminus/dist/terminus-bootstrap.service.js:143:52)
    at MapIterator.iteratee (/app/node_modules/@nestjs/core/hooks/on-app-bootstrap.hook.js:21:43)
    at MapIterator.next (/app/node_modules/iterare/src/map.ts:9:39)
    at IteratorWithOperators.next (/app/node_modules/iterare/src/iterate.ts:19:28)
    at Function.from (<anonymous>)
    at IteratorWithOperators.toArray (/app/node_modules/iterare/src/iterate.ts:227:22)
    at callOperator (/app/node_modules/@nestjs/core/hooks/on-app-bootstrap.hook.js:22:10)
    at Object.callModuleBootstrapHook (/app/node_modules/@nestjs/core/hooks/on-app-bootstrap.hook.js:37:23)
    at NestApplicationContext.callBootstrapHook (/app/node_modules/@nestjs/core/nest-application-context.js:162:27)
    at NestApplicationContext.init (/app/node_modules/@nestjs/core/nest-application-context.js:63:20)

Expected behavior

No error to be produced.

Minimal reproduction of the problem with instructions

Instead of using NestFactory.create(), use NestFactory.createApplicationContext(). I use this to create a CLI that has access to the Nest DI container.

What is the motivation / use case for changing the behavior?

Environment


Nest version: 6.10.8

 
For Tooling issues:
- Node version: 12.13
- Platform:  Liux

Others:

Cannot use @nestjs/terminus 6.5.6 with @nestjs/microservices 7.0.1

I'm submitting a...


[x] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Cannot use @nestjs/terminus 6.5.6 with @nestjs/microservices 7.0.1

Expected behavior

compile nestjs app when @nestjs/microservices and @nestjs/terminus are used

Minimal reproduction of the problem with instructions

Create new NestJS app with @nestjs/cli 7.0.0

nest new nestjs-terminus-issue && cd nestjs-terminus-issue

Install dependencies

npm i --save @nestjs/microservices @nestjs/terminus @godaddy/terminus

Change following files:

modify main.ts

import { NestFactory } from '@nestjs/core';
import { Transport, MicroserviceOptions } from '@nestjs/microservices';
import { AppModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  app.connectMicroservice<MicroserviceOptions>({
    transport: Transport.TCP,
    options: { host: '0.0.0.0', port: 3001 },
  });
  await app.startAllMicroservicesAsync();
  await app.listen(3000);
}
bootstrap();

add src/terminus-options.service.ts

import {
  TerminusEndpoint,
  TerminusOptionsFactory,
  TerminusModuleOptions,
  MicroserviceHealthIndicator,
} from '@nestjs/terminus';
import { Injectable } from '@nestjs/common';
import { Transport } from '@nestjs/microservices';

@Injectable()
export class TerminusOptionsService implements TerminusOptionsFactory {
  constructor(private readonly microservice: MicroserviceHealthIndicator) {}

  createTerminusOptions(): TerminusModuleOptions {
    const healthEndpoint: TerminusEndpoint = {
      url: 'healthz',
      healthIndicators: [
        async () =>
          this.microservice.pingCheck('service', {
            transport: Transport.TCP,
            options: { host: '0.0.0.0', port: 3001 },
          }),
      ],
    };

    return {
      endpoints: [healthEndpoint],
    };
  }
}

update app-module.ts

import { Module } from '@nestjs/common';
import { TerminusModule } from '@nestjs/terminus';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { TerminusOptionsService } from './terminus-options.service';

@Module({
  imports: [TerminusModule.forRootAsync({ useClass: TerminusOptionsService })],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}

execute nest start

Error:

node_modules/@nestjs/terminus/dist/health-indicators/microservice/grpc.health.d.ts:1:29 - error TS2307: Cannot find modul
e '@nestjs/common/interfaces/microservices/microservice-configuration.interface'.

1 import { GrpcOptions } from '@nestjs/common/interfaces/microservices/microservice-configuration.interface';
                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@nestjs/terminus/dist/health-indicators/microservice/microservice.health.d.ts:1:93 - error TS2307: Cannot find module '@nestjs/common/interfaces/microservices/microservice-configuration.interface'.

1 import { RedisOptions, NatsOptions, MqttOptions, GrpcOptions, RmqOptions, TcpOptions } from '@nestjs/common/interfaces/microservices/microservice-configuration.interface';
                                                                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Found 2 error(s).

What is the motivation / use case for changing the behavior?

Use health check with apps made with nestjs 7

Environment


Nest version: 7.0.1

 
For Tooling issues:
- Node version: v13.9.0  
- Platform: Linux 

Get Health Status programmatically

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

The only way to retrieve the health status is over HTTP.

Expected behavior

There should be a way to request the current status by the public nestjs/terminus API.

For example:

// Returns { status: 'ok' | 'error', info: {...} }
await terminusRegistry.getHealthStatus('/health');

Related

godaddy/terminus#83

Support GRPC health checks

I'm submitting a...


[ ] Regression 
[ ] Bug report
[X] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Related to nestjs/nest#2214 , we would like to use the GRPC Health Check protocol in our microservices. I'm not sure if there is a easy way to hook nestjs/terminus into the GRPC transport in Nest, but it would be a big win for us.

What is the motivation / use case for changing the behavior?

Rather than reinvent the wheel and/or include our own separate health check handler, we would like to use the health check that is part of the GRPC spec. Several languages include built-in support and there are tools already developed to use the health check in the spec.

Environment


Nest version: all

 
For Tooling issues:
- Node version: all
- Platform:  all

Others:

Add support for system signals (SIGINT, SIGTERM, etc.)

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

It should support system signal (graceful shutdown

Expected behavior

System signal support should allow the user to gracefully shutdown the server

peerDependencies versions are too specific

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Whenever a peer dependency version doesn't match the installed version exactly, npm displays warnings:


npm WARN @nestjs/[email protected] requires a peer of @godaddy/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN @nestjs/[email protected] requires a peer of @nestjs/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN @nestjs/[email protected] requires a peer of @nestjs/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN @nestjs/[email protected] requires a peer of [email protected] but none is installed. You must install peer dependencies yourself.

Expected behavior

No warnings should be displayed for compatible peer dependency versions.

The version range for peer dependencies should be as wide as possible. It should at least include patch or minor versions.

Environment


Nest version: 6.6.7
@nestjs/terminus version: 6.5.1
@godaddy/terminus: 4.2.0
rxjs 6.5.3

 
For Tooling issues:
- Node version: 12.2.0 
- Platform: Linux 

Others:
- NPM version: 6.11.2

The health.proto missing from dist

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

If you try to use the gRPC health indicator without passing in options to override the proto path, you'll end up with an error like this:

[Nest] 1327   - 06/05/2019, 6:19 PM   [ExceptionHandler] ENOENT: no such file or directory, open '/workspace/node_modules/@nestjs/terminus/dist/health-indicators/microservice/protos/health.proto'

Expected behavior

You should be able to use the default health proto that comes with this package.

Minimal reproduction of the problem with instructions

// main.ts
import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create(ApplicationModule);
  await app.listen(3000);
}
bootstrap();
// health.module.ts
import { Module } from '@nestjs/common';
import {
  TerminusModule,
  TerminusModuleOptions,
  GRPCHealthIndicator,
} from '@nestjs/terminus';

const getTerminusOptions = (
  grpc: GRPCHealthIndicator,
): TerminusModuleOptions => ({
  endpoints: [
    {
      url: '/health',
      healthIndicators: [
        async () =>
          grpc.checkService('hero_service', 'hero.health.v1', {
            timeout: 2000,
          }),
      ],
    },
  ],
});

@Module({
  imports: [
    TerminusModule.forRootAsync({
      inject: [GRPCHealthIndicator],
      useFactory: getTerminusOptions,
    }),
  ],
})
export class HealthModule {}
// app.module.ts
import { Module } from '@nestjs/common';
import { HealthModule } from './health.module';

@Module({
  imports: [HealthModule],
})
export class ApplicationModule {}
curl localhost:3000/health

Yes, I know this example does not return a health indicator without having the corresponding gRPC health controller in this setup, but you'll still get the error regardless.

What is the motivation / use case for changing the behavior?

This is most likely caused by not copying the health.proto file into the dist folder when the package is published.

Environment


Nest version: X.Y.Z

 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

Don't require mysql as a prod dependency

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Mysql is a prod dependency.

Expected behavior

Mysql is a dev/optional dependency.

Minimal reproduction of the problem with instructions

None.

What is the motivation / use case for changing the behavior?

The mysql package is required as a dependency, but it's only used during tests.

Environment


Nest version: 5.5.1

 
For Tooling issues:
- Node version: 10  
- Platform: Linux 

Others:

TerminusModule causing several issues

I'm submitting a...


[x] Regression 
[ ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When I hit the following command below

npm install --save @nestjs/terminus @godaddy/terminus --no-optional

TerminusModule cannot be found from my workspace.

Whereas if I hit the same command without having --no-optional

I'm facing the same problem as I've mentioned above and it shows an extra error message as:

Parsing error: Unexpected character '@'eslint

However, the parsing error can be resolved by disabling an ESLint extension from the vscode.

If I manually write the import statement as follows:

import { TerminusModule, TypeOrmHealthIndicator, TerminusModuleOptions } from '@nestjs/terminus';

@Module({
  imports:[
    TerminusModule.forRootAsync({
      ...
    }),
  ],
})
export class HealthModule {}

everything works fine, but the CI server throws an error.

> nest build
src/internal/health.module.ts:2:79 - error TS2307: Cannot find module '@nestjs/terminus'.
2 import { TerminusModule, TypeOrmHealthIndicator, TerminusModuleOptions } from '@nestjs/terminus';
                                                                                ~~~~~~~~~~~~~~~~~~
Found 1 error(s).

Expected behavior

The build process should not be failed due to TerminusModule.

Minimal reproduction of the problem with instructions

https://github.com/jeffminsungkim/nest-terminus-import-issue

What is the motivation / use case for changing the behavior?

Environment


Nest version: 6.11.11

 
For Tooling issues:
- Node version: 11.15.0
- Platform:  macOS Catalina

Others:

Invalid npm package dependencies

I'm submitting a...


[ ] Regression 
[x ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When I download latest version of libraries via npm:

$ npm install --save @nestjs/terminus @godaddy/terminus

and I'm trying to use healtchecks like below:

import {
  TerminusEndpoint,
  TerminusOptionsFactory,
  DNSHealthIndicator,
  TypeOrmHealthIndicator,
  TerminusModuleOptions,
  MemoryHealthIndicator,
  DiskHealthIndicator,
} from '@nestjs/terminus';
import { Injectable } from '@nestjs/common';

@Injectable()
export class HealthCheck implements TerminusOptionsFactory {
  constructor(
    private readonly _dns: DNSHealthIndicator,
    private readonly _typeorm: TypeOrmHealthIndicator,
    private readonly _memoryHealthIndicator: MemoryHealthIndicator,
    private readonly _diskHealthIndicator: DiskHealthIndicator,
  ) {}

  public createTerminusOptions(): TerminusModuleOptions {
    const healthEndpoint: TerminusEndpoint = {
      url: '/health',
      healthIndicators: [
        async () => this._dns.pingCheck('google', 'https://google.com'),
        async () => this._typeorm.pingCheck('database', { timeout: 1500 }),
        async () =>
          this._diskHealthIndicator.checkStorage('storage', { thresholdPercent: 0.5, path: '/' }),
        async () => this._memoryHealthIndicator.checkRSS('rss', 500 * 1024 * 1024),
        async () => this._memoryHealthIndicator.checkHeap('heap', 100 * 1024 * 1024),
        async () => this._typeorm.pingCheck('database', { timeout: 1500 }),
      ],
    };
    return {
      endpoints: [healthEndpoint],
    };
  }
}

I'm receiving build errors. Please check image below:
image

I tried to install manually packages, but it still doesn't work.

Expected behavior

After $ npm install --save @nestjs/terminus @godaddy/terminus I expect to have every needed dependency, or detailed instruction what I should do if I want to use providers from official doc:
https://docs.nestjs.com/recipes/terminus

Minimal reproduction of the problem with instructions

$ npm install --save @nestjs/terminus @godaddy/terminus
$ tsc build

Environment

"@godaddy/terminus": "^4.1.2",
"@nestjs/terminus": "^6.3.1",
NodeJS: v10.16.0
Windows 10

Mongoose Compatibility

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

DatabaseHealthIndicator currently only supports TypeOrm.

Expected behavior

DatabaseHealth should also support Mongoose

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Nest version: X.Y.Z

 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

Document timeout

I'm submitting a...


[ ] Regression 
[ ] Bug report
[ ] Feature request
[x] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

It seems that a global timeout can be configured on Terminus, which the documentation does not tell anything.

Same for the health indicators, there is promiseTimeout util function, but it is not documented if one should use it.

Expected behavior

Explanation of timeouts, recommendation...

Environment


Nest version: 5.x
 
For Tooling issues:
- Node version: 10.15.3
- Platform:  Linux

Others:

Trailing Slash Ignored

I'm submitting a...


[ ] Regression 
[ x ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

URL trailing slashes are ignored.

/health -> 200
/health/ -> 404

Expected behavior

Hitting both /health and /health/ should resolve to the same endpoint.

Compatibility with middlewares

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Add a middleware via app.use() [with or without the FastifyAdapter], e.g:

app.use((req, res, next) => { logger.info("This is a request."); next(); });
Then call /health/readiness (or any terminus routes). No message is logged for terminus routes (but it is for other custom routes).

Note: I also have morgan set up for more convenient request logging, it doesn't work either. Version:

"morgan": "^1.9.1",

Expected behavior

The above middleware should log "This is a request" to the console on every request to a terminus route.

Minimal reproduction of the problem with instructions

See "Current behavior".

What is the motivation / use case for changing the behavior?

Using middlewares is supported by nest, and logging requests is useful for debugging, bug tracing, etc., so it would be a great addition/fix.

Environment


Nest version: 5.5.0
Nest terminus version: 5.5.2

 
For Tooling issues:
- Node version: v10.15.0  
- Platform: Linux/Docker 

Others:

Update dependency redis from 2.8.0 to 3.0.2

I'm submitting a...


[ ] Regression 
[X] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Expected behavior

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Nest version: X.Y.Z

 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

[CVE vulnerability here](https://nvd.nist.gov/vuln/detail/CVE-2018-11218)

Cannot inject providers into useFactory (async) - incompatible "unknown"


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

I am trying to use "useFactory" of forRootAsync

like so

   TerminusModule.forRootAsync({
      imports: [HealthModule],
      inject: [ConfigService, TerminusOptionsService],
      useFactory: async (
        configService: ConfigService,
        terminusOptionsService: TerminusOptionsService
      ): Promise<TerminusModuleOptions> => {
        // Do some logging.. etc

        return terminusOptionsService.createTerminusOptions()
      }
    }),

Problem is that for the args i..e configService and terminusOptionsService I got the following error

Type '(configService: ConfigService, terminusOptionsService: TerminusOptionsService) => Promise<TerminusModuleOptions>' is not assignable to type '(...args: unknown[]) => TerminusModuleOptions | Promise<TerminusModuleOptions>'.
  Types of parameters 'configService' and 'args' are incompatible.
    Type 'unknown' is not assignable to type 'ConfigService'.

I am trying to use it like I use other modules but it doesn't seem to allow me to inject providers

Any ideas ?

Expected behavior

To be able to use forRootAsync and useFactory and inject other things into the useFactory signature.

Minimal reproduction of the problem with instructions

->

What is the motivation / use case for changing the behavior?

Environment


Nest version: 6.1
 
For Tooling issues:
- Node version: 11
- Platform:  MAC
Others:

TypeOrmHealthIndicator type issue

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

There is a type error on TypeOrmHealthIndicator.pingCheck. Providing an instance of Connection throws a type error

Minimal reproduction of the problem with instructions

import { Injectable } from "@nestjs/common";
import {
  TerminusEndpoint,
  TerminusModuleOptions,
  TerminusOptionsFactory,
  TypeOrmHealthIndicator,
} from "@nestjs/terminus";
import { Connection } from "typeorm";

@Injectable()
export class TerminusOptionsService implements TerminusOptionsFactory {
  private readonly _myConn!: Connection;
  constructor(private readonly _typeOrm: TypeOrmHealthIndicator) {}

  createTerminusOptions(): TerminusModuleOptions {
    const connection: Connection = new Connection({
      type: "postgres",
      url: "psql://",
    });
    const healthEndpoint: TerminusEndpoint = {
      healthIndicators: [
        async () => this._typeOrm.pingCheck("database", { connection }),
      ],
      url: "/health",
    };
    return { endpoints: [healthEndpoint] };
  }
}

Produces the type error (on connection inside TypeOrmPingCheckSettings):

Argument of type '{ connection: Connection; }' is not assignable to parameter of type 'TypeOrmPingCheckSettings'.
  The types of 'connection.options' are incompatible between these types.
    Type 'import("/Users/dfee/myapp/node_modules/typeorm/connection/ConnectionOptions").ConnectionOptions' is not assignable to type 'import("/Users/dfee/myapp/node_modules/@nestjs/terminus/node_modules/typeorm/connection/ConnectionOptions").ConnectionOptions'.
      Type 'MysqlConnectionOptions' is not assignable to type 'ConnectionOptions'.
        Type 'import("/Users/dfee/myapp/node_modules/typeorm/driver/mysql/MysqlConnectionOptions").MysqlConnectionOptions' is not assignable to type 'import("/Users/dfee/myapp/node_modules/@nestjs/terminus/node_modules/typeorm/driver/mysql/MysqlConnectionOptions").MysqlConnectionOptions'.
          Types of property 'entities' are incompatible.
            Type '(string | Function | import("/Users/dfee/myapp/node_modules/typeorm/entity-schema/EntitySchema").EntitySchema<any>)[] | undefined' is not assignable to type '(string | Function | import("/Users/dfee/myapp/node_modules/@nestjs/terminus/node_modules/typeorm/entity-schema/EntitySchema").EntitySchema<any>)[] | undefined'.
              Type '(string | Function | import("/Users/dfee/myapp/node_modules/typeorm/entity-schema/EntitySchema").EntitySchema<any>)[]' is not assignable to type '(string | Function | import("/Users/dfee/myapp/node_modules/@nestjs/terminus/node_modules/typeorm/entity-schema/EntitySchema").EntitySchema<any>)[]'.
                Type 'string | Function | import("/Users/dfee/myapp/node_modules/typeorm/entity-schema/EntitySchema").EntitySchema<any>' is not assignable to type 'string | Function | import("/Users/dfee/myapp/node_modules/@nestjs/terminus/node_modules/typeorm/entity-schema/EntitySchema").EntitySchema<any>'.
                  Type 'EntitySchema<any>' is not assignable to type 'string | Function | EntitySchema<any>'.
                    Type 'import("/Users/dfee/myapp/node_modules/typeorm/entity-schema/EntitySchema").EntitySchema<any>' is not assignable to type 'import("/Users/dfee/myapp/node_modules/@nestjs/terminus/node_modules/typeorm/entity-schema/EntitySchema").EntitySchema<any>'.
                      The types of 'options.columns' are incompatible between these types.
                        Type '{ [x: string]: import("/Users/dfee/myapp/node_modules/typeorm/entity-schema/EntitySchemaColumnOptions").EntitySchemaColumnOptions | undefined; }' is not assignable to type '{ [x: string]: import("/Users/dfee/myapp/node_modules/@nestjs/terminus/node_modules/typeorm/entity-schema/EntitySchemaColumnOptions").EntitySchemaColumnOptions | undefined; }'.
                          Index signatures are incompatible.
                            Type 'import("/Users/dfee/myapp/node_modules/typeorm/entity-schema/EntitySchemaColumnOptions").EntitySchemaColumnOptions | undefined' is not assignable to type 'import("/Users/dfee/myapp/node_modules/@nestjs/terminus/node_modules/typeorm/entity-schema/EntitySchemaColumnOptions").EntitySchemaColumnOptions | undefined'.
                              Type 'import("/Users/dfee/myapp/node_modules/typeorm/entity-schema/EntitySchemaColumnOptions").EntitySchemaColumnOptions' is not assignable to type 'import("/Users/dfee/myapp/node_modules/@nestjs/terminus/node_modules/typeorm/entity-schema/EntitySchemaColumnOptions").EntitySchemaColumnOptions'.
                                Types of property 'type' are incompatible.
                                  Type 'import("/Users/dfee/myapp/node_modules/typeorm/driver/types/ColumnTypes").ColumnType' is not assignable to type 'import("/Users/dfee/myapp/node_modules/@nestjs/terminus/node_modules/typeorm/driver/types/ColumnTypes").ColumnType'.
                                    Type '"smalldecimal"' is not assignable to type 'ColumnType'.ts(2345)

Environment


Nest version: 6.11.5

 
For Tooling issues:
- Node version: 13.3.0
- Platform:  Mac

Others:
- typescript: 3.7.5
- typeorm: 0.2.22
- @nestjs/typeorm: 6.2.0

TypeOrmHealthIndicator always returning up (with no mongodb connection)

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

TypeOrmHealthIndicator always returns positive result, whether it is connected to MongoDB, or not.

options passed:

    {
      url: '/health',
      healthIndicators: [
        async () => this.db.pingCheck('database', { timeout: 200 }),
      ],
    }

health result:

{"status":"ok","info":{"database":{"status":"up"}},"details":{"database":{"status":"up"}}}

Expected behavior

It should return error if there is no connection to the MongoDB.

Minimal reproduction of the problem with instructions

I prepared basic example here:
https://github.com/jacob87o2/nest/tree/terminus-typeorm-health-issue-reproduction/sample/13-mongo-typeorm

After downloading/cloning the repo, go to the folder above and:

  1. Install dependencies (npm install)
  2. Run mongodb (docker-compose up -d)
  3. Run NestJS (nest start)
  4. Stop mongodb (in separate terminal - docker-compose down)
  5. Check health endpoint (go to http://localhost:3000/health)

What is the motivation / use case for changing the behavior?

Environment


[Nest Information]
terminus version         : 6.5.5
typeorm version          : 6.2.0
common version           : 6.7.2
core version             : 6.7.2

Compatibility with FastifyAdapter

I'm submitting a...


[ ] Regression 
[?] Bug report
[?] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Using the "FastifyAdapter" the server fails to start with the message

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'listeners' of undefined

Expected behavior

The server starts and the added health check URLs are available.

Minimal reproduction of the problem with instructions

App:

  • Basic setup of nest from the first-steps docs
    • index.ts with app = nestfactory.create() and app.listen,
    • app.module;
      • controllers: app.controller, which has a single @get(/hello) route
      • imports: HealthModule, that's the same as the one in the README, but DatabaseHealthIndicator replaced with DNSHealthIndicator which pings google

This start like expected:
const app = await NestFactory.create(AppModule); await app.listen(20000);

This fails with the mentioned error:
const app = await NestFactory.create(AppModule, new FastifyAdapter()); await app.listen(20000);

Note:

  • When using fastify/fastify with godaddy/terminus it works with this: createTerminus(fastify.server, options); (everything else is just copy/paste from their respective READMEs)

What is the motivation / use case for changing the behavior?

Nest provides FastifyAdapter by default, nestjs/terminus should be compatible with it.

Environment


Nest version: 5.5.1

 
For Tooling issues:
- Node version: 10.14.2  
- Platform: Linux running docker, image: 10.14.2-alpine ; but also Linux running 10.13.0 directly

Others:

Build samples in pipeline

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

At the moment it is hard to track whether the samples are up to date.

Expected behavior

On each commit / tag Travis should build all the samples, so we can assure that everything is working just fine.

What is the motivation / use case for changing the behavior?

To prevent inconsistent samples, run them in a pipeline.

How to disable logger

I'm submitting a...


[ ] Regression 
[ ] Bug report
[X] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

On every failed healthcheck response terminus creates a log message. In my case I'd like to log that on my own, since I expect failed healthchecks occosionally.

Expected behavior

Option to disable logging.

OnApplicationShutdown hook

I'm submitting a...


[ ] Regression
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

I have an app with the Terminus module and the app also have the shutdown hooks enabled.
When I try to stop the app with a SIGTERM, the underlying http server is closed before the shutdown hooks are executed. It also trigger two times the shutdown hooks.

[Nest] 31043   - 08/07/2019, 2:37 PM   [NestApplication] Nest application successfully started +4ms
[Nest] 31043   - 08/07/2019, 2:37 PM   [OnApplicationShutdown] Started at Wed Aug 07 2019 14:37:41 GMT+0200 (Central European Summer Time) +6318ms
// The http server is stop somewhere here.
[Nest] 31043   - 08/07/2019, 2:37 PM   [OnApplicationShutdown] Started at Wed Aug 07 2019 14:37:42 GMT+0200 (Central European Summer Time) +1007ms
[Nest] 31043   - 08/07/2019, 2:37 PM   [OnApplicationShutdown] Completed at Wed Aug 07 2019 14:37:48 GMT+0200 (Central European Summer Time) +6352ms
[Nest] 31043   - 08/07/2019, 2:37 PM   [OnApplicationShutdown] Completed at Wed Aug 07 2019 14:37:48 GMT+0200 (Central European Summer Time) +1ms

Expected behavior

The http server should stay until all shutdown hooks are resolved and the onApplicationShutdown hook should be call only one time.

Minimal reproduction of the problem with instructions

Clone this repo

Compile the app with npm run build then start it.

Curl the local server with curl --location --request GET "localhost:3000/" and stop the process with a SIGTERM while request is being processed.

What is the motivation / use case for changing the behavior?

The server should be able to process already accepted requests before shutting down.

Environment


Nest version: 6.5.3
@nestjs/terminus version: 6.5.0

 
For Tooling issues:
- Node version: 10.16.0 
- Platform:  MacOS, Containerized ubuntu 18

Possible solution :

The problem seems to come from there with this not allowing the configuration of the beforeShutdown hook on godaddy/terminus. Allowing user to configure the beforeShutdown hook here or setting a promise based timeout should fix the http server problem.

Consider removing certain peerDependencies

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Performing a yarn install outputs several "missing peerDependency" warnings.

Example:

@nestjs/[email protected]" has unmet peer dependency "@grpc/proto-loader@^0.5.0".
@nestjs/[email protected]" has unmet peer dependency "@nestjs/mongoose@^6.1.2".
@nestjs/[email protected]" has unmet peer dependency "@nestjs/platform-fastify@^6.0.0".
@nestjs/[email protected]" has unmet peer dependency "@nestjs/typeorm@^6.0.0".
@nestjs/[email protected]" has unmet peer dependency "amqp-connection-manager@^2.3.1".
@nestjs/[email protected]" has unmet peer dependency "amqplib@^0.5.3".
@nestjs/[email protected]" has unmet peer dependency "grpc@^1.20.0".
@nestjs/[email protected]" has unmet peer dependency "mongoose@^5.5.2".
@nestjs/[email protected]" has unmet peer dependency "nats@^1.2.10".
@nestjs/[email protected]" has unmet peer dependency "redis@^2.8.0".
@nestjs/[email protected]" has unmet peer dependency "typeorm@^0.2.16".

Expected behavior

I should be able to run the installation instructions and get no warnings during installation.

There is nothing "broken" about this - technically - but getting warnings for packages that I might never install and are not strictly required in order to make the package work should exist in optionalDependencies in my opinion.

Minimal reproduction of the problem with instructions

Simply run the installation instructions in a fresh NestJS app.

What is the motivation / use case for changing the behavior?

See "Expected behavior"

Environment


Nest version: 6.1.1

 
For Tooling issues:
- Node version: 10.15.3
- Platform:  MacOS, Alpine Linux

Others:
- Yarn version: 1.16.0

Dependency issue using providers/exports for TerminusFactoryService


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

I got an error on bootstrapping of nestjs

[Nest] 40293   - 04/29/2019, 12:29 PM   [ExceptionHandler] Nest can't resolve dependencies of the TerminusOptionsService (LoggerFactoryService, Connection, ?, DNSHealthIndicator, DiskHealthIndicator, MemoryHealthIndicator). Please make sure that the argument at index [2] is available in the HealthModule context. +3ms
Error: Nest can't resolve dependencies of the TerminusOptionsService (LoggerFactoryService, Connection, ?, DNSHealthIndicator, DiskHealthIndicator, MemoryHealthIndicator). Please make sure that the argument at index [2] is available in the HealthModule context.

Actually its not the 3rds param at Index [2], if I remove that and leave DnsHealthIndicator, does the same. Its anything that is part of the TerminusModule

I have created a standard TerminusOptionsFactory and I am trying to Provide and Export it

like so

import { HealthCheckError } from "@godaddy/terminus"
import { Injectable } from "@nestjs/common"
import {
  DiskHealthIndicator,
  DNSHealthIndicator,
  HealthIndicatorResult,
  MemoryHealthIndicator,
  TerminusEndpoint,
  TerminusLogger,
  TerminusModuleOptions,
  TerminusOptionsFactory,
  TypeOrmHealthIndicator
} from "@nestjs/terminus"
import { LoggerFactoryService } from "@prime/nest-logger"
import { Connection } from "typeorm"

@Injectable()
export class TerminusOptionsService implements TerminusOptionsFactory {
  constructor(
    private readonly loggerFactoryService: LoggerFactoryService,
    private readonly connection: Connection,
    private readonly typeOrmHealthIndicator: TypeOrmHealthIndicator,
    private readonly dns: DNSHealthIndicator,
    private readonly diskHealthIndicator: DiskHealthIndicator,
    private readonly memoryHealthIndicator: MemoryHealthIndicator
  ) {}

and I am using in the module like so

import { Module } from "@nestjs/common"
import { TerminusModule } from "@nestjs/terminus"

import { TerminusOptionsService } from "./terminus-options.service"

@Module({
  imports: [TerminusModule],
  exports: [],
  providers: [TerminusOptionsService]
})
export class HealthModule {}

Expected behavior

Import TerminusModule into my module, I would assume that I can list my factory in the provider of the module but it complains.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Nest version: 6.1
 
For Tooling issues:
- Node version:11
- Platform:MAC
Others:

Run test cases in parallel

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

At the moment the test cases run sequentially, because the express instances would need a free port for each test run

Expected behavior

Each express instance should get a new port assigned in each test case using
https://github.com/indexzero/node-portfinder

What is the motivation / use case for changing the behavior?

Faster test execution

too many dependencies

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

install all the packages

Expected behavior

do not install the packages I don't need

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

{
    "@nestjs/terminus": {
      "version": "6.5.6",
      "resolved": "https://registry.npm.taobao.org/@nestjs/terminus/download/@nestjs/terminus-6.5.6.tgz",
      "integrity": "sha1-6XejwZG5NrbZGVyrQ/rYEslykXA=",
      "requires": {
        "@grpc/proto-loader": "0.5.3",
        "@nestjs/microservices": "6.11.6",
        "@nestjs/mongoose": "6.3.1",
        "@nestjs/platform-express": "6.11.6",
        "@nestjs/platform-fastify": "6.11.6",
        "@nestjs/typeorm": "6.2.0",
        "amqp-connection-manager": "3.2.0",
        "amqplib": "0.5.5",
        "check-disk-space": "2.1.0",
        "grpc": "1.24.2",
        "mongoose": "5.8.11",
        "mqtt": "3.0.0",
        "nats": "1.4.0",
        "redis": "2.8.0",
        "typeorm": "0.2.22"
      },
}

Environment


Nest version: 6.5.6

 
For Tooling issues:
- Node version:  v12.14.1 
- Platform:  Linux 

Others:

url doesn't take into consideration the setGlobalPrefix


[ ] Regression 
[x] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Adding the url to the terminus doesn't take into consideration . the setGlobalPrefix..

For example, i have some metrics endpoints and that can be accessed via

https://localhost:3009/api/metrics

this is because I have the following set

    app.setGlobalPrefix("api")

but terminus ignores this, and it is still available on /health and not /api/health

The reason I need this is that the root is being proxied, so I need to add any custom endpoints under /api

I have terminus configured like so

 const healthEndpoint: TerminusEndpoint = {
      healthIndicators: [],
      url: "/health"
    }

Expected behavior

For terminus to take into consideration the setGlobalPrefix

Environment


Nest version: 6.1
 
For Tooling issues:
- Node version:11
- Platform:  MAC

Swagger compatibility

I'm submitting a...


[ ] Regression 
[ ] Bug report
[?] Feature request
[x] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

There's no documented way for enabling swagger integration for the health endpoints.

Expected behavior

Documentation for enabling swagger integration for the health endpoints.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

I have swagger enabled so I can benefit from the autogenerated documentation for my API. When enabling terminus, its endpoints (e.g /health/readiness) do not show up on the list.

I can add a custom controller with the same endpoint (AppController / @get('health/readiness') ) and then it is registered and the terminus-code is executed, but that isn't a clean way of doing this.

Environment


Nest version: 5.5.0
Nest terminus version: 5.5.2

 
For Tooling issues:
- Node version: v10.15.0  
- Platform: Linux / Docker 

Others:

Missing documentation

I'm submitting a...


[ ] Regression 
[ ] Bug report
[ ] Feature request
[X] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

No docs at all

Expected behavior

Documentation on docs.nestjs.com

I'd like to try nest-terminus and I am looking for a detailed documentation which I can test in a "blackbox" fashion without looking at the code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.