pip-services3-rpc-node

  • Version 3.9.2
  • Published
  • 439 kB
  • 6 dependencies
  • MIT license

Install

npm i pip-services3-rpc-node
yarn add pip-services3-rpc-node
pnpm add pip-services3-rpc-node

Overview

Remote procedure calls for Pip.Services in Node.js

Index

Classes

Interfaces

Classes

class AboutOperations

class AboutOperations extends RestOperations {}

    method about

    about: (req: any, res: any) => void;

      method getAboutOperation

      getAboutOperation: () => (req: any, res: any) => void;

        method setReferences

        setReferences: (references: IReferences) => void;

          class BasicAuthManager

          class BasicAuthorizer {}

            method anybody

            anybody: () => (req: any, res: any, next: () => void) => void;

              method signed

              signed: () => (req: any, res: any, next: () => void) => void;

                class CommandableHttpClient

                class CommandableHttpClient extends RestClient {}
                • Abstract client that calls commandable HTTP service.

                  Commandable services are generated automatically for [[https://pip-services3-node.github.io/pip-services3-commons-node/interfaces/commands.icommandable.html ICommandable objects]]. Each command is exposed as POST operation that receives all parameters in body object.

                  ### Configuration parameters ###

                  base_route: base route for remote URI

                  - connection(s): - discovery_key: (optional) a key to retrieve the connection from [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/connect.idiscovery.html IDiscovery]] - protocol: connection protocol: http or https - host: host name or IP address - port: port number - uri: resource URI or connection string with all parameters in it - options: - retries: number of retries (default: 3) - connect_timeout: connection timeout in milliseconds (default: 10 sec) - timeout: invocation timeout in milliseconds (default: 10 sec)

                  ### References ###

                  - *:logger:*:*:1.0 (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/log.ilogger.html ILogger]] components to pass log messages - *:counters:*:*:1.0 (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/count.icounters.html ICounters]] components to pass collected measurements - *:discovery:*:*:1.0 (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/connect.idiscovery.html IDiscovery]] services to resolve connection

                  ### Example ###

                  class MyCommandableHttpClient extends CommandableHttpClient implements IMyClient { ...

                  public getData(correlationId: string, id: string, callback: (err: any, result: MyData) => void): void {

                  this.callCommand( "get_data", correlationId, { id: id }, (err, result) => { callback(err, result); } ); } ... }

                  let client = new MyCommandableHttpClient(); client.configure(ConfigParams.fromTuples( "connection.protocol", "http", "connection.host", "localhost", "connection.port", 8080 ));

                  client.getData("123", "1", (err, result) => { ... });

                constructor

                constructor(baseRoute: string);
                • Creates a new instance of the client.

                  Parameter baseRoute

                  a base route for remote service.

                method callCommand

                protected callCommand: (
                name: string,
                correlationId: string,
                params: any,
                callback: (err: any, result: any) => void
                ) => void;
                • Calls a remote method via HTTP commadable protocol. The call is made via POST operation and all parameters are sent in body object. The complete route to remote method is defined as baseRoute + "/" + name.

                  Parameter name

                  a name of the command to call.

                  Parameter correlationId

                  (optional) transaction id to trace execution through the call chain.

                  Parameter params

                  command parameters.

                  Parameter callback

                  callback function that receives result or error.

                class CommandableHttpService

                abstract class CommandableHttpService extends RestService {}
                • Abstract service that receives remove calls via HTTP protocol to operations automatically generated for commands defined in [[https://pip-services3-node.github.io/pip-services3-commons-node/interfaces/commands.icommandable.html ICommandable components]]. Each command is exposed as POST operation that receives all parameters in body object.

                  Commandable services require only 3 lines of code to implement a robust external HTTP-based remote interface.

                  ### Configuration parameters ###

                  - base_route: base route for remote URI - dependencies: - endpoint: override for HTTP Endpoint dependency - controller: override for Controller dependency - connection(s): - discovery_key: (optional) a key to retrieve the connection from [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/connect.idiscovery.html IDiscovery]] - protocol: connection protocol: http or https - host: host name or IP address - port: port number - uri: resource URI or connection string with all parameters in it

                  ### References ###

                  - *:logger:*:*:1.0 (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/log.ilogger.html ILogger]] components to pass log messages - *:counters:*:*:1.0 (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/count.icounters.html ICounters]] components to pass collected measurements - *:discovery:*:*:1.0 (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/connect.idiscovery.html IDiscovery]] services to resolve connection - *:endpoint:http:*:1.0 (optional) [[HttpEndpoint]] reference

                  See Also

                  • [[CommandableHttpClient]]

                  • [[RestService]]

                    ### Example ###

                    class MyCommandableHttpService extends CommandableHttpService { public constructor() { base(); this._dependencyResolver.put( "controller", new Descriptor("mygroup","controller","*","*","1.0") ); } }

                    let service = new MyCommandableHttpService(); service.configure(ConfigParams.fromTuples( "connection.protocol", "http", "connection.host", "localhost", "connection.port", 8080 )); service.setReferences(References.fromTuples( new Descriptor("mygroup","controller","default","default","1.0"), controller ));

                    service.open("123", (err) => { console.log("The REST service is running on port 8080"); });

                constructor

                constructor(baseRoute: string);
                • Creates a new instance of the service.

                  Parameter baseRoute

                  a service base route.

                method configure

                configure: (config: ConfigParams) => void;
                • Configures component by passing configuration parameters.

                  Parameter config

                  configuration parameters to be set.

                method register

                register: () => void;
                • Registers all service routes in HTTP endpoint.

                class CommandableSwaggerDocument

                class CommandableSwaggerDocument {}

                  constructor

                  constructor(baseRoute: string, config: ConfigParams, commands: ICommand[]);

                    property baseRoute

                    baseRoute: string;

                      property commands

                      commands: ICommand[];

                        property infoContactEmail

                        infoContactEmail: string;

                          property infoContactName

                          infoContactName: string;

                            property infoContactUrl

                            infoContactUrl: string;

                              property infoDescription

                              infoDescription: string;

                                property infoLicenseName

                                infoLicenseName: string;

                                  property infoLicenseUrl

                                  infoLicenseUrl: string;

                                    property infoTermsOfService

                                    infoTermsOfService: string;

                                      property infoTitle

                                      infoTitle: string;

                                        property infoVersion

                                        infoVersion: string;

                                          property objectType

                                          protected readonly objectType: Map<string, any>;

                                            property version

                                            version: string;

                                              method getSpaces

                                              protected getSpaces: (length: number) => string;

                                                method toString

                                                toString: () => string;

                                                  method writeArrayItem

                                                  protected writeArrayItem: (
                                                  indent: number,
                                                  name: string,
                                                  isObjectItem?: boolean
                                                  ) => void;

                                                    method writeAsObject

                                                    protected writeAsObject: (indent: number, name: string, value: any) => void;

                                                      method writeAsString

                                                      protected writeAsString: (indent: number, name: string, value: string) => void;

                                                        method writeData

                                                        protected writeData: (indent: number, data: Map<string, any>) => void;

                                                          method writeName

                                                          protected writeName: (indent: number, name: string) => void;

                                                            class DefaultRpcFactory

                                                            class DefaultRpcFactory extends Factory {}
                                                            • Creates RPC components by their descriptors.

                                                              See Also

                                                              • [[https://pip-services3-node.github.io/pip-services3-components-node/classes/build.factory.html Factory]]

                                                              • [[HttpEndpoint]]

                                                              • [[HeartbeatRestService]]

                                                              • [[StatusRestService]]

                                                            constructor

                                                            constructor();
                                                            • Create a new instance of the factory.

                                                            property Descriptor

                                                            static readonly Descriptor: Descriptor;

                                                              property HeartbeatServiceDescriptor

                                                              static readonly HeartbeatServiceDescriptor: Descriptor;

                                                                property HttpEndpointDescriptor

                                                                static readonly HttpEndpointDescriptor: Descriptor;

                                                                  property StatusServiceDescriptor

                                                                  static readonly StatusServiceDescriptor: Descriptor;

                                                                    class DirectClient

                                                                    abstract class DirectClient<T> implements IConfigurable, IReferenceable, IOpenable {}
                                                                    • Abstract client that calls controller directly in the same memory space.

                                                                      It is used when multiple microservices are deployed in a single container (monolyth) and communication between them can be done by direct calls rather then through the network.

                                                                      ### Configuration parameters ###

                                                                      - dependencies: - controller: override controller descriptor

                                                                      ### References ###

                                                                      - *:logger:*:*:1.0 (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/log.ilogger.html ILogger]] components to pass log messages - *:counters:*:*:1.0 (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/count.icounters.html ICounters]] components to pass collected measurements - *:controller:*:*:1.0 controller to call business methods

                                                                      ### Example ###

                                                                      class MyDirectClient extends DirectClient implements IMyClient {

                                                                      public constructor() { super(); this._dependencyResolver.put('controller', new Descriptor( "mygroup", "controller", "*", "*", "*")); } ...

                                                                      public getData(correlationId: string, id: string, callback: (err: any, result: MyData) => void): void {

                                                                      let timing = this.instrument(correlationId, 'myclient.get_data'); this._controller.getData(correlationId, id, (err, result) => { timing.endTiming(); this.instrumentError(correlationId, 'myclient.get_data', err, result, callback); }); } ... }

                                                                      let client = new MyDirectClient(); client.setReferences(References.fromTuples( new Descriptor("mygroup","controller","default","default","1.0"), controller ));

                                                                      client.getData("123", "1", (err, result) => { ... });

                                                                    constructor

                                                                    constructor();
                                                                    • Creates a new instance of the client.

                                                                    method close

                                                                    close: (correlationId: string, callback?: (err: any) => void) => void;
                                                                    • Closes component and frees used resources.

                                                                      Parameter correlationId

                                                                      (optional) transaction id to trace execution through call chain.

                                                                      Parameter callback

                                                                      callback function that receives error or null no errors occured.

                                                                    method configure

                                                                    configure: (config: ConfigParams) => void;
                                                                    • Configures component by passing configuration parameters.

                                                                      Parameter config

                                                                      configuration parameters to be set.

                                                                    method instrument

                                                                    protected instrument: (correlationId: string, name: string) => CounterTiming;
                                                                    • Adds instrumentation to log calls and measure call time. It returns a CounterTiming object that is used to end the time measurement.

                                                                      Parameter correlationId

                                                                      (optional) transaction id to trace execution through call chain.

                                                                      Parameter name

                                                                      a method name.

                                                                      Returns

                                                                      CounterTiming object to end the time measurement.

                                                                    method instrumentError

                                                                    protected instrumentError: (
                                                                    correlationId: string,
                                                                    name: string,
                                                                    err: any,
                                                                    result?: any,
                                                                    callback?: (err: any, result: any) => void
                                                                    ) => void;
                                                                    • Adds instrumentation to error handling.

                                                                      Parameter correlationId

                                                                      (optional) transaction id to trace execution through call chain.

                                                                      Parameter name

                                                                      a method name.

                                                                      Parameter err

                                                                      an occured error

                                                                      Parameter result

                                                                      (optional) an execution result

                                                                      Parameter callback

                                                                      (optional) an execution callback

                                                                    method isOpen

                                                                    isOpen: () => boolean;
                                                                    • Checks if the component is opened.

                                                                      Returns

                                                                      true if the component has been opened and false otherwise.

                                                                    method open

                                                                    open: (correlationId: string, callback?: (err: any) => void) => void;
                                                                    • Opens the component.

                                                                      Parameter correlationId

                                                                      (optional) transaction id to trace execution through call chain.

                                                                      Parameter callback

                                                                      callback function that receives error or null no errors occured.

                                                                    method setReferences

                                                                    setReferences: (references: IReferences) => void;
                                                                    • Sets references to dependent components.

                                                                      Parameter references

                                                                      references to locate the component dependencies.

                                                                    class HeartbeatOperations

                                                                    class HeartbeatOperations extends RestOperations {}

                                                                      constructor

                                                                      constructor();

                                                                        method getHeartbeatOperation

                                                                        getHeartbeatOperation: () => (req: any, res: any) => void;

                                                                          method heartbeat

                                                                          heartbeat: (req: any, res: any) => void;

                                                                            class HeartbeatRestService

                                                                            class HeartbeatRestService extends RestService {}
                                                                            • Service returns heartbeat via HTTP/REST protocol.

                                                                              The service responds on /heartbeat route (can be changed) with a string with the current time in UTC.

                                                                              This service route can be used to health checks by loadbalancers and container orchestrators.

                                                                              ### Configuration parameters ###

                                                                              - base_route: base route for remote URI (default: "") - route: route to heartbeat operation (default: "heartbeat") - dependencies: - endpoint: override for HTTP Endpoint dependency - connection(s): - discovery_key: (optional) a key to retrieve the connection from [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/connect.idiscovery.html IDiscovery]] - protocol: connection protocol: http or https - host: host name or IP address - port: port number - uri: resource URI or connection string with all parameters in it

                                                                              ### References ###

                                                                              - *:logger:*:*:1.0 (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/log.ilogger.html ILogger]] components to pass log messages - *:counters:*:*:1.0 (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/count.icounters.html ICounters]] components to pass collected measurements - *:discovery:*:*:1.0 (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/connect.idiscovery.html IDiscovery]] services to resolve connection - *:endpoint:http:*:1.0 (optional) [[HttpEndpoint]] reference

                                                                              See Also

                                                                              • [[RestService]]

                                                                              • [[RestClient]]

                                                                                ### Example ###

                                                                                let service = new HeartbeatService(); service.configure(ConfigParams.fromTuples( "route", "ping", "connection.protocol", "http", "connection.host", "localhost", "connection.port", 8080 ));

                                                                                service.open("123", (err) => { console.log("The Heartbeat service is accessible at http://+:8080/ping"); });

                                                                            constructor

                                                                            constructor();
                                                                            • Creates a new instance of this service.

                                                                            method configure

                                                                            configure: (config: ConfigParams) => void;
                                                                            • Configures component by passing configuration parameters.

                                                                              Parameter config

                                                                              configuration parameters to be set.

                                                                            method register

                                                                            register: () => void;
                                                                            • Registers all service routes in HTTP endpoint.

                                                                            class HttpConnectionResolver

                                                                            class HttpConnectionResolver implements IReferenceable, IConfigurable {}
                                                                            • Helper class to retrieve connections for HTTP-based services abd clients.

                                                                              In addition to regular functions of ConnectionResolver is able to parse http:// URIs and validate connection parameters before returning them.

                                                                              ### Configuration parameters ###

                                                                              - connection: - discovery_key: (optional) a key to retrieve the connection from [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/connect.idiscovery.html IDiscovery]] - ... other connection parameters

                                                                              - connections: alternative to connection - [connection params 1]: first connection parameters - ... - [connection params N]: Nth connection parameters - ...

                                                                              ### References ###

                                                                              - *:discovery:*:*:1.0 (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/connect.idiscovery.html IDiscovery]] services

                                                                              See Also

                                                                              • [[https://pip-services3-node.github.io/pip-services3-components-node/classes/connect.connectionparams.html ConnectionParams]]

                                                                              • [[https://pip-services3-node.github.io/pip-services3-components-node/classes/connect.connectionresolver.html ConnectionResolver]]

                                                                                ### Example ###

                                                                                let config = ConfigParams.fromTuples( "connection.host", "10.1.1.100", "connection.port", 8080 );

                                                                                let connectionResolver = new HttpConnectionResolver(); connectionResolver.configure(config); connectionResolver.setReferences(references);

                                                                                connectionResolver.resolve("123", (err, connection) => { // Now use connection... });

                                                                            method configure

                                                                            configure: (config: ConfigParams) => void;
                                                                            • Configures component by passing configuration parameters.

                                                                              Parameter config

                                                                              configuration parameters to be set.

                                                                            method register

                                                                            register: (correlationId: string, callback: (err: any) => void) => void;
                                                                            • Registers the given connection in all referenced discovery services. This method can be used for dynamic service discovery.

                                                                              Parameter correlationId

                                                                              (optional) transaction id to trace execution through call chain.

                                                                              Parameter connection

                                                                              a connection to register.

                                                                              Parameter callback

                                                                              callback function that receives registered connection or error.

                                                                            method resolve

                                                                            resolve: (
                                                                            correlationId: string,
                                                                            callback: (
                                                                            err: any,
                                                                            connection: ConnectionParams,
                                                                            credential: CredentialParams
                                                                            ) => void
                                                                            ) => void;
                                                                            • Resolves a single component connection. If connections are configured to be retrieved from Discovery service it finds a IDiscovery and resolves the connection there.

                                                                              Parameter correlationId

                                                                              (optional) transaction id to trace execution through call chain.

                                                                              Parameter callback

                                                                              callback function that receives resolved connection or error.

                                                                            method resolveAll

                                                                            resolveAll: (
                                                                            correlationId: string,
                                                                            callback: (
                                                                            err: any,
                                                                            connections: ConnectionParams[],
                                                                            credential: CredentialParams
                                                                            ) => void
                                                                            ) => void;
                                                                            • Resolves all component connection. If connections are configured to be retrieved from Discovery service it finds a IDiscovery and resolves the connection there.

                                                                              Parameter correlationId

                                                                              (optional) transaction id to trace execution through call chain.

                                                                              Parameter callback

                                                                              callback function that receives resolved connections or error.

                                                                            method setReferences

                                                                            setReferences: (references: IReferences) => void;
                                                                            • Sets references to dependent components.

                                                                              Parameter references

                                                                              references to locate the component dependencies.

                                                                            class HttpEndpoint

                                                                            class HttpEndpoint implements IOpenable, IConfigurable, IReferenceable {}
                                                                            • Used for creating HTTP endpoints. An endpoint is a URL, at which a given service can be accessed by a client.

                                                                              ### Configuration parameters ###

                                                                              Parameters to pass to the [[configure]] method for component configuration:

                                                                              - cors_headers - a comma-separated list of allowed CORS headers - cors_origins - a comma-separated list of allowed CORS origins - connection(s) - the connection resolver's connections: - "connection.discovery_key" - the key to use for connection resolving in a discovery service; - "connection.protocol" - the connection's protocol; - "connection.host" - the target host; - "connection.port" - the target port; - "connection.uri" - the target URI. - credential - the HTTPS credentials: - "credential.ssl_key_file" - the SSL private key in PEM - "credential.ssl_crt_file" - the SSL certificate in PEM - "credential.ssl_ca_file" - the certificate authorities (root cerfiticates) in PEM

                                                                              ### References ###

                                                                              A logger, counters, and a connection resolver can be referenced by passing the following references to the object's [[setReferences]] method:

                                                                              - logger: "*:logger:*:*:1.0"; - counters: "*:counters:*:*:1.0"; - discovery: "*:discovery:*:*:1.0" (for the connection resolver).

                                                                              ### Examples ###

                                                                              public MyMethod(_config: ConfigParams, _references: IReferences) { let endpoint = new HttpEndpoint(); if (this._config) endpoint.configure(this._config); if (this._references) endpoint.setReferences(this._references); ...

                                                                              this._endpoint.open(correlationId, (err) => { this._opened = err == null; callback(err); }); ... }

                                                                            method close

                                                                            close: (correlationId: string, callback?: (err: any) => void) => void;
                                                                            • Closes this endpoint and the REST server (service) that was opened earlier.

                                                                              Parameter correlationId

                                                                              (optional) transaction id to trace execution through call chain.

                                                                              Parameter callback

                                                                              (optional) the function to call once the closing process is complete. Will be called with an error if one is raised.

                                                                            method configure

                                                                            configure: (config: ConfigParams) => void;
                                                                            • Configures this HttpEndpoint using the given configuration parameters.

                                                                              __Configuration parameters:__ - cors_headers - a comma-separated list of allowed CORS headers - cors_origins - a comma-separated list of allowed CORS origins - __connection(s)__ - the connection resolver's connections; - "connection.discovery_key" - the key to use for connection resolving in a discovery service; - "connection.protocol" - the connection's protocol; - "connection.host" - the target host; - "connection.port" - the target port; - "connection.uri" - the target URI. - "credential.ssl_key_file" - SSL private key in PEM - "credential.ssl_crt_file" - SSL certificate in PEM - "credential.ssl_ca_file" - Certificate authority (root certificate) in PEM

                                                                              Parameter config

                                                                              configuration parameters, containing a "connection(s)" section.

                                                                              See Also

                                                                              • [[https://pip-services3-node.github.io/pip-services3-commons-node/classes/config.configparams.html ConfigParams]] (in the PipServices "Commons" package)

                                                                            method getCorrelationId

                                                                            getCorrelationId: (req: any) => string;
                                                                            • Returns correlationId from request

                                                                              Parameter req

                                                                              http request Returns correlationId from request

                                                                            method getServer

                                                                            getServer: () => any;
                                                                            • Gets an HTTP server instance.

                                                                              Returns

                                                                              an HTTP server instance of null if endpoint is closed.

                                                                            method isOpen

                                                                            isOpen: () => boolean;
                                                                            • Returns

                                                                              whether or not this endpoint is open with an actively listening REST server.

                                                                            method open

                                                                            open: (correlationId: string, callback?: (err: any) => void) => void;
                                                                            • Opens a connection using the parameters resolved by the referenced connection resolver and creates a REST server (service) using the set options and parameters.

                                                                              Parameter correlationId

                                                                              (optional) transaction id to trace execution through call chain.

                                                                              Parameter callback

                                                                              (optional) the function to call once the opening process is complete. Will be called with an error if one is raised.

                                                                            method register

                                                                            register: (registration: IRegisterable) => void;
                                                                            • Registers a registerable object for dynamic endpoint discovery.

                                                                              Parameter registration

                                                                              the registration to add.

                                                                              See Also

                                                                              • [[IRegisterable]]

                                                                            method registerInterceptor

                                                                            registerInterceptor: (
                                                                            route: string,
                                                                            action: (req: any, res: any, next: () => void) => void
                                                                            ) => void;
                                                                            • Registers a middleware action for the given route.

                                                                              Parameter route

                                                                              the route to register in this object's REST server (service).

                                                                              Parameter action

                                                                              the middleware action to perform at the given route.

                                                                            method registerRoute

                                                                            registerRoute: (
                                                                            method: string,
                                                                            route: string,
                                                                            schema: Schema,
                                                                            action: (req: any, res: any) => void
                                                                            ) => void;
                                                                            • Registers an action in this objects REST server (service) by the given method and route.

                                                                              Parameter method

                                                                              the HTTP method of the route.

                                                                              Parameter route

                                                                              the route to register in this object's REST server (service).

                                                                              Parameter schema

                                                                              the schema to use for parameter validation.

                                                                              Parameter action

                                                                              the action to perform at the given route.

                                                                            method registerRouteWithAuth

                                                                            registerRouteWithAuth: (
                                                                            method: string,
                                                                            route: string,
                                                                            schema: Schema,
                                                                            authorize: (req: any, res: any, next: () => void) => void,
                                                                            action: (req: any, res: any) => void
                                                                            ) => void;
                                                                            • Registers an action with authorization in this objects REST server (service) by the given method and route.

                                                                              Parameter method

                                                                              the HTTP method of the route.

                                                                              Parameter route

                                                                              the route to register in this object's REST server (service).

                                                                              Parameter schema

                                                                              the schema to use for parameter validation.

                                                                              Parameter authorize

                                                                              the authorization interceptor

                                                                              Parameter action

                                                                              the action to perform at the given route.

                                                                            method setReferences

                                                                            setReferences: (references: IReferences) => void;
                                                                            • Sets references to this endpoint's logger, counters, and connection resolver.

                                                                              __References:__ - logger: "*:logger:*:*:1.0" - counters: "*:counters:*:*:1.0" - discovery: "*:discovery:*:*:1.0" (for the connection resolver)

                                                                              Parameter references

                                                                              an IReferences object, containing references to a logger, counters, and a connection resolver.

                                                                              See Also

                                                                              • [[https://pip-services3-node.github.io/pip-services3-commons-node/interfaces/refer.ireferences.html IReferences]] (in the PipServices "Commons" package)

                                                                            method unregister

                                                                            unregister: (registration: IRegisterable) => void;
                                                                            • Unregisters a registerable object, so that it is no longer used in dynamic endpoint discovery.

                                                                              Parameter registration

                                                                              the registration to remove.

                                                                              See Also

                                                                              • [[IRegisterable]]

                                                                            class HttpRequestDetector

                                                                            class HttpRequestDetector {}
                                                                            • Helper class that retrieves parameters from HTTP requests.

                                                                            method detectAddress

                                                                            static detectAddress: (req: any) => string;
                                                                            • Detects the IP address from which the given HTTP request was received.

                                                                              Parameter req

                                                                              an HTTP request to process.

                                                                              Returns

                                                                              the detected IP address (without a port). If no IP is detected - null will be returned.

                                                                            method detectBrowser

                                                                            static detectBrowser: (req: any) => string;
                                                                            • Detects the browser (using "user-agent") from which the given HTTP request was made.

                                                                              Parameter req

                                                                              an HTTP request to process.

                                                                              Returns

                                                                              the detected browser. Detectable browsers: "chrome", "msie", "firefox", "safari". Otherwise - "unknown" will be returned.

                                                                            method detectPlatform

                                                                            static detectPlatform: (req: any) => string;
                                                                            • Detects the platform (using "user-agent") from which the given HTTP request was made.

                                                                              Parameter req

                                                                              an HTTP request to process.

                                                                              Returns

                                                                              the detected platform and version. Detectable platforms: "mobile", "iphone", "ipad", "macosx", "android", "webos", "mac", "windows". Otherwise - "unknown" will be returned.

                                                                            method detectServerHost

                                                                            static detectServerHost: (req: any) => string;
                                                                            • Detects the host name of the request's destination server.

                                                                              Parameter req

                                                                              an HTTP request to process.

                                                                              Returns

                                                                              the destination server's host name.

                                                                            method detectServerPort

                                                                            static detectServerPort: (req: any) => any;
                                                                            • Detects the request's destination port number.

                                                                              Parameter req

                                                                              an HTTP request to process.

                                                                              Returns

                                                                              the detected port number or 80 (if none are detected).

                                                                            class HttpResponseSender

                                                                            class HttpResponseSender {}
                                                                            • Helper class that handles HTTP-based responses.

                                                                            method sendCreatedResult

                                                                            static sendCreatedResult: (
                                                                            req: any,
                                                                            res: any
                                                                            ) => (err: any, result: any) => void;
                                                                            • Creates a callback function that sends newly created object as JSON. That callack function call be called directly or passed as a parameter to business logic components.

                                                                              If object is not null it returns 201 status code. For null results it returns 204 status code. If error occur it sends ErrorDescription with approproate status code.

                                                                              Parameter req

                                                                              a HTTP request object.

                                                                              Parameter res

                                                                              a HTTP response object.

                                                                              Parameter callback

                                                                              function that receives execution result or error.

                                                                            method sendDeletedResult

                                                                            static sendDeletedResult: (
                                                                            req: any,
                                                                            res: any
                                                                            ) => (err: any, result: any) => void;
                                                                            • Creates a callback function that sends deleted object as JSON. That callack function call be called directly or passed as a parameter to business logic components.

                                                                              If object is not null it returns 200 status code. For null results it returns 204 status code. If error occur it sends ErrorDescription with approproate status code.

                                                                              Parameter req

                                                                              a HTTP request object.

                                                                              Parameter res

                                                                              a HTTP response object.

                                                                              Parameter callback

                                                                              function that receives execution result or error.

                                                                            method sendEmptyResult

                                                                            static sendEmptyResult: (req: any, res: any) => (err: any) => void;
                                                                            • Creates a callback function that sends an empty result with 204 status code. If error occur it sends ErrorDescription with approproate status code.

                                                                              Parameter req

                                                                              a HTTP request object.

                                                                              Parameter res

                                                                              a HTTP response object.

                                                                              Parameter callback

                                                                              function that receives error or null for success.

                                                                            method sendError

                                                                            static sendError: (req: any, res: any, error: any) => void;
                                                                            • Sends error serialized as ErrorDescription object and appropriate HTTP status code. If status code is not defined, it uses 500 status code.

                                                                              Parameter req

                                                                              a HTTP request object.

                                                                              Parameter res

                                                                              a HTTP response object.

                                                                              Parameter error

                                                                              an error object to be sent.

                                                                            method sendResult

                                                                            static sendResult: (req: any, res: any) => (err: any, result: any) => void;
                                                                            • Creates a callback function that sends result as JSON object. That callack function call be called directly or passed as a parameter to business logic components.

                                                                              If object is not null it returns 200 status code. For null results it returns 204 status code. If error occur it sends ErrorDescription with approproate status code.

                                                                              Parameter req

                                                                              a HTTP request object.

                                                                              Parameter res

                                                                              a HTTP response object.

                                                                              Parameter callback

                                                                              function that receives execution result or error.

                                                                            class OwnerAuthManager

                                                                            class OwnerAuthorizer {}

                                                                              method owner

                                                                              owner: (idParam?: string) => (req: any, res: any, next: () => void) => void;

                                                                                method ownerOrAdmin

                                                                                ownerOrAdmin: (
                                                                                idParam?: string
                                                                                ) => (req: any, res: any, next: () => void) => void;

                                                                                  class RestClient

                                                                                  abstract class RestClient implements IOpenable, IConfigurable, IReferenceable {}
                                                                                  • Abstract client that calls remove endpoints using HTTP/REST protocol.

                                                                                    ### Configuration parameters ###

                                                                                    - base_route: base route for remote URI - connection(s): - discovery_key: (optional) a key to retrieve the connection from [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/connect.idiscovery.html IDiscovery]] - protocol: connection protocol: http or https - host: host name or IP address - port: port number - uri: resource URI or connection string with all parameters in it - options: - retries: number of retries (default: 3) - connect_timeout: connection timeout in milliseconds (default: 10 sec) - timeout: invocation timeout in milliseconds (default: 10 sec) - correlation_id_place place for adding correalationId, query - in query string, headers - in headers, both - in query and headers (default: query)

                                                                                    ### References ###

                                                                                    - *:logger:*:*:1.0 (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/log.ilogger.html ILogger]] components to pass log messages - *:counters:*:*:1.0 (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/count.icounters.html ICounters]] components to pass collected measurements - *:discovery:*:*:1.0 (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/connect.idiscovery.html IDiscovery]] services to resolve connection

                                                                                    See Also

                                                                                    • [[RestService]]

                                                                                    • [[CommandableHttpService]]

                                                                                      ### Example ###

                                                                                      class MyRestClient extends RestClient implements IMyClient { ...

                                                                                      public getData(correlationId: string, id: string, callback: (err: any, result: MyData) => void): void {

                                                                                      let timing = this.instrument(correlationId, 'myclient.get_data'); this.call("get", "/get_data" correlationId, { id: id }, null, (err, result) => { timing.endTiming(); callback(err, result); }); } ... }

                                                                                      let client = new MyRestClient(); client.configure(ConfigParams.fromTuples( "connection.protocol", "http", "connection.host", "localhost", "connection.port", 8080 ));

                                                                                      client.getData("123", "1", (err, result) => { ... });

                                                                                  method addCorrelationId

                                                                                  protected addCorrelationId: (params: any, correlationId: string) => any;
                                                                                  • Adds a correlation id (correlation_id) to invocation parameter map.

                                                                                    Parameter params

                                                                                    invocation parameters.

                                                                                    Parameter correlationId

                                                                                    (optional) a correlation id to be added.

                                                                                    Returns

                                                                                    invocation parameters with added correlation id.

                                                                                  method addFilterParams

                                                                                  protected addFilterParams: (params: any, filter: any) => void;
                                                                                  • Adds filter parameters (with the same name as they defined) to invocation parameter map.

                                                                                    Parameter params

                                                                                    invocation parameters.

                                                                                    Parameter filter

                                                                                    (optional) filter parameters

                                                                                    Returns

                                                                                    invocation parameters with added filter parameters.

                                                                                  method addPagingParams

                                                                                  protected addPagingParams: (params: any, paging: any) => void;
                                                                                  • Adds paging parameters (skip, take, total) to invocation parameter map.

                                                                                    Parameter params

                                                                                    invocation parameters.

                                                                                    Parameter paging

                                                                                    (optional) paging parameters

                                                                                    Returns

                                                                                    invocation parameters with added paging parameters.

                                                                                  method call

                                                                                  protected call: (
                                                                                  method: string,
                                                                                  route: string,
                                                                                  correlationId?: string,
                                                                                  params?: any,
                                                                                  data?: any,
                                                                                  callback?: (err: any, result: any) => void
                                                                                  ) => void;
                                                                                  • Calls a remote method via HTTP/REST protocol.

                                                                                    Parameter method

                                                                                    HTTP method: "get", "head", "post", "put", "delete"

                                                                                    Parameter route

                                                                                    a command route. Base route will be added to this route

                                                                                    Parameter correlationId

                                                                                    (optional) transaction id to trace execution through call chain.

                                                                                    Parameter params

                                                                                    (optional) query parameters.

                                                                                    Parameter data

                                                                                    (optional) body object.

                                                                                    Parameter callback

                                                                                    (optional) callback function that receives result object or error.

                                                                                  method close

                                                                                  close: (correlationId: string, callback?: (err: any) => void) => void;
                                                                                  • Closes component and frees used resources.

                                                                                    Parameter correlationId

                                                                                    (optional) transaction id to trace execution through call chain.

                                                                                    Parameter callback

                                                                                    callback function that receives error or null no errors occured.

                                                                                  method configure

                                                                                  configure: (config: ConfigParams) => void;
                                                                                  • Configures component by passing configuration parameters.

                                                                                    Parameter config

                                                                                    configuration parameters to be set.

                                                                                  method instrument

                                                                                  protected instrument: (correlationId: string, name: string) => CounterTiming;
                                                                                  • Adds instrumentation to log calls and measure call time. It returns a CounterTiming object that is used to end the time measurement.

                                                                                    Parameter correlationId

                                                                                    (optional) transaction id to trace execution through call chain.

                                                                                    Parameter name

                                                                                    a method name.

                                                                                    Returns

                                                                                    CounterTiming object to end the time measurement.

                                                                                  method instrumentError

                                                                                  protected instrumentError: (
                                                                                  correlationId: string,
                                                                                  name: string,
                                                                                  err: any,
                                                                                  result?: any,
                                                                                  callback?: (err: any, result: any) => void
                                                                                  ) => void;
                                                                                  • Adds instrumentation to error handling.

                                                                                    Parameter correlationId

                                                                                    (optional) transaction id to trace execution through call chain.

                                                                                    Parameter name

                                                                                    a method name.

                                                                                    Parameter err

                                                                                    an occured error

                                                                                    Parameter result

                                                                                    (optional) an execution result

                                                                                    Parameter callback

                                                                                    (optional) an execution callback

                                                                                  method isOpen

                                                                                  isOpen: () => boolean;
                                                                                  • Checks if the component is opened.

                                                                                    Returns

                                                                                    true if the component has been opened and false otherwise.

                                                                                  method open

                                                                                  open: (correlationId: string, callback?: (err: any) => void) => void;
                                                                                  • Opens the component.

                                                                                    Parameter correlationId

                                                                                    (optional) transaction id to trace execution through call chain.

                                                                                    Parameter callback

                                                                                    callback function that receives error or null no errors occured.

                                                                                  method setReferences

                                                                                  setReferences: (references: IReferences) => void;
                                                                                  • Sets references to dependent components.

                                                                                    Parameter references

                                                                                    references to locate the component dependencies.

                                                                                  class RestOperations

                                                                                  abstract class RestOperations implements IConfigurable, IReferenceable {}

                                                                                    constructor

                                                                                    constructor();

                                                                                      method configure

                                                                                      configure: (config: ConfigParams) => void;

                                                                                        method getCorrelationId

                                                                                        protected getCorrelationId: (req: any) => any;

                                                                                          method getFilterParams

                                                                                          protected getFilterParams: (req: any) => FilterParams;

                                                                                            method getPagingParams

                                                                                            protected getPagingParams: (req: any) => PagingParams;

                                                                                              method invoke

                                                                                              invoke: (operation: string) => (req: any, res: any) => void;

                                                                                                method sendBadRequest

                                                                                                protected sendBadRequest: (req: any, res: any, message: string) => void;

                                                                                                  method sendConflict

                                                                                                  protected sendConflict: (req: any, res: any, message: string) => void;

                                                                                                    method sendCreatedResult

                                                                                                    protected sendCreatedResult: (
                                                                                                    req: any,
                                                                                                    res: any
                                                                                                    ) => (err: any, result: any) => void;

                                                                                                      method sendDeletedResult

                                                                                                      protected sendDeletedResult: (
                                                                                                      req: any,
                                                                                                      res: any
                                                                                                      ) => (err: any, result: any) => void;

                                                                                                        method sendEmptyResult

                                                                                                        protected sendEmptyResult: (req: any, res: any) => (err: any) => void;

                                                                                                          method sendError

                                                                                                          protected sendError: (req: any, res: any, error: any) => void;

                                                                                                            method sendInternalError

                                                                                                            protected sendInternalError: (req: any, res: any, message: string) => void;

                                                                                                              method sendNotFound

                                                                                                              protected sendNotFound: (req: any, res: any, message: string) => void;

                                                                                                                method sendResult

                                                                                                                protected sendResult: (req: any, res: any) => (err: any, result: any) => void;

                                                                                                                  method sendServerUnavailable

                                                                                                                  protected sendServerUnavailable: (req: any, res: any, message: string) => void;

                                                                                                                    method sendSessionExpired

                                                                                                                    protected sendSessionExpired: (req: any, res: any, message: string) => void;

                                                                                                                      method sendUnauthorized

                                                                                                                      protected sendUnauthorized: (req: any, res: any, message: string) => void;

                                                                                                                        method setReferences

                                                                                                                        setReferences: (references: IReferences) => void;

                                                                                                                          class RestService

                                                                                                                          abstract class RestService
                                                                                                                          implements
                                                                                                                          IOpenable,
                                                                                                                          IConfigurable,
                                                                                                                          IReferenceable,
                                                                                                                          IUnreferenceable,
                                                                                                                          IRegisterable {}
                                                                                                                          • Abstract service that receives remove calls via HTTP/REST protocol.

                                                                                                                            ### Configuration parameters ###

                                                                                                                            - base_route: base route for remote URI - dependencies: - endpoint: override for HTTP Endpoint dependency - controller: override for Controller dependency - connection(s): - discovery_key: (optional) a key to retrieve the connection from [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/connect.idiscovery.html IDiscovery]] - protocol: connection protocol: http or https - host: host name or IP address - port: port number - uri: resource URI or connection string with all parameters in it - credential - the HTTPS credentials: - ssl_key_file: the SSL private key in PEM - ssl_crt_file: the SSL certificate in PEM - ssl_ca_file: the certificate authorities (root cerfiticates) in PEM

                                                                                                                            ### References ###

                                                                                                                            - *:logger:*:*:1.0 (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/log.ilogger.html ILogger]] components to pass log messages - *:counters:*:*:1.0 (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/count.icounters.html ICounters]] components to pass collected measurements - *:discovery:*:*:1.0 (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/connect.idiscovery.html IDiscovery]] services to resolve connection - *:endpoint:http:*:1.0 (optional) [[HttpEndpoint]] reference

                                                                                                                            See Also

                                                                                                                            • [[RestClient]]

                                                                                                                              ### Example ###

                                                                                                                              class MyRestService extends RestService { private _controller: IMyController; ... public constructor() { base(); this._dependencyResolver.put( "controller", new Descriptor("mygroup","controller","*","*","1.0") ); }

                                                                                                                              public setReferences(references: IReferences): void { base.setReferences(references); this._controller = this._dependencyResolver.getRequired("controller"); }

                                                                                                                              public register(): void { registerRoute("get", "get_mydata", null, (req, res) => { let correlationId = req.param("correlation_id"); let id = req.param("id"); this._controller.getMyData(correlationId, id, this.sendResult(req, res)); }); ... } }

                                                                                                                              let service = new MyRestService(); service.configure(ConfigParams.fromTuples( "connection.protocol", "http", "connection.host", "localhost", "connection.port", 8080 )); service.setReferences(References.fromTuples( new Descriptor("mygroup","controller","default","default","1.0"), controller ));

                                                                                                                              service.open("123", (err) => { console.log("The REST service is running on port 8080"); });

                                                                                                                          method close

                                                                                                                          close: (correlationId: string, callback?: (err: any) => void) => void;
                                                                                                                          • Closes component and frees used resources.

                                                                                                                            Parameter correlationId

                                                                                                                            (optional) transaction id to trace execution through call chain.

                                                                                                                            Parameter callback

                                                                                                                            callback function that receives error or null no errors occured.

                                                                                                                          method configure

                                                                                                                          configure: (config: ConfigParams) => void;
                                                                                                                          • Configures component by passing configuration parameters.

                                                                                                                            Parameter config

                                                                                                                            configuration parameters to be set.

                                                                                                                          method getCorrelationId

                                                                                                                          getCorrelationId: (req: any) => string;
                                                                                                                          • Returns correlationId from request

                                                                                                                            Parameter req

                                                                                                                            http request Returns correlationId from request

                                                                                                                          method instrument

                                                                                                                          protected instrument: (correlationId: string, name: string) => CounterTiming;
                                                                                                                          • Adds instrumentation to log calls and measure call time. It returns a CounterTiming object that is used to end the time measurement.

                                                                                                                            Parameter correlationId

                                                                                                                            (optional) transaction id to trace execution through call chain.

                                                                                                                            Parameter name

                                                                                                                            a method name.

                                                                                                                            Returns

                                                                                                                            CounterTiming object to end the time measurement.

                                                                                                                          method instrumentError

                                                                                                                          protected instrumentError: (
                                                                                                                          correlationId: string,
                                                                                                                          name: string,
                                                                                                                          err: any,
                                                                                                                          result?: any,
                                                                                                                          callback?: (err: any, result: any) => void
                                                                                                                          ) => void;
                                                                                                                          • Adds instrumentation to error handling.

                                                                                                                            Parameter correlationId

                                                                                                                            (optional) transaction id to trace execution through call chain.

                                                                                                                            Parameter name

                                                                                                                            a method name.

                                                                                                                            Parameter err

                                                                                                                            an occured error

                                                                                                                            Parameter result

                                                                                                                            (optional) an execution result

                                                                                                                            Parameter callback

                                                                                                                            (optional) an execution callback

                                                                                                                          method isOpen

                                                                                                                          isOpen: () => boolean;
                                                                                                                          • Checks if the component is opened.

                                                                                                                            Returns

                                                                                                                            true if the component has been opened and false otherwise.

                                                                                                                          method open

                                                                                                                          open: (correlationId: string, callback?: (err: any) => void) => void;
                                                                                                                          • Opens the component.

                                                                                                                            Parameter correlationId

                                                                                                                            (optional) transaction id to trace execution through call chain.

                                                                                                                            Parameter callback

                                                                                                                            callback function that receives error or null no errors occured.

                                                                                                                          method register

                                                                                                                          abstract register: () => void;
                                                                                                                          • Registers all service routes in HTTP endpoint.

                                                                                                                            This method is called by the service and must be overriden in child classes.

                                                                                                                          method registerInterceptor

                                                                                                                          protected registerInterceptor: (
                                                                                                                          route: string,
                                                                                                                          action: (req: any, res: any, next: () => void) => void
                                                                                                                          ) => void;
                                                                                                                          • Registers a middleware for a given route in HTTP endpoint.

                                                                                                                            Parameter route

                                                                                                                            a command route. Base route will be added to this route

                                                                                                                            Parameter action

                                                                                                                            an action function that is called when middleware is invoked.

                                                                                                                          method registerOpenApiSpec

                                                                                                                          protected registerOpenApiSpec: (content: string) => void;

                                                                                                                            method registerOpenApiSpecFromFile

                                                                                                                            protected registerOpenApiSpecFromFile: (path: string) => void;

                                                                                                                              method registerRoute

                                                                                                                              protected registerRoute: (
                                                                                                                              method: string,
                                                                                                                              route: string,
                                                                                                                              schema: Schema,
                                                                                                                              action: (req: any, res: any) => void
                                                                                                                              ) => void;
                                                                                                                              • Registers a route in HTTP endpoint.

                                                                                                                                Parameter method

                                                                                                                                HTTP method: "get", "head", "post", "put", "delete"

                                                                                                                                Parameter route

                                                                                                                                a command route. Base route will be added to this route

                                                                                                                                Parameter schema

                                                                                                                                a validation schema to validate received parameters.

                                                                                                                                Parameter action

                                                                                                                                an action function that is called when operation is invoked.

                                                                                                                              method registerRouteWithAuth

                                                                                                                              protected registerRouteWithAuth: (
                                                                                                                              method: string,
                                                                                                                              route: string,
                                                                                                                              schema: Schema,
                                                                                                                              authorize: (req: any, res: any, next: () => void) => void,
                                                                                                                              action: (req: any, res: any) => void
                                                                                                                              ) => void;
                                                                                                                              • Registers a route with authorization in HTTP endpoint.

                                                                                                                                Parameter method

                                                                                                                                HTTP method: "get", "head", "post", "put", "delete"

                                                                                                                                Parameter route

                                                                                                                                a command route. Base route will be added to this route

                                                                                                                                Parameter schema

                                                                                                                                a validation schema to validate received parameters.

                                                                                                                                Parameter authorize

                                                                                                                                an authorization interceptor

                                                                                                                                Parameter action

                                                                                                                                an action function that is called when operation is invoked.

                                                                                                                              method sendCreatedResult

                                                                                                                              protected sendCreatedResult: (
                                                                                                                              req: any,
                                                                                                                              res: any
                                                                                                                              ) => (err: any, result: any) => void;
                                                                                                                              • Creates a callback function that sends newly created object as JSON. That callack function call be called directly or passed as a parameter to business logic components.

                                                                                                                                If object is not null it returns 201 status code. For null results it returns 204 status code. If error occur it sends ErrorDescription with approproate status code.

                                                                                                                                Parameter req

                                                                                                                                a HTTP request object.

                                                                                                                                Parameter res

                                                                                                                                a HTTP response object.

                                                                                                                                Parameter callback

                                                                                                                                function that receives execution result or error.

                                                                                                                              method sendDeletedResult

                                                                                                                              protected sendDeletedResult: (
                                                                                                                              req: any,
                                                                                                                              res: any
                                                                                                                              ) => (err: any, result: any) => void;
                                                                                                                              • Creates a callback function that sends deleted object as JSON. That callack function call be called directly or passed as a parameter to business logic components.

                                                                                                                                If object is not null it returns 200 status code. For null results it returns 204 status code. If error occur it sends ErrorDescription with approproate status code.

                                                                                                                                Parameter req

                                                                                                                                a HTTP request object.

                                                                                                                                Parameter res

                                                                                                                                a HTTP response object.

                                                                                                                                Parameter callback

                                                                                                                                function that receives execution result or error.

                                                                                                                              method sendError

                                                                                                                              protected sendError: (req: any, res: any, error: any) => void;
                                                                                                                              • Sends error serialized as ErrorDescription object and appropriate HTTP status code. If status code is not defined, it uses 500 status code.

                                                                                                                                Parameter req

                                                                                                                                a HTTP request object.

                                                                                                                                Parameter res

                                                                                                                                a HTTP response object.

                                                                                                                                Parameter error

                                                                                                                                an error object to be sent.

                                                                                                                              method sendResult

                                                                                                                              protected sendResult: (req: any, res: any) => (err: any, result: any) => void;
                                                                                                                              • Creates a callback function that sends result as JSON object. That callack function call be called directly or passed as a parameter to business logic components.

                                                                                                                                If object is not null it returns 200 status code. For null results it returns 204 status code. If error occur it sends ErrorDescription with approproate status code.

                                                                                                                                Parameter req

                                                                                                                                a HTTP request object.

                                                                                                                                Parameter res

                                                                                                                                a HTTP response object.

                                                                                                                                Parameter callback

                                                                                                                                function that receives execution result or error.

                                                                                                                              method setReferences

                                                                                                                              setReferences: (references: IReferences) => void;
                                                                                                                              • Sets references to dependent components.

                                                                                                                                Parameter references

                                                                                                                                references to locate the component dependencies.

                                                                                                                              method unsetReferences

                                                                                                                              unsetReferences: () => void;
                                                                                                                              • Unsets (clears) previously set references to dependent components.

                                                                                                                              class RoleAuthManager

                                                                                                                              class RoleAuthorizer {}

                                                                                                                                method admin

                                                                                                                                admin: () => (req: any, res: any, next: () => void) => void;

                                                                                                                                  method userInRole

                                                                                                                                  userInRole: (role: string) => (req: any, res: any, next: () => void) => void;

                                                                                                                                    method userInRoles

                                                                                                                                    userInRoles: (roles: string[]) => (req: any, res: any, next: () => void) => void;

                                                                                                                                      class StatusOperations

                                                                                                                                      class StatusOperations extends RestOperations {}

                                                                                                                                        constructor

                                                                                                                                        constructor();

                                                                                                                                          method getStatusOperation

                                                                                                                                          getStatusOperation: () => (req: any, res: any) => void;

                                                                                                                                            method setReferences

                                                                                                                                            setReferences: (references: IReferences) => void;
                                                                                                                                            • Sets references to dependent components.

                                                                                                                                              Parameter references

                                                                                                                                              references to locate the component dependencies.

                                                                                                                                            method status

                                                                                                                                            status: (req: any, res: any) => void;
                                                                                                                                            • Handles status requests

                                                                                                                                              Parameter req

                                                                                                                                              an HTTP request

                                                                                                                                              Parameter res

                                                                                                                                              an HTTP response

                                                                                                                                            class StatusRestService

                                                                                                                                            class StatusRestService extends RestService {}
                                                                                                                                            • Service that returns microservice status information via HTTP/REST protocol.

                                                                                                                                              The service responds on /status route (can be changed) with a JSON object: { - "id": unique container id (usually hostname) - "name": container name (from ContextInfo) - "description": container description (from ContextInfo) - "start_time": time when container was started - "current_time": current time in UTC - "uptime": duration since container start time in milliseconds - "properties": additional container properties (from ContextInfo) - "components": descriptors of components registered in the container }

                                                                                                                                              ### Configuration parameters ###

                                                                                                                                              - base_route: base route for remote URI - route: status route (default: "status") - dependencies: - endpoint: override for HTTP Endpoint dependency - controller: override for Controller dependency - connection(s): - discovery_key: (optional) a key to retrieve the connection from [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/connect.idiscovery.html IDiscovery]] - protocol: connection protocol: http or https - host: host name or IP address - port: port number - uri: resource URI or connection string with all parameters in it

                                                                                                                                              ### References ###

                                                                                                                                              - *:logger:*:*:1.0 (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/log.ilogger.html ILogger]] components to pass log messages - *:counters:*:*:1.0 (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/count.icounters.html ICounters]] components to pass collected measurements - *:discovery:*:*:1.0 (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/connect.idiscovery.html IDiscovery]] services to resolve connection - *:endpoint:http:*:1.0 (optional) [[HttpEndpoint]] reference

                                                                                                                                              See Also

                                                                                                                                              • [[RestService]]

                                                                                                                                              • [[RestClient]]

                                                                                                                                                ### Example ###

                                                                                                                                                let service = new StatusService(); service.configure(ConfigParams.fromTuples( "connection.protocol", "http", "connection.host", "localhost", "connection.port", 8080 ));

                                                                                                                                                service.open("123", (err) => { console.log("The Status service is accessible at http://+:8080/status"); });

                                                                                                                                            constructor

                                                                                                                                            constructor();
                                                                                                                                            • Creates a new instance of this service.

                                                                                                                                            method configure

                                                                                                                                            configure: (config: ConfigParams) => void;
                                                                                                                                            • Configures component by passing configuration parameters.

                                                                                                                                              Parameter config

                                                                                                                                              configuration parameters to be set.

                                                                                                                                            method register

                                                                                                                                            register: () => void;
                                                                                                                                            • Registers all service routes in HTTP endpoint.

                                                                                                                                            method setReferences

                                                                                                                                            setReferences: (references: IReferences) => void;
                                                                                                                                            • Sets references to dependent components.

                                                                                                                                              Parameter references

                                                                                                                                              references to locate the component dependencies.

                                                                                                                                            Interfaces

                                                                                                                                            interface ISwaggerService

                                                                                                                                            interface ISwaggerService {}
                                                                                                                                            • Interface to perform Swagger registrations.

                                                                                                                                            method registerOpenApiSpec

                                                                                                                                            registerOpenApiSpec: (baseRoute: string, swaggerRoute: string) => void;
                                                                                                                                            • Perform required Swagger registration steps.

                                                                                                                                            Package Files (22)

                                                                                                                                            Dependencies (6)

                                                                                                                                            Dev Dependencies (9)

                                                                                                                                            Peer Dependencies (0)

                                                                                                                                            No peer dependencies.

                                                                                                                                            Badge

                                                                                                                                            To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                            You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/pip-services3-rpc-node.

                                                                                                                                            • Markdown
                                                                                                                                              [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/pip-services3-rpc-node)
                                                                                                                                            • HTML
                                                                                                                                              <a href="https://www.jsdocs.io/package/pip-services3-rpc-node"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>