3.1.11 • Published 12 days ago

@alenon/grpc-mock-server v3.1.11

Weekly downloads
6
License
MIT
Repository
github
Last release
12 days 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.11

12 days ago

3.1.10

1 month ago

3.1.9

3 months ago

3.1.8

5 months ago

3.1.7

6 months ago

3.1.3

8 months ago

3.1.1

8 months ago

3.1.0

8 months ago

3.1.6

7 months ago

3.1.5

7 months ago

3.1.4

7 months ago

3.0.21

11 months ago

3.0.20

12 months ago

3.0.19

1 year ago

3.0.18

1 year ago

3.0.17

1 year ago

3.0.13

2 years ago

3.0.16

1 year ago

3.0.14

1 year ago

3.0.15

1 year ago

3.0.12

2 years ago

3.0.11

2 years ago

3.0.9

2 years ago

3.0.10

2 years ago

3.0.8

2 years ago

3.0.7

2 years ago

3.0.6

2 years ago

3.0.4

2 years ago

3.0.3

2 years ago

3.0.2

2 years ago

3.0.5

2 years ago

3.0.1

2 years ago

1.2.7

2 years ago

3.0.0

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

2.0.0

2 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.9

3 years ago

1.1.8

4 years ago