grpc-adapter
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

gRPC Adapter

Requirements

  • Typescript

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;
};

  • Mapper for handlers:
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,
    }),
];

Readme

Keywords

none

Package Sidebar

Install

npm i grpc-adapter

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

7.91 kB

Total Files

14

Last publish

Collaborators

  • gustavo_fdte