0.4.0 • Published 6 months ago

@grpcexpress/grpcexpress v0.4.0

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

gRPC Express

Version badge

gRPCExpress is a gRPC-web caching library built with TypeScript. It enhances the native functionalities of the grpc-web library by providing advanced caching capabilities.

Features

  • Enhanced Caching: Extends the grpc-web's ServiceClient class to incorporate advanced caching functionalities.
  • Efficiency: A pub-sub pattern to sequence repetitive function calls, reducing network usage.
  • Cost-aware Caching: An efficient algorithm that maintains cache size constraints while ensuring relevant data remains cached.
  • Unit Testing: Tested using ViTest.

Prerequisites

Before you begin, ensure you have the grpc-web dependency installed in your project and the services stub generated with protoc.

protoc -I=protos stocks.proto --js_out=import_style=commonjs,binary:protos --grpc-web_out=import_style=commonjs+dts,mode=grpcweb:protos

Installation

Install the library using npm:

npm i @grpcexpress/grpcexpress

Basic Usage

import { grpcExpressClient } from "@grpcexpress/grpcexpress";
const Client = grpcExpressClient(ServiceClient);
const client = new Client(url);
const response = await client.myMethod(message);

Advanced Usage

Setting Default Cache Duration

Set default cache duration (in ms) for all method calls, the default duration is 10 minutes:

const Client = grpcExpressClient(ServiceClient, 10000);

Skipping Caching

To skip caching for a particular call:

const response = await client.myMethod(message, {
  cacheOptions: { cache: "nocache:" },
});

Custom Cache Expiration

Specify a custom cache expiration duration (in ms) for a particular response:

const response = await client.myMethod(message, {
  cacheOptions: { duration: 10000 },
});

License

This project is licensed under the MIT License.

Credits

Junwen Zhang Arthur Griffith Murat Agrali Shi Yu Liu

0.4.0

6 months ago

0.3.1

7 months ago

0.3.0

7 months ago

0.2.2

7 months ago

0.2.1

8 months ago

0.2.0

8 months ago

0.1.1

8 months ago

0.1.0

8 months ago