nestjs / terminus

Terminus module for Nest framework (node.js) :robot:
https://nestjs.com/
MIT License
675 stars 100 forks source link

The health.proto missing from dist #224

Closed ethanrubio closed 5 years ago

ethanrubio commented 5 years ago

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:

BrunnerLivio commented 5 years ago

Thanks for reporting! Indeed, I forgot to copy the proto file into the dist folder. Fixed by using gulp now as build task and copying proto files in @nestjs/terminus@6.3.1.