Skip to content

Commit bf39230

Browse files
author
Milan Pavlik
committed
Fix grpc-web go version, fix binding to chi
1 parent 3851ef4 commit bf39230

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+8260
-665
lines changed

.editorconfig

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
root = true
2+
3+
[*.sh]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
12+
[*.{js,ts,tsx}]
13+
indent_style = space
14+
indent_size = 2
15+
charset = utf-8
16+
trim_trailing_whitespace = true
17+
insert_final_newline = true
18+
end_of_line = lf
19+
20+
# Override for Makefile
21+
[{Makefile, makefile, GNUmakefile}]
22+
indent_style = tab
23+
indent_size = 4

app/package.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6+
"google-protobuf": "^3.5.0",
7+
"grpc-web-client": "^0.3.1",
68
"react": "^16.2.0",
79
"react-dom": "^16.2.0",
810
"react-scripts-ts": "2.10.0"
@@ -14,9 +16,11 @@
1416
"eject": "react-scripts-ts eject"
1517
},
1618
"devDependencies": {
19+
"@types/google-protobuf": "^3.2.7",
1720
"@types/jest": "^22.0.1",
1821
"@types/node": "^9.3.0",
1922
"@types/react": "^16.0.34",
20-
"@types/react-dom": "^16.0.3"
23+
"@types/react-dom": "^16.0.3",
24+
"ts-protoc-gen": "^0.4.0"
2125
}
2226
}

app/src/App.tsx

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
11
import * as React from 'react';
22
import './App.css';
3+
import { grpc } from 'grpc-web-client';
4+
import { HackerNewsService } from './proto/hackernews_pb_service';
5+
import { ListStoriesRequest } from './proto/hackernews_pb';
36

47
const logo = require('./logo.svg');
58

69
class App extends React.Component {
10+
11+
componentDidMount() {
12+
const request = new ListStoriesRequest();
13+
grpc.unary(HackerNewsService.ListStories, {
14+
request: request,
15+
debug: true,
16+
host: 'http://localhost:8900',
17+
onEnd: (res) => {
18+
console.log(res);
19+
}
20+
});
21+
}
22+
723
render() {
824
return (
925
<div className="App">
1026
<div className="App-header">
11-
<img src={logo} className="App-logo" alt="logo" />
27+
<img src={logo} className="App-logo" alt="logo"/>
1228
<h2>Welcome to React</h2>
1329
</div>
1430
<p className="App-intro">

app/src/proto/hackernews_pb.d.ts

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// package: grpc_web_hacker_news
2+
// file: proto/hackernews.proto
3+
4+
import * as jspb from "google-protobuf";
5+
6+
export class Item extends jspb.Message {
7+
getId(): number;
8+
setId(value: number): void;
9+
10+
serializeBinary(): Uint8Array;
11+
toObject(includeInstance?: boolean): Item.AsObject;
12+
static toObject(includeInstance: boolean, msg: Item): Item.AsObject;
13+
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
14+
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
15+
static serializeBinaryToWriter(message: Item, writer: jspb.BinaryWriter): void;
16+
static deserializeBinary(bytes: Uint8Array): Item;
17+
static deserializeBinaryFromReader(message: Item, reader: jspb.BinaryReader): Item;
18+
}
19+
20+
export namespace Item {
21+
export type AsObject = {
22+
id: number,
23+
}
24+
}
25+
26+
export class ListStoriesResponse extends jspb.Message {
27+
clearStoriesList(): void;
28+
getStoriesList(): Array<Item>;
29+
setStoriesList(value: Array<Item>): void;
30+
addStories(value?: Item, index?: number): Item;
31+
32+
serializeBinary(): Uint8Array;
33+
toObject(includeInstance?: boolean): ListStoriesResponse.AsObject;
34+
static toObject(includeInstance: boolean, msg: ListStoriesResponse): ListStoriesResponse.AsObject;
35+
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
36+
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
37+
static serializeBinaryToWriter(message: ListStoriesResponse, writer: jspb.BinaryWriter): void;
38+
static deserializeBinary(bytes: Uint8Array): ListStoriesResponse;
39+
static deserializeBinaryFromReader(message: ListStoriesResponse, reader: jspb.BinaryReader): ListStoriesResponse;
40+
}
41+
42+
export namespace ListStoriesResponse {
43+
export type AsObject = {
44+
storiesList: Array<Item.AsObject>,
45+
}
46+
}
47+
48+
export class ListStoriesRequest extends jspb.Message {
49+
serializeBinary(): Uint8Array;
50+
toObject(includeInstance?: boolean): ListStoriesRequest.AsObject;
51+
static toObject(includeInstance: boolean, msg: ListStoriesRequest): ListStoriesRequest.AsObject;
52+
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
53+
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
54+
static serializeBinaryToWriter(message: ListStoriesRequest, writer: jspb.BinaryWriter): void;
55+
static deserializeBinary(bytes: Uint8Array): ListStoriesRequest;
56+
static deserializeBinaryFromReader(message: ListStoriesRequest, reader: jspb.BinaryReader): ListStoriesRequest;
57+
}
58+
59+
export namespace ListStoriesRequest {
60+
export type AsObject = {
61+
}
62+
}
63+

0 commit comments

Comments
 (0)