Home Reference Source Repository
import {EndpointConfig} from 'test-rest/src/models/EndpointConfig.js'
public class | source

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:

NameTypeAttributeDescription
path string

Path for the endpoint root.

methods Array<string | Function>
  • optional
  • default: []

Sets the methods available for use at the endpoint.

state Array | Object
  • optional
  • default: []

Sets the initial state of the endpoint data.

nested Array<EndpointConfig>
  • optional

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:

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

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. If the type of the state is Object then the only available method to use is GET_ONE.