Skip to content

Commit 7b146cc

Browse files
committed
refactor: simplify types for messages
1 parent 058187e commit 7b146cc

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

descriptor_set.bin

52 Bytes
Binary file not shown.

news.proto

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
syntax = "proto3";
22

3+
import "google/protobuf/empty.proto";
4+
35
message News {
4-
string id = 1;
6+
int32 id = 1;
57
string title = 2;
68
string body = 3;
79
string postImage = 4;
810
}
911

1012
service NewsService {
11-
rpc GetAllNews (Empty) returns (NewsList) {}
13+
rpc GetAllNews (google.protobuf.Empty) returns (NewsList) {}
1214
rpc GetNews (NewsId) returns (News) {}
1315
rpc GetMultipleNews (MultipleNewsId) returns (NewsList) {}
14-
rpc DeleteNews (NewsId) returns (Empty) {}
16+
rpc DeleteNews (NewsId) returns (google.protobuf.Empty) {}
1517
rpc EditNews (News) returns (News) {}
1618
rpc AddNews (News) returns (News) {}
1719
}
1820

1921
message NewsId {
20-
string id = 1;
22+
int32 id = 1;
2123
}
2224

2325
message MultipleNewsId {
2426
repeated NewsId ids = 1;
2527
}
2628

27-
message Empty {}
28-
2929
message NewsList {
3030
repeated News news = 1;
3131
}

server.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ const server = new grpc.Server();
1818
addReflection(server, "./descriptor_set.bin");
1919

2020
const NEWS = [
21-
{ id: "1", title: "Note 1", body: "Content 1", postImage: "Post image 1" },
22-
{ id: "2", title: "Note 2", body: "Content 2", postImage: "Post image 2" },
23-
{ id: "3", title: "Note 3", body: "Content 3", postImage: "Post image 3" },
24-
{ id: "4", title: "Note 4", body: "Content 4", postImage: "Post image 4" },
25-
{ id: "5", title: "Note 5", body: "Content 5", postImage: "Post image 5" },
21+
{ id: 1, title: "Note 1", body: "Content 1", postImage: "Post image 1" },
22+
{ id: 2, title: "Note 2", body: "Content 2", postImage: "Post image 2" },
23+
{ id: 3, title: "Note 3", body: "Content 3", postImage: "Post image 3" },
24+
{ id: 4, title: "Note 4", body: "Content 4", postImage: "Post image 4" },
25+
{ id: 5, title: "Note 5", body: "Content 5", postImage: "Post image 5" },
2626
];
2727

2828
server.addService(newsProto.NewsService.service, {

0 commit comments

Comments
 (0)