Skip to main content

HotRouteMethod

hotstaq / Modules / HotRouteMethod

Class: HotRouteMethod

An API method to make.

Table of contents​

Constructors​

Properties​

Methods​

Constructors​

constructor​

• new HotRouteMethod(route, name, onExecute?, type?, onServerAuthorize?, onRegister?, authCredentials?, testCases?)

Parameters​

NameTypeDefault value
routeHotRouteundefined
namestringundefined
onExecuteServerExecutionFunction | ClientExecutionFunctionnull
typeHTTPMethodHTTPMethod.POST
onServerAuthorizeServerAuthorizationFunctionnull
onRegisterServerRegistrationFunctionnull
authCredentialsanynull
testCases(string | TestCaseFunction)[] | TestCaseFunction[] | TestCaseObject[]null

Defined in​

HotRouteMethod.ts:95

Properties​

authCredentials​

• authCredentials: any

The authorization credentials to be used by the client when connecting to the server.

Defined in​

HotRouteMethod.ts:87


executeSetup​

• executeSetup: boolean

Has this method been registered with the server? This prevents the method from being reregistered.

Defined in​

HotRouteMethod.ts:82


isRegistered​

• isRegistered: boolean

Has this method been registered with the server? This prevents the method from being reregistered.

Defined in​

HotRouteMethod.ts:77


name​

• name: string

The api call name.

Defined in​

HotRouteMethod.ts:68


onClientExecute​

• Optional onClientExecute: ClientExecutionFunction

Executes when executing a called method from the client side.

fixme Is this necessary?

Defined in​

HotRouteMethod.ts:178


onPostRegister​

• Optional onPostRegister: () => Promise<void>

Type declaration​

â–¸ (): Promise<void>

Executes after all routes have been registered.

Returns​

Promise<void>

Defined in​

HotRouteMethod.ts:151


onPreRegister​

• Optional onPreRegister: () => Promise<void>

Type declaration​

â–¸ (): Promise<void>

Executes before all routes have been registered.

Returns​

Promise<void>

Defined in​

HotRouteMethod.ts:142


onRegister​

• Optional onRegister: ServerRegistrationFunction

Executes when first registering this method with Express. If this returns false, the method will not be registered.

Defined in​

HotRouteMethod.ts:147


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​

HotRouteMethod.ts:162


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​

HotRouteMethod.ts:173


parentRoute​

• parentRoute: HotRoute

The parent route.

Defined in​

HotRouteMethod.ts:64


testCases​

• testCases: Object

The test case objects to execute during tests.

Index signature​

â–ª [name: string]: TestCaseObject

Defined in​

HotRouteMethod.ts:91


type​

• type: HTTPMethod

The api call name.

Defined in​

HotRouteMethod.ts:72

Methods​

addTestCase​

â–¸ addTestCase(newTestCase, testCaseFunction?): void

Add a new test case.

Parameters​

NameTypeDefault value
newTestCasestring | TestCaseFunction | TestCaseObjectundefined
testCaseFunctionTestCaseFunctionnull

Returns​

void

Defined in​

HotRouteMethod.ts:183