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.
This method is called by the service and must be overriden in child classes.
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.
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 referenceRestClient
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<IMyController>("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"); });