8000 GitHub - codeflows/twirp-typescript-example: Twirp TypeScript client example
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

codeflows/twirp-typescript-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Twirp Typescript example

A simple example of calling a Twirp service in Typescript using a client generated with protobufjs.

Usage

Go server

brew install protobuf
go get -u github.com/golang/protobuf/protoc-gen-go
go get -u github.com/twitchtv/twirp/protoc-gen-twirp

cd server
# Regenerate Go code if necessary
protoc --proto_path=$GOPATH/src:. --twirp_out=. --go_out=. ./haberdasher/haberdasher.proto
# Run the server at :8080
go run *.go

Typescript client

cd client
yarn install
yarn generate   # *.proto -> *.js and *.ts
yarn start      # Run the typescript client

Limitations

  • Metadata about the service not available at the protobufjs RPC layer - have to pass it in manually (would require changes to protobufjs)
  • protobufjs supports binary format only, and not the canonical JSON format

About

Twirp TypeScript client example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0