new Protocols( grpcMocksDir )

Description

Defines all protocols: Currently active:

  • HTTP
  • HTTPS
  • HTTP2
  • gRPC
  • Websocket
Parameters
Name Type Description
grpcMocksDir string

location of grpc mocks, not initialized as constructor variable, because grpc is an optional protocol instead it will be initialized in initGRPC method, if called.

Methods


initHttp() → {void}

Description

Initialize HTTP server at specified port

Returns

initHttps( key, cert ) → {void}

Description

Initialize HTTPs server at specified port

Parameters
Name Type Description
key string

location of server.key file

cert string

location of server.cert file

Returns

initGrpc( grpcProtosDir, grpcMocksDir, grpcHost, grpcPort )

Description

Initializes a gRPC server at specified host and port

  • Set location of gRPC mocks to be used by metod camouflageMock
  • Get an array of all .protofile in specified protos directory
  • Run forEach on the array and read and load package definition for each protofile in protos dir
  • For each definition, get the package details from all .proto files and store in a master packages object
  • Initialize a grpcServer
  • Create an insecure binding to given grpc host and port, and start the server
  • For each package, filter out objects with service definition, discard rest
  • For each method in the service definition, attach a generic handler, finally add service to running server
  • Handlers will vary based on the type of request, i.e. unary, bidi streams or one sided streams
  • Finally add all services to the server
Parameters
Name Type Description
grpcProtosDir string

location of proto files

grpcMocksDir string

location of mock files for grpc

grpcHost string

grpc host

grpcPort number

grpc port


initHttp2( http2Port, http2key, http2cert )

Description

Initializes an HTTP2 server

Parameters
Name Type Description
http2Port number
http2key string
http2cert string

initws( wsPort, wsMockDir )

Description

Initializes a WebSocketserver

Parameters
Name Type Description
wsPort number
wsMockDir string