Skip to content

Legacy API: Development

James Lott edited this page May 8, 2018 · 1 revision

Anatomy of an endpoint

API endpoints are implemented as a collection of components which work together to return the requested API object to the requesting client. The components of an endpoint are documented and explained in this section.

API Object

The API object itself is simply an object which defines the properties specified by the interface specification. API objects serve only as data containers, and do not define any methods (with the exception of a toJSON method, though in most cases defining that method is not necessary either).

To see examples of API object implementations, see any of lib/objects/*.js

Storage object

The storage object is responsible for fetching the data needed to instantiate a API object, instating the object, and invoking the processing method passed to it by its caller.

To see examples of storage object implementations, see any of lib/storage/sqlite/*.js

Controller

The controller is a function which is responsible for collecting inputs from the requestor, passing the requestor's inputs to a fetch method of a storage object, and returning the API object instantiated by the storage method to the requestor

To see examples of controller implementations, see any of controllers/*.js

Clone this wiki locally