Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate ServiceType #1057

Open
yuusheng opened this issue Jan 19, 2025 · 0 comments
Open

Generate ServiceType #1057

yuusheng opened this issue Jan 19, 2025 · 0 comments

Comments

@yuusheng
Copy link

Currently, we don't export an interface to describe the service.

For example:

syntax = "proto3";

package hero;

service HeroesService { rpc FindOne(HeroById) returns (Hero); }

message HeroById { int32 id = 1; }

message Hero {
  int32 id = 1;
  string name = 2;
}

will generate:

// @generated by protoc-gen-es v2.2.3 with parameter "target=ts"
// @generated from file hero.proto (package hero, syntax proto3)
/* eslint-disable */

import type { GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv1";
import { fileDesc, messageDesc, serviceDesc } from "@bufbuild/protobuf/codegenv1";
import type { Message } from "@bufbuild/protobuf";

// ...message stuff

/**
 * @generated from service hero.HeroesService
 */
export const HeroesService: GenService<{
  /**
   * @generated from rpc hero.HeroesService.FindOne
   */
  findOne: {
    methodKind: "unary";
    input: typeof HeroByIdSchema;
    output: typeof HeroSchema;
  },
}> = /*@__PURE__*/
  serviceDesc(file_hero, 0);

I suppose we should also have a HeroesService interface

export interface HeroesService {
  FindOne(request: HeroById): Promise<Hero>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant