gRPC Adapter
Requirements
Setup
How to Use
- Proto file example (my.proto):
syntax = "proto3";
service MainService {
rpc list (Empty) returns (TodoList);
rpc insert (NewItem) returns (TodoList);
rpc mark (TodoItemId) returns (TodoList);
};
message Empty {};
message TodoItemId {
int32 id = 1;
bool checked = 2;
};
message NewItem {
string task = 1;
};
message TodoItem {
int32 id = 1;
bool done = 2;
string task = 3;
};
message TodoList {
repeated TodoItem todoItem = 1;
};
const path = require('node:path');
import {Request} from '../grpc-adapter';
import {MyService} from '../services/myService';
const myService = MyService();
const protoPath = path.join(__dirname, '..', 'proto', 'my.proto');
export const mappers = [
Request(`${protoPath}`, {
insert: myService.insertTask,
list: myService.listTask,
mark: myService.markTask,
}),
];