forked from commitdev/zero
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from commitdev/grpc-web-typescript-support
#6 add grpc-web typescript generation support
- Loading branch information
Showing
6 changed files
with
89 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,36 @@ | ||
PROTOC_VERSION := 3.9.2 | ||
PROTOC_WEB_VERSION := 1.0.6 | ||
PROTO_SOURCES := -I /usr/local/include | ||
PROTO_SOURCES += -I . | ||
PROTO_SOURCES += -I ${GOPATH}/src | ||
PROTO_SOURCES += -I ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis | ||
|
||
deps-linux: deps-protoc-linux deps-grpc-web-linux | ||
|
||
|
||
deps-linux: | ||
deps-protoc-linux: | ||
curl -OL https://github.com/google/protobuf/releases/download/v$(PROTOC_VERSION)/protoc-$(PROTOC_VERSION)-linux-x86_64.zip | ||
unzip protoc-$(PROTOC_VERSION)-linux-x86_64.zip -d protoc3 | ||
sudo mv protoc3/bin/* /usr/local/bin/ | ||
sudo mv protoc3/include/* /usr/local/include/ | ||
rm -rf protoc3 protoc-$(PROTOC_VERSION)-linux-x86_64.zip | ||
|
||
generate: | ||
deps-grpc-web-linux: | ||
curl -OL https://github.com/grpc/grpc-web/releases/download/$(PROTOC_WEB_VERSION)/protoc-gen-grpc-web-$(PROTOC_WEB_VERSION)-linux-x86_64 | ||
sudo mv protoc-gen-grpc-web-$(PROTOC_WEB_VERSION)-linux-x86_64 /usr/local/bin/protoc-gen-grpc-web | ||
chmod +x /usr/local/bin/protoc-gen-grpc-web | ||
|
||
generate: generate-grpc generate-web | ||
|
||
generate-grpc: | ||
mkdir -p gen/go | ||
protoc ${PROTO_SOURCES} --go_out=plugins=grpc:./gen/go ./proto/health/*.proto | ||
protoc ${PROTO_SOURCES} --go_out=plugins=grpc:./gen/go ./proto/helloworld/*.proto | ||
cp -f -rv gen/go/proto/* gen/go | ||
rm -rf gen/go/proto | ||
generate-web: | ||
mkdir -p gen/web | ||
protoc ${PROTO_SOURCES} --grpc-web_out=import_style=typescript,mode=grpcwebtext:gen/web ./proto/health/*.proto | ||
protoc ${PROTO_SOURCES} --grpc-web_out=import_style=typescript,mode=grpcwebtext:gen/web ./proto/helloworld/*.proto | ||
cp -f -rv gen/web/proto/* gen/web | ||
rm -rf gen/web/Proto gen/web/proto | ||
|
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,45 @@ | ||
import * as jspb from "google-protobuf" | ||
|
||
export class HealthCheckRequest extends jspb.Message { | ||
getService(): string; | ||
setService(value: string): void; | ||
|
||
serializeBinary(): Uint8Array; | ||
toObject(includeInstance?: boolean): HealthCheckRequest.AsObject; | ||
static toObject(includeInstance: boolean, msg: HealthCheckRequest): HealthCheckRequest.AsObject; | ||
static serializeBinaryToWriter(message: HealthCheckRequest, writer: jspb.BinaryWriter): void; | ||
static deserializeBinary(bytes: Uint8Array): HealthCheckRequest; | ||
static deserializeBinaryFromReader(message: HealthCheckRequest, reader: jspb.BinaryReader): HealthCheckRequest; | ||
} | ||
|
||
export namespace HealthCheckRequest { | ||
export type AsObject = { | ||
service: string, | ||
} | ||
} | ||
|
||
export class HealthCheckResponse extends jspb.Message { | ||
getStatus(): HealthCheckResponse.ServingStatus; | ||
setStatus(value: HealthCheckResponse.ServingStatus): void; | ||
|
||
serializeBinary(): Uint8Array; | ||
toObject(includeInstance?: boolean): HealthCheckResponse.AsObject; | ||
static toObject(includeInstance: boolean, msg: HealthCheckResponse): HealthCheckResponse.AsObject; | ||
static serializeBinaryToWriter(message: HealthCheckResponse, writer: jspb.BinaryWriter): void; | ||
static deserializeBinary(bytes: Uint8Array): HealthCheckResponse; | ||
static deserializeBinaryFromReader(message: HealthCheckResponse, reader: jspb.BinaryReader): HealthCheckResponse; | ||
} | ||
|
||
export namespace HealthCheckResponse { | ||
export type AsObject = { | ||
status: HealthCheckResponse.ServingStatus, | ||
} | ||
|
||
export enum ServingStatus { | ||
UNKNOWN = 0, | ||
SERVING = 1, | ||
NOT_SERVING = 2, | ||
SERVICE_UNKNOWN = 3, | ||
} | ||
} | ||
|
2 changes: 2 additions & 0 deletions
2
example/hello-world-idl/gen/web/helloworld/helloworld_pb.d.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import * as jspb from "google-protobuf" | ||
|
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 |
---|---|---|
|
@@ -11,7 +11,7 @@ network: | |
grpc: | ||
host: 0.0.0.0 | ||
port: 3000 | ||
http: | ||
web: | ||
enabled: true | ||
port: 8080 | ||
graphql: | ||
|
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