Skip to content

Commit

Permalink
fix: adapt new grpc
Browse files Browse the repository at this point in the history
  • Loading branch information
ZigBalthazar committed Jan 8, 2025
1 parent 9a8533b commit c005280
Show file tree
Hide file tree
Showing 17 changed files with 291 additions and 340 deletions.
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { AppModule } from './app.module';
import { setupSwagger } from './setup-swagger';
import { ApiConfigService } from './shared/services/api-config.service';
import { SharedModule } from './shared/shared.module';
import { MANAGER_V1_PACKAGE_NAME } from './modules/grpc/gen/ts/config';

async function bootstrap() {
const app = await NestFactory.create<NestExpressApplication>(AppModule, new ExpressAdapter(), {
Expand Down Expand Up @@ -69,7 +70,7 @@ async function bootstrap() {
onLoadPackageDefinition: (pkg, server) => {
new ReflectionService(pkg).addToServer(server);

Check failure on line 71 in src/main.ts

View workflow job for this annotation

GitHub Actions / ESLint

src/main.ts#L71

Unsafe argument of type `any` assigned to a parameter of type `PackageDefinition` (@typescript-eslint/no-unsafe-argument)

Check failure on line 71 in src/main.ts

View workflow job for this annotation

GitHub Actions / ESLint

src/main.ts#L71

Unsafe argument of type `any` assigned to a parameter of type `Pick<Server, "addService">` (@typescript-eslint/no-unsafe-argument)
},
package: 'kraken',
package: MANAGER_V1_PACKAGE_NAME,
protoPath: configService.grpcConfig.protoPath,
url: `0.0.0.0:${configService.grpcConfig.port}`,
},
Expand Down
11 changes: 5 additions & 6 deletions src/modules/config/controllers/config-grpc.controller.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { Controller, UseInterceptors } from '@nestjs/common';

Check failure on line 1 in src/modules/config/controllers/config-grpc.controller.ts

View workflow job for this annotation

GitHub Actions / ESLint

src/modules/config/controllers/config-grpc.controller.ts#L1

Run autofix to sort these imports! (simple-import-sort/imports)

import type { ConfigController, EmptyRequest, getConfigResponse } from '../../../../src/modules/grpc/gen/ts/kraken';
import { ConfigControllerMethods } from '../../../../src/modules/grpc/gen/ts/kraken';
import { GrpcInvalidArgumentException, GrpcToHttpInterceptor } from 'nestjs-grpc-exceptions';
import { ConfigService } from '../config.service';
import { Metadata } from '@grpc/grpc-js';

Check failure on line 5 in src/modules/config/controllers/config-grpc.controller.ts

View workflow job for this annotation

GitHub Actions / ESLint

src/modules/config/controllers/config-grpc.controller.ts#L5

All imports in the declaration are only used as types. Use `import type` (@typescript-eslint/consistent-type-imports)
import { GetParametersRequest, GetParametersResponse, ParametersController, ParametersControllerMethods } from '../../../../src/modules/grpc/gen/ts/config';

Check failure on line 6 in src/modules/config/controllers/config-grpc.controller.ts

View workflow job for this annotation

GitHub Actions / ESLint

src/modules/config/controllers/config-grpc.controller.ts#L6

This line has a length of 156. Maximum allowed is 150 (max-len)

Check failure on line 6 in src/modules/config/controllers/config-grpc.controller.ts

View workflow job for this annotation

GitHub Actions / ESLint

src/modules/config/controllers/config-grpc.controller.ts#L6

Imports "GetParametersRequest", "GetParametersResponse" and "ParametersController" are only used as types (@typescript-eslint/consistent-type-imports)

Check failure on line 6 in src/modules/config/controllers/config-grpc.controller.ts

View workflow job for this annotation

GitHub Actions / ESLint

src/modules/config/controllers/config-grpc.controller.ts#L6

Replace `·GetParametersRequest,·GetParametersResponse,·ParametersController,·ParametersControllerMethods·` with `⏎··GetParametersRequest,⏎··GetParametersResponse,⏎··ParametersController,⏎··ParametersControllerMethods,⏎` (prettier/prettier)

@Controller()
@ConfigControllerMethods()
@ParametersControllerMethods()
@UseInterceptors(GrpcToHttpInterceptor)
export class ConfigGrpcController implements ConfigController {
export class ConfigGrpcController implements ParametersController {
constructor(private readonly configService: ConfigService) {}

async getConfig(_request: EmptyRequest, _metadata?: Metadata): Promise<getConfigResponse> {
async getParameters(_request: GetParametersRequest, _metadata?: Metadata): Promise<GetParametersResponse> {
const token = _metadata?.get('x-identifier')?.[0] as string | undefined;

Check failure on line 15 in src/modules/config/controllers/config-grpc.controller.ts

View workflow job for this annotation

GitHub Actions / ESLint

src/modules/config/controllers/config-grpc.controller.ts#L15

Unnecessary optional chain on a non-nullish value (@typescript-eslint/no-unnecessary-condition)
if (!token) {

Check failure on line 16 in src/modules/config/controllers/config-grpc.controller.ts

View workflow job for this annotation

GitHub Actions / ESLint

src/modules/config/controllers/config-grpc.controller.ts#L16

Expected blank line before this statement (padding-line-between-statements)
throw new GrpcInvalidArgumentException("input 'x-identifier' is not valid.");
Expand All @@ -37,6 +36,6 @@ export class ConfigGrpcController implements ConfigController {
defaultQueryLimit: limitations?.default_query_limit,
maxQueryLimit: limitations?.max_limit,
},
} as getConfigResponse;
} as GetParametersResponse;
}
}
67 changes: 67 additions & 0 deletions src/modules/grpc/gen/ts/config.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

219 changes: 0 additions & 219 deletions src/modules/grpc/gen/ts/kraken.ts

This file was deleted.

52 changes: 52 additions & 0 deletions src/modules/grpc/gen/ts/log.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c005280

Please sign in to comment.