EndpointConfig
Object representing the configuration of a single endpoint.
Constructor Summary
Public Constructor | ||
public |
constructor(path: string, methods: Array<string | Function>, state: Array | Object, nested: Array<EndpointConfig>) Creates a new instance of EndpointConfig. |
Member Summary
Public Members | ||
public |
methods: Array<string | Function> Available methods at the endpoint. |
|
public |
|
|
public |
The root path for the endpoint. |
|
public |
this member is experimental. The state management is still under consideration and might change greatly.
The state object represents the current state of the endpoint data storage. |
Public Constructors
public constructor(path: string, methods: Array<string | Function>, state: Array | Object, nested: Array<EndpointConfig>) source
Creates a new instance of EndpointConfig.
Params:
Name | Type | Attribute | Description |
path | string | Path for the endpoint root. |
|
methods | Array<string | Function> |
|
Sets the methods available for use at the endpoint. |
state | Array | Object |
|
Sets the initial state of the endpoint data. |
nested | Array<EndpointConfig> |
|
Contains the nested endpoints of the endpoint. |
Public Members
public methods: Array<string | Function> source
Available methods at the endpoint.
For automatic generation the following keywords are available:
- GET_ALL - Returns a list of all the resources in the endpoint state.
- GET_BY_KEY - Returns a specified resource identified by the given ServerConfig.identifierKey.
- GET_ONE - Currently only usable with
Object
-type state. See EndpointConfig.state. - POST - Creates a new resource at the given endpoint.
- PUT - Updates a specified resource identified by the given ServerConfig.identifierKey.
- DELETE - Deletes a specified resource identified by the given ServerConfig.identifierKey.
You can also create a custom handler by passing a function that takes in the path and state as arguments.
Example:
(path, state) => {
return {
path: `${path}/meta`,
method: 'GET',
handler: (request, reply) => reply({type: 'metaResponse', state})
}
}
public nested: Array<EndpointConfig> source
public path: string source
The root path for the endpoint. Note that all nested endpoint will be prefixed by their parents paths.
public state: Array | Object source
The state object represents the current state of the endpoint data storage.
If the type of the state is Object
then the only available method to use is GET_ONE.