Handlers
A handler
is invoked whenever a request is made to its associated path. A handler
can take multiple shapes depending
on desired operation. In general, it accepts a context
object, and must return an API
response.
Types
HandlersInput
Type used as input on a addHandler
function call.
Its shape changes depending on which type of handler you are adding.
type HandlersInput = {
getItem?: GetItemHandler;
getCollection?: GetCollectionHandler;
createItem?: CreateItemHandler;
updateItem?: UpdateItemHandler;
deleteItem?: DeleteItemHandler;
}
| { getCredentialAccount: GetCredentialAccountHandler; }
| { parseWebhooks: ParseWebhooksHandler; }
| { updateWebhookSubscriptions: UpdateWebhookSubscriptionsHandler; }
| { acknowledgeWebhooks: AcknowledgeWebhooksHandler; }
GetItemHandler
Handler called to get an individual item.
export type GetItemHandler = (context: GetItemContext<any, any>) => Promise<API.Item>;
GetCollectionHandler
Handler called to retrieve a collection of items.
export type GetCollectionHandler = (context: GetCollectionContext<any, any>) => Promise<API.Collection>;