Creates a new instance of the service.
a service base route.
The base route.
The performance counters.
The dependency resolver.
The HTTP endpoint that exposes this service.
The logger.
Closes component and frees used resources.
(optional) transaction id to trace execution through call chain.
callback function that receives error or null no errors occured.
Configures component by passing configuration parameters.
configuration parameters to be set.
Adds instrumentation to log calls and measure call time. It returns a Timing object that is used to end the time measurement.
(optional) transaction id to trace execution through call chain.
a method name.
Timing object to end the time measurement.
Checks if the component is opened.
true if the component has been opened and false otherwise.
Opens the component.
(optional) transaction id to trace execution through call chain.
callback function that receives error or null no errors occured.
Registers all service routes in HTTP endpoint.
Registers a route in HTTP endpoint.
HTTP method: "get", "head", "post", "put", "delete"
a command route. Base route will be added to this route
a validation schema to validate received parameters.
an action function that is called when operation is invoked.
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.
a HTTP request object.
a HTTP response object.
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.
a HTTP request object.
a HTTP response object.
Sends error serialized as ErrorDescription object and appropriate HTTP status code. If status code is not defined, it uses 500 status code.
a HTTP request object.
a HTTP response object.
an error object to be sent.
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.
a HTTP request object.
a HTTP response object.
Sets references to dependent components.
references to locate the component dependencies.
Unsets (clears) previously set references to dependent components.
Generated using TypeDoc
Abstract service that receives remove calls via HTTP/REST protocol to operations automatically generated for commands defined in 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
References
*:logger:*:*:1.0
(optional) ILogger components to pass log messages*:counters:*:*:1.0
(optional) ICounters components to pass collected measurements*:discovery:*:*:1.0
(optional) IDiscovery services to resolve connection*:endpoint:http:*:1.0
(optional) HttpEndpoint referenceCommandableHttpClient
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"); });