Skip to content

Commit

Permalink
feat: conditionally add "Service" to nice-grpc's generated service in…
Browse files Browse the repository at this point in the history
…terface name (#710)

* Conditionally add "Service" to nice-grpc's generated service interface name

* Extract maybeSuffix.

Co-authored-by: Stephen Haberman <stephen.haberman@gmail.com>
  • Loading branch information
krugi and stephenh committed Nov 25, 2022
1 parent def9f3f commit 7c39cc0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/generate-nice-grpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export function generateNiceGrpcService(
function generateServerStub(ctx: Context, sourceInfo: SourceInfo, serviceDesc: ServiceDescriptorProto) {
const chunks: Code[] = [];

chunks.push(code`export interface ${def(`${serviceDesc.name}ServiceImplementation`)}<CallContextExt = {}> {`);
const maybeSuffix = serviceDesc.name.endsWith("Service") ? "" : "Service";
chunks.push(code`export interface ${def(`${serviceDesc.name}${maybeSuffix}Implementation`)}<CallContextExt = {}> {`);

for (const [index, methodDesc] of serviceDesc.method.entries()) {
assertInstanceOf(methodDesc, FormattedMethodDescriptor);
Expand Down

0 comments on commit 7c39cc0

Please sign in to comment.