grpc-web/net/grpc/gateway/examples/echo/ts-example
Eryu Xia f8fbbe32f9
Update Debian (and other deps) and remove Java In-process Proxy (#1335)
2023-05-14 02:57:11 -07:00
..
.gitignore Experimental Typescript support 2018-08-24 15:34:01 -07:00
README.md Improve Typescript example docs. (#1318) 2023-02-07 16:37:23 -08:00
client.ts Internal code sync (#1139) 2021-09-22 16:53:00 -07:00
echotest.html Disable caching of local generated main.js file (#1193) 2022-01-28 21:47:21 -08:00
package.json Update Debian (and other deps) and remove Java In-process Proxy (#1335) 2023-05-14 02:57:11 -07:00
tsconfig.json update generated typescript files to work in strict mode 2018-11-05 13:54:13 -08:00
webpack.config.js Experimental Typescript support 2018-08-24 15:34:01 -07:00

README.md

Instructions to run the Typescript example

Docker run

# From root dir
docker-compose up --build node-server envoy ts-client

Visit http://localhost:8081/echotest.html

Manual run

Step 1 - Run servers

# From root dir
docker-compose up --build node-server envoy

Step 2 - Codegen

cd net/grpc/gateway/examples/echo

Option 1: import_style=commonjs+dts

RUN protoc -I=. echo.proto \
  --js_out=import_style=commonjs:./ts-example \
  --grpc-web_out=import_style=commonjs+dts,mode=grpcwebtext:./ts-example

Option 2: import_style=typescript

RUN protoc -I=. echo.proto \
  --js_out=import_style=commonjs:./ts-example \
  --grpc-web_out=import_style=typescript,mode=grpcwebtext:./ts-example

Step 3 - (Optional) Update import style

Change client.ts to use import style Option 2 if you had chosen import_style=typescript above:

60caece154/net/grpc/gateway/examples/echo/ts-example/client.ts (L26-L27)

Step 4 - Build JS files.

cd net/grpc/gateway/examples/echo/ts-example
npm install
npx tsc
mv *_pb.js dist/
npx webpack

Step 5 - Host and visit page

# In the ./ts-example folder
python3 -m http.server 8081

Visit http://localhost:8081/echotest.html