From 85fc7328a84698a33a20458c7db6aefc10f40b2d Mon Sep 17 00:00:00 2001 From: Tejas Mehta Date: Sat, 30 Mar 2024 11:03:59 -0400 Subject: [PATCH] fix tests --- packages/logging-service/src/app.module.ts | 12 ++++-------- packages/proto/definitions/error_logging.proto | 15 --------------- packages/proto/definitions/logging.proto | 10 +++++++++- packages/proto/src/gen/logging.ts | 18 +++++++++++++++++- 4 files changed, 30 insertions(+), 25 deletions(-) delete mode 100644 packages/proto/definitions/error_logging.proto diff --git a/packages/logging-service/src/app.module.ts b/packages/logging-service/src/app.module.ts index 6b8bf71..9b42937 100644 --- a/packages/logging-service/src/app.module.ts +++ b/packages/logging-service/src/app.module.ts @@ -3,7 +3,8 @@ import { AppController } from './app.controller'; import { AppService } from './app.service'; import { LoggingModule } from './modules/logging/logging.module'; import { ClientsModule, Transport } from '@nestjs/microservices'; -import * as path from 'path'; +import { JUNO_LOGGING_PACKAGE_NAME } from 'juno-proto/dist/gen/logging'; +import { LoggingProtoFile } from 'juno-proto'; @Module({ imports: [ @@ -13,13 +14,8 @@ import * as path from 'path'; name: 'LOGGING_SERVICE', transport: Transport.GRPC, options: { - package: 'error_logging', - protoPath: path.join( - __dirname, - '../../', - 'juno-proto/dist/definitions', - 'error_logging.proto', - ), + package: JUNO_LOGGING_PACKAGE_NAME, + protoPath: [LoggingProtoFile], }, }, ]), diff --git a/packages/proto/definitions/error_logging.proto b/packages/proto/definitions/error_logging.proto deleted file mode 100644 index 47a1637..0000000 --- a/packages/proto/definitions/error_logging.proto +++ /dev/null @@ -1,15 +0,0 @@ -syntax = "proto3"; - -package logging; - -service LoggingService { - rpc recordError (ErrorLogRequest) returns (ErrorLogResponse) {} -} - -// The request message containing the error message. -message ErrorLogRequest { - string message = 1; -} - -// TODO: to be defined later -message ErrorLogResponse {} \ No newline at end of file diff --git a/packages/proto/definitions/logging.proto b/packages/proto/definitions/logging.proto index 7375727..ff521ca 100644 --- a/packages/proto/definitions/logging.proto +++ b/packages/proto/definitions/logging.proto @@ -4,10 +4,18 @@ package juno.logging; service LoggingService { rpc recordInfo(RecordInfoRequest) returns (RecordInfoResponse); + rpc recordError (ErrorLogRequest) returns (ErrorLogResponse) {} } message RecordInfoRequest { string message = 1; } -message RecordInfoResponse {} \ No newline at end of file +message RecordInfoResponse {} + +message ErrorLogRequest { + string message = 1; +} + +// TODO: to be defined later +message ErrorLogResponse {} diff --git a/packages/proto/src/gen/logging.ts b/packages/proto/src/gen/logging.ts index 3d14044..f6c2676 100644 --- a/packages/proto/src/gen/logging.ts +++ b/packages/proto/src/gen/logging.ts @@ -10,10 +10,19 @@ export interface RecordInfoRequest { export interface RecordInfoResponse {} +export interface ErrorLogRequest { + message: string; +} + +/** TODO: to be defined later */ +export interface ErrorLogResponse {} + export const JUNO_LOGGING_PACKAGE_NAME = 'juno.logging'; export interface LoggingServiceClient { recordInfo(request: RecordInfoRequest): Observable; + + recordError(request: ErrorLogRequest): Observable; } export interface LoggingServiceController { @@ -23,11 +32,18 @@ export interface LoggingServiceController { | Promise | Observable | RecordInfoResponse; + + recordError( + request: ErrorLogRequest, + ): + | Promise + | Observable + | ErrorLogResponse; } export function LoggingServiceControllerMethods() { return function (constructor: Function) { - const grpcMethods: string[] = ['recordInfo']; + const grpcMethods: string[] = ['recordInfo', 'recordError']; for (const method of grpcMethods) { const descriptor: any = Reflect.getOwnPropertyDescriptor( constructor.prototype,