|
1 | | -# Sample gRPC Node.js News Server |
2 | | - |
3 | | -## Overview |
4 | | - |
5 | | -This repository contains a gRPC-based Node.js server implementing CRUD operations for a news list. It features a batched `GetNews` API, allowing efficient retrieval of multiple news items. |
6 | | - |
7 | | -### Features |
8 | | - |
9 | | -- **CRUD Operations**: Create, Read, Update, and Delete news items. |
10 | | -- **Batched News Retrieval**: Fetch multiple news items in a single request. |
11 | | -- **gRPC Interface**: Efficient and modern protocol for inter-service communication. |
12 | | - |
13 | | -## Prerequisites |
14 | | - |
15 | | -Before you begin, ensure you have installed: |
16 | | -- [Node.js](https://nodejs.org/en/download/) |
17 | | -- [npm](https://www.npmjs.com/get-npm) |
18 | | - |
19 | | -## Installation |
20 | | - |
21 | | -To set up the project, run the following command: |
22 | | - |
23 | | -```bash |
24 | | -npm install |
25 | | -``` |
26 | | - |
27 | | -## Running the Server |
28 | | - |
29 | | -Start the server with: |
30 | | - |
31 | | -```bash |
32 | | -node server |
33 | | -``` |
34 | | - |
35 | | -## gRPC API |
36 | | - |
37 | | -The server uses the following gRPC API defined in `news.proto`: |
38 | | - |
39 | | -```protobuf |
40 | | -syntax = "proto3"; |
41 | | -import "google/protobuf/empty.proto"; |
42 | | -package news; |
43 | | -message News { |
44 | | - int32 id = 1; |
45 | | - string title = 2; |
46 | | - string body = 3; |
47 | | - string postImage = 4; |
48 | | -} |
49 | | -
|
50 | | -service NewsService { |
51 | | - rpc GetAllNews (google.protobuf.Empty) returns (NewsList) {} |
52 | | - rpc GetNews (NewsId) returns (News) {} |
53 | | - rpc GetMultipleNews (MultipleNewsId) returns (NewsList) {} |
54 | | - rpc DeleteNews (NewsId) returns (google.protobuf.Empty) {} |
55 | | - rpc EditNews (News) returns (News) {} |
56 | | - rpc AddNews (News) returns (News) {} |
57 | | -} |
58 | | -
|
59 | | -message NewsId { |
60 | | - int32 id = 1; |
61 | | -} |
62 | | -
|
63 | | -message MultipleNewsId { |
64 | | - repeated NewsId ids = 1; |
65 | | -} |
66 | | -
|
67 | | -message NewsList { |
68 | | - repeated News news = 1; |
69 | | -} |
70 | | -``` |
71 | | - |
72 | | -## License |
73 | | - |
74 | | -This project is licensed under the MIT License. |
75 | | - |
76 | | -* * * |
77 | | - |
78 | | -© 2023 @ Tailcall |
| 1 | +# Depricated |
| 2 | +The server is now written in rust at https://github.com/tailcallhq/rust-grpc with awesome new features like server reflection! |
0 commit comments