Factory class to define a bunch of action handlers.
Type parameter | Value |
---|
P extends Patch | ItemPatch |
new DataConnector<P>(client): DataConnector<P>
DataConnector
<P
>
new DataConnector<P>(client, optPatchParser): DataConnector<P>
Parameter | Type |
---|
client | DataConnectorClient |
optPatchParser | P extends ItemPatch ? never : PatchParser <P > |
DataConnector
<P
>
actions: Record<string, object | object> = {};
routes: Record<string, DataConnectorRoute> = {};
defineAction<T>(
name,
request,
asynchronous): DataConnector<P>
Factory to define an action request handler
Type parameter |
---|
T extends string |
Parameter | Type | Default value |
---|
name | T | undefined |
request | ActionTypeForName <P , T , boolean > | undefined |
asynchronous | boolean | false |
DataConnector
<P
>
defineAsynchronousAction<T>(name, request): DataConnector<P>
Factory to define an asynchronous action request handler
Type parameter |
---|
T extends string |
Parameter | Type |
---|
name | T |
request | ActionTypeForName <P , T , true > |
DataConnector
<P
>
defineRoute(name, request): DataConnector<P>
Factory to define a route handler
DataConnector
<P
>
routeDebugServer(options): ExpressAppLike
Add a route to the given express app (or generate a new app) to serve this data connector
Parameter | Type |
---|
options | RunDebugServerOptions |
ExpressAppLike
runAction(
url,
headers,
body): Promise<object>
Call a defined action handler and gather its serialized response
Parameter | Type |
---|
url | string |
headers | Record <string , undefined | string | string []> |
body | unknown |
Promise
<object
>
runDebugServer(options): void
Serve this data connector as a simple express app for debugging purposes
Parameter | Type |
---|
options | RunDebugServerOptions |
void