@nats-io/services
    Preparing search index...

    Type Alias ServiceHandler

    ServiceHandler: (err: Error | null, msg: ServiceMsg) => void

    Handles a request to an endpoint. The handler may be async.

    The request is counted in the endpoint's stats when the handler returns or, when it is async, when its promise settles: its processing time, and an error if it threw or rejected, or else responded with an error before then. Work done or replies sent elsewhere afterwards, for example by another worker the request was handed to, are not counted. A promise that never settles is never counted.

    If the handler throws or its promise rejects, an error reply is sent: the code and description of a ServiceError, or code 500 and "internal error" for any other error. Throw a ServiceError, or use respondError, for errors meant for the client.

    Any other error is a runtime error: its details are internal, so they are only recorded in the endpoint's stats (last_error), and printed with console.error as an errors.UnhandledCallbackError that says which handler failed, with what was thrown as its cause.

    Type Declaration

      • (err: Error | null, msg: ServiceMsg): void
      • Parameters

        Returns void