HotRouteMethod
hotstaq / Modules / HotRouteMethod
Class: HotRouteMethod
An API method to make.
Table of contents​
Constructors​
Properties​
- authCredentials
- executeSetup
- isRegistered
- name
- onClientExecute
- onPostRegister
- onPreRegister
- onRegister
- onServerAuthorize
- onServerExecute
- parentRoute
- testCases
- type
Methods​
Constructors​
constructor​
• new HotRouteMethod(route
, name
, onExecute?
, type?
, onServerAuthorize?
, onRegister?
, authCredentials?
, testCases?
)
Parameters​
Name | Type | Default value |
---|---|---|
route | HotRoute | undefined |
name | string | undefined |
onExecute | ServerExecutionFunction | ClientExecutionFunction | null |
type | HTTPMethod | HTTPMethod.POST |
onServerAuthorize | ServerAuthorizationFunction | null |
onRegister | ServerRegistrationFunction | null |
authCredentials | any | null |
testCases | (string | TestCaseFunction )[] | TestCaseFunction [] | TestCaseObject [] | null |
Defined in​
Properties​
authCredentials​
• authCredentials: any
The authorization credentials to be used by the client when connecting to the server.
Defined in​
executeSetup​
• executeSetup: boolean
Has this method been registered with the server? This prevents the method from being reregistered.
Defined in​
isRegistered​
• isRegistered: boolean
Has this method been registered with the server? This prevents the method from being reregistered.
Defined in​
name​
• name: string
The api call name.
Defined in​
onClientExecute​
• Optional
onClientExecute: ClientExecutionFunction
Executes when executing a called method from the client side.
fixme
Is this necessary?
Defined in​
onPostRegister​
• Optional
onPostRegister: () => Promise
<void
>
Type declaration​
â–¸ (): Promise
<void
>
Executes after all routes have been registered.
Returns​
Promise
<void
>
Defined in​
onPreRegister​
• Optional
onPreRegister: () => Promise
<void
>
Type declaration​
â–¸ (): Promise
<void
>
Executes before all routes have been registered.
Returns​
Promise
<void
>
Defined in​
onRegister​
• Optional
onRegister: ServerRegistrationFunction
Executes when first registering this method with Express. If this returns false, the method will not be registered.
Defined in​
onServerAuthorize​
• Optional
onServerAuthorize: ServerAuthorizationFunction
Executes when authorizing a called method. If this method is set, this will not call onAuthorize for the parent HotRoute. The value returned from here will be passed to onExecute. Undefined returning from here will mean the authorization failed. If any exceptions are thrown from this function, they will be sent to the server as an { error: string; } object with the exception message as the error.
Defined in​
onServerExecute​
• Optional
onServerExecute: ServerExecutionFunction
Executes when executing a called method from the server side. This will stringify any JSON object and send it as a JSON response. If undefined is returned no response will be sent to the server. So the developer would have to send a response using "res". If any exceptions are thrown from this function, they will be sent to the server as an { error: string; } object with the exception message as the error.
Defined in​
parentRoute​
• parentRoute: HotRoute
The parent route.
Defined in​
testCases​
• testCases: Object
The test case objects to execute during tests.
Index signature​
â–ª [name: string
]: TestCaseObject
Defined in​
type​
• type: HTTPMethod
The api call name.
Defined in​
Methods​
addTestCase​
â–¸ addTestCase(newTestCase
, testCaseFunction?
): void
Add a new test case.
Parameters​
Name | Type | Default value |
---|---|---|
newTestCase | string | TestCaseFunction | TestCaseObject | undefined |
testCaseFunction | TestCaseFunction | null |
Returns​
void