The REST API service endpoint implementations of the systems
executive.
These functions must be registered during the startup phase of the application, via the startup()
functions of the executive, and they will respond to the incoming API calls.
The responses are objects, that hold the complete information that is required by the npac-webserver-adapter
middleware to make a correct HTTP response to the client, including { headers: {...}, status: ..., body: ... }
. This response object must be placed into the second parameter of the cb
callback function, and null
value as the first parameter.
NOTE: In case of the service wants to respond with a HTTP-level error, the callback also has to be called with null
, and the response object will contain the error code and error content body.
Methods
(static) deleteSystems(data, cb)
Serve the DELETE /systems
API call.
The function deletes all systems.
Parameters:
Name | Type | Description |
---|---|---|
data |
Object | The complete data payload of the incoming call |
cb |
function | The error-first callback function that will be called either with the complete success response or with the response that describe the error and contains the corresponding error status code. |
(static) getSystems(data, cb)
Serve the GET /systems
API call.
The function retrieves and responses wth the list of systems.
Parameters:
Name | Type | Description |
---|---|---|
data |
Object | The complete data payload of the incoming call |
cb |
function | The error-first callback function that will be called either with the complete success response or with the response that describe the error and contains the corresponding error status code. |
(static) postSystems(data, cb)
Serve the POST /systems
API call.
The function creates a new system.
Parameters:
Name | Type | Description |
---|---|---|
data |
Object | The complete data payload of the incoming call |
cb |
function | The error-first callback function that will be called either with the complete success response or with the response that describe the error and contains the corresponding error status code. |