1: Node(GRPC) : Backend
10 | 2: NextJS : Frontend
12 | 3: Envoy : Proxy for GRPC
14 |
15 | ## 1: Run in Dev Mode
16 | 1: Install grpc-tools globally using bellow command or else grpc_tools_node_protoc will not work
17 | npm i -g grpc-tools
20 | 2: Install npm dependencies in these 3 directories
23 | npm i
26 | cd backend && npm i backend
27 | cd frontend && npm i frontend
28 | 3: Generate protos (optional)
31 | npm run gen-proto
34 | 4: Run both backend and frondend
37 | npm run dev
40 | 5: Run docker command for backend GRPC in DEV mode
43 |
46 | docker run -ti -p 8080:8080 -p 9901:9901 -v /$(pwd)/envoy.yaml:/etc/envoy/envoy.yaml --rm envoyproxy/envoy-dev:04dd76b051c99f82abda081e1d04cac38667ef88
47 |
48 | /$(pwd)
and for bash in linux or mac use $(pwd)
and for win use "%cd%"
.
--------------------------------------------------------------------------------
/backend/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | # Keep environment variables out of version control
3 | .env
4 |
--------------------------------------------------------------------------------
/backend/controllers/task.ts:
--------------------------------------------------------------------------------
1 | import {
2 | AddTaskRequest,
3 | AddTaskResponse,
4 | DeleteTaskRequest,
5 | DeleteTaskResponse,
6 | EmptyRequest,
7 | EmptyResponse,
8 | Task,
9 | TaskRequest,
10 | TaskResponse,
11 | TasksRequest,
12 | TasksResponse,
13 | UpdateTaskRequest,
14 | UpdateTaskResponse,
15 | } from "../protos/task_pb";
16 | import {
17 | sendUnaryData,
18 | ServerUnaryCall,
19 | ServerWritableStream,
20 | } from "@grpc/grpc-js";
21 | import { prisma } from "../server";
22 | import { Status } from "@grpc/grpc-js/build/src/constants";
23 |
24 | let connectedClientsForTasks: any[] = [];
25 |
26 | function setTask(task: any) {
27 | const realtask = new Task();
28 | realtask.setId(task.id);
29 | realtask.setTitle(task.title);
30 | realtask.setBody(task.body);
31 | realtask.setStatus(task.status);
32 | return realtask;
33 | }
34 |
35 | async function addTask(
36 | call: ServerUnaryCall54 | All Tasks 55 |
56 |106 | {index + 1} 107 |
108 |{item.getTitle()}
111 |{item.getBody()}
114 |121 | No tasks available 122 |
123 |