The options to construct the controller.
Protected
Readonly
_apiThe generated endpoints for the API client configuration the controller can generate.
Protected
Readonly
_apiThe entry URL for the API client configuration the controller can generate.
Protected
Readonly
_endpointsA flat dictionary with the endpoints information.
Protected
Readonly
_gatewayThe information, url and endpoints, for the gateway the controller will make requests to.
Protected
Readonly
_getA function to get a possible helper service. This is injected as a "getter" to not interrupt the DIC "lifecycle": controllers are initialized right when the app starts, and injecting a reference would force the service to be initialized too, even if a request is not being made.
Protected
Readonly
_optionsThe controller customization options.
Protected
Readonly
_routeThe route in which the controller is mounted.
Protected
Readonly
_routeA regular expression that will be used to remove the controller route from a request path. This will allow the main middleware to extract the path to where the request should be made.
Protected
Readonly
_routesThe list of routes the controller can handle.
Protected
Readonly
httpThe service that makes HTTP requests.
The configuration for the gateway the controller will make requests to.
The customization options.
Protected
_addMounts the middleware(s) for an endpoint in the router.
The information of the endpoint and how it needs to be added.
Protected
_createAPIConfigCreates the API client configuration based on the controller routes.
Protected
_createGenerates a middleware that will make the request to an endpoint and stream the response.
The information of the endpoint the middleware will handle.
Protected
_createBased on the information from the endpoints, this method will create the routes the controller will later add on a router.
Protected
_formatFormats the endpoints for the gateway into a flat dictionary without nesting.
Protected
_formatValidates and formats the customization options sent to the controller.
The options sent to the constructor.
Protected
_handleThis is a "proxy method" to call the helper service's function that handles an error on an endpoint request.
The reason this is a "proxy method" is in case the controller gets subclassed and "used itself as a helper" instead of relying on a difference one.
If the helper doesn't implement handleEndpointError
, it will just send the error to
the next middleware/error handler.
The information of the response and the reference to the helper.
Protected
_handleThis is a "proxy method" to call the helper service's function that handles a response in case it already said that a response shouldn't be streamed.
The reason this is a "proxy method" is in case the controller gets subclassed and "used itself as a helper" instead of relying on a difference one.
If the helper doesn't implement shouldStreamEndpointResponse
, it will throw an
error.
The information of the response and the reference to the helper.
Protected
_reduceThis is a "proxy method" to call the helper service's function that can modify an endpoint request before it gets made.
The reason this is a "proxy method" is in case the controller gets subclassed and "used itself as a helper" instead of relying on a difference one.
If the helper doesn't implement reduceEndpointRequest
, it will just return
information for the request.
The information of the request and the reference to the helper.
Protected
_reduceThis is a "proxy method" to call the helper service's function that can modify an endpoint response before it gets processed.
The reason this is a "proxy method" is in case the controller gets subclassed and "used itself as a helper" instead of relying on a difference one.
If the helper doesn't implement reduceEndpointResponse
, it will just return
information for the response.
The information of the response and the reference to the helper.
Protected
_shouldThis is a "proxy method" to call the helper service's function that can decide if an endpoint response should be streamed or not.
The reason this is a "proxy method" is in case the controller gets subclassed and "used itself as a helper" instead of relying on a difference one.
If the helper doesn't implement shouldStreamEndpointResponse
, it will just return
true
.
The information of the response and the reference to the helper.
Protected
_validateHTTPMethodValidates a router/HTTP method that the controller intends to use for an endpoint. If
it's not valid, it will return all
.
The HTTP method for the endpoint.
Mounts the middlewares in the router in order to make the requests.
A reference to the application router.
A list of extra middlewares to execute before the gateway middleware.
Generates an API client configuration based on the controller routes.
The options to customize the generated configuration.
A utility controller that generates routes that act as a gateway for a specific API.
Prettierignore