3.1.15 • Published 9 months ago

@alenon/grpc-mock-server v3.1.15

Weekly downloads
6
License
MIT
Repository
github
Last release
9 months ago

grpc-mock-server

gRPC mock server for tests with typescript definitions.

NPM CI

Installation:

NPM link

npm i @alenon/grpc-mock-server

Usage example:

private static readonly PROTO_PATH: string = __dirname + "example.proto";
private static readonly PKG_NAME: string = "com.alenon.example";
private static readonly SERVICE_NAME: string = "ExampleService";

...

const implementations = {
    ex1: (call: any, callback: any) => {
        const response: any =
            new this.proto.ExampleResponse.constructor({msg: "the response message"});
        callback(null, response);
    },
};

this.server.addService(PROTO_PATH, PKG_NAME, SERVICE_NAME, implementations);
this.server.start();

Migrating from 1.x to 3.x: 1. Change grpc dependecy from this import * as grpc from "grpc"; by this: import * as grpc from "@grpc/grpc-js";

  1. Handle start and stop functions which are now asynchronous and return Promises:
this.server = new GrpcMockServer();

// async / await
try {
    await this.server.start();
    console.log('do work...');
    await this.server.stop();
} catch (error) {
    console.log(error);
}

// standard promises
this.server.start()
    .then(() => console.log('do work...'))
    .then(() => this.server.stop())
    .catch((error) => console.log(error));
3.1.14

10 months ago

3.1.15

9 months ago

3.1.12

12 months ago

3.1.13

12 months ago

3.1.11

1 year ago

3.1.10

1 year ago

3.1.9

1 year ago

3.1.8

2 years ago

3.1.7

2 years ago

3.1.3

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

3.1.6

2 years ago

3.1.5

2 years ago

3.1.4

2 years ago

3.0.21

2 years ago

3.0.20

2 years ago

3.0.19

2 years ago

3.0.18

2 years ago

3.0.17

2 years ago

3.0.13

3 years ago

3.0.16

3 years ago

3.0.14

3 years ago

3.0.15

3 years ago

3.0.12

3 years ago

3.0.11

3 years ago

3.0.9

3 years ago

3.0.10

3 years ago

3.0.8

3 years ago

3.0.7

3 years ago

3.0.6

3 years ago

3.0.4

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.0.5

3 years ago

3.0.1

3 years ago

1.2.7

3 years ago

3.0.0

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

2.0.0

3 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.9

4 years ago

1.1.8

5 years ago