Protected
cachesAn array of cache objects used to store data temporarily. Each cache object is expected to hold an array of elements, with the specific type of the elements being flexible (any[]). This variable can be utilized as a mechanism to manage and retrieve stored data efficiently.
Protected
defaultThe default duration for cache lifetime.
Protected
serviceHandles the creation of a new resource by processing the request, sanitizing input and output data, and responding with the created resource.
The HTTP request containing the data to create the resource.
The HTTP response used to send the result back to the client.
This method does not return a value, it sends a response to the client.
Deletes a resource identified by the provided ID.
The HTTP request object, containing the resource ID to delete.
The HTTP response object, used to send back the deletion result.
No value is returned, the response object is used to communicate the result.
Clears all the caches by resetting the caches array to an empty state.
No return value.
Filters the input value based on specific criteria.
The value to be evaluated against the filter.
Returns true if the value meets the filter criteria, otherwise false.
Retrieves all data based on the provided request, processes it, and sends the appropriate response.
The incoming request object containing the necessary parameters and context.
The response object used to send back the processed data or error information.
This method does not return anything directly, but responds to the client with the processed data or an error.
Retrieves a record by its identifier from the database, sanitizes the data, and sends the response back to the client. Throws an exception if the record is not found or an error occurs during the process.
The HTTP request object, used to extract the record ID.
The HTTP response object, used to send back the result or error message.
Does not return a value, as it sends the response directly to the client.
Loads data using the provided loader function and generates a cache with a checksum. Uses request-specific parameters to identify caching needs, validate cache validity, and update the cache if necessary.
The incoming request object containing the necessary parameters and context.
The function used to load data from the data source.
Optional
onOptional method to perform teardown or clean-up actions specific to the instance. It is invoked when the instance is being destroyed. This method does not take any parameters and does not return any value.
Sanitizes the provided value for safe usage and storage in a database.
The input object or data structure that needs to be sanitized.
The sanitized version of the input object or data structure.
Sanitizes the given object retrieved from the database to ensure it is safe and standardized for processing.
The object retrieved from the database that needs to be sanitized.
The sanitized object after processing.
Updates the resource with the provided data and responds with the updated result.
The request object containing the data to update the resource.
The response object used to send the result or error to the client.
This method does not return a value; it sends a response back to the client.
Static
getRetrieves and parses the "id" parameter from the given request object.
The request object containing parameters.
Optional
shouldThrow: boolean = trueDetermines whether an exception should be thrown if the "id" parameter is missing.
The parsed integer value of the "id" parameter if present, or null if not present and shouldThrow
is false.
Static
getStatic
getTries to get parameters specified in paramDefinition from requests route parameters. If a parameter is not found in the request, the parameter is set to the default value specified in paramDefinition.
{Express.Request}
{ParamDefinition}
The
ControllerInstance
class represents an implementation of theInstance
interface. It provides the ability to define a controller that can include optional lifecycle methods.The class may optionally include the
onDestroy
method, which is invoked to handle cleanup or teardown logic when the instance is destroyed.This design allows extending classes or implementations to define specific behaviors for the
onDestroy
lifecycle hook.Implements:
Instance
: Interface to be implemented by theControllerInstance
class.Methods:
onDestroy?
: Optional. A method to define custom clean-up or shutdown logic when the controller instance is destroyed. It is invoked automatically at the appropriate lifecycle stage.