Skip to content

Commit c4596b5

Browse files
committed
[test-client]
1 parent 2114e10 commit c4596b5

File tree

7 files changed

+2750
-0
lines changed

7 files changed

+2750
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
### This is a quickly test example for typescript browser client
2+
3+
### How to test
4+
5+
1. modify `client.ts` file host endpoint
6+
2. copy `../lib/*` to current folder
7+
3. run `npx webpack`
8+
4. run `curl lama.sh | sh`
9+
5. open browser, find `test.html` open `Dev tool` -> `Console` see logs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { RpcError } from "grpc-web";
2+
import { MetricsServicePromiseClient } from "./idemetrics_grpc_web_pb";
3+
import { AddCounterRequest, AddCounterResponse } from "./idemetrics_pb";
4+
5+
var client = new MetricsServicePromiseClient("https://3000-gitpodio-gitpod-k67e9t2f0o8.ws-us54.gitpod.io/metrics-api");
6+
7+
var request = new AddCounterRequest();
8+
request.setName("gitpod_test_counter");
9+
request.setValue(1);
10+
request.getLabelsMap().set("ide", "vscode");
11+
12+
client.addCounter(request).then(console.log).catch(console.error);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "grpc-web-commonjs-example",
3+
"version": "0.1.0",
4+
"description": "gRPC-Web CommonJS client example",
5+
"license": "Apache-2.0",
6+
"dependencies": {
7+
"google-protobuf": "~3.14.0",
8+
"grpc-web": "~1.3.1"
9+
},
10+
"devDependencies": {
11+
"webpack": "~4.43.0",
12+
"webpack-cli": "~3.3.11"
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<script>
6+
const script = document.createElement('script');
7+
script.src = `./dist/main.js?v=${Date.now()}`;
8+
document.head.appendChild(script);
9+
</script>
10+
</head>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
mode: "production",
3+
entry: "./client.ts",
4+
};

0 commit comments

Comments
 (0)