-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: generating new clients implementing GenericClient on generate c…
…ommand
- Loading branch information
Showing
24 changed files
with
770 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Examples | ||
|
||
- [Using the generated client](./generated_client/README.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// This file was generated using @lewnelson/grpc-ts | ||
// Do not modify this file directly | ||
|
||
import { createClient, UnaryRequest, ReadableStreamRequest, WriteableStreamRequest, DuplexStreamRequest } from "@lewnelson/grpc-ts"; | ||
import { ExampleClient as grpc_ExampleClient } from "./example_grpc_pb"; | ||
|
||
export interface IExampleClient { | ||
getName: UnaryRequest<grpc_ExampleClient, "getName">; | ||
streamMessages: ReadableStreamRequest<grpc_ExampleClient, "streamMessages">; | ||
emitMessages: WriteableStreamRequest<grpc_ExampleClient, "emitMessages">; | ||
chat: DuplexStreamRequest<grpc_ExampleClient, "chat">; | ||
} | ||
|
||
export class ExampleClient implements IExampleClient { | ||
constructor(address: Parameters<typeof createClient>[1], options?: Parameters<typeof createClient>[2]); | ||
getName: UnaryRequest<grpc_ExampleClient, "getName">; | ||
streamMessages: ReadableStreamRequest<grpc_ExampleClient, "streamMessages">; | ||
emitMessages: WriteableStreamRequest<grpc_ExampleClient, "emitMessages">; | ||
chat: DuplexStreamRequest<grpc_ExampleClient, "chat">; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// This file was generated using @lewnelson/grpc-ts | ||
// Do not modify this file directly | ||
|
||
const { createClient } = require("@lewnelson/grpc-ts"); | ||
const grpc = require("./example_grpc_pb"); | ||
|
||
class ExampleClient { | ||
constructor() { | ||
this.client = createClient(grpc.ExampleClient, ...arguments); | ||
} | ||
|
||
getName() { | ||
return this.client.unaryRequest("getName", ...arguments); | ||
} | ||
|
||
streamMessages() { | ||
return this.client.serverStreamRequest("streamMessages", ...arguments); | ||
} | ||
|
||
emitMessages() { | ||
return this.client.clientStreamRequest("emitMessages", ...arguments); | ||
} | ||
|
||
chat() { | ||
return this.client.duplexStreamRequest("chat", ...arguments); | ||
} | ||
} | ||
|
||
exports.ExampleClient = ExampleClient; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Generated client examples | ||
|
||
The `grpc-ts` CLI tool will generate the output from [grpc-tools](https://www.npmjs.com/package/grpc-tools) as well as creating a client class which uses the [GenericClient](../generic_client/README.md) under the hood to make requests. | ||
|
||
The client class method names are a 1:1 mapping of the methods defined in the generated client class on the `_grpc_pb.d.ts` files. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,20 @@ | ||
/** @type {import("ts-jest").JestConfigWithTsJest} */ | ||
module.exports = { | ||
preset: "ts-jest", | ||
transform: { | ||
"^.+\\.ts$": [ | ||
"ts-jest", | ||
{ | ||
tsconfig: "<rootDir>/test/tsconfig.json", | ||
}, | ||
], | ||
}, | ||
testEnvironment: "node", | ||
setupFilesAfterEnv: ["./jest.setup.ts"], | ||
collectCoverage: true, | ||
coverageDirectory: "./coverage", | ||
coveragePathIgnorePatterns: ["/node_modules/", "/generated/"], | ||
moduleNameMapper: { | ||
"^@lewnelson/grpc-ts$": "<rootDir>/src/index.ts", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.