Skip to main content

HotRoute

hotstaq / Modules / HotRoute

Class: HotRoute

The route to use.

Table of contents​

Constructors​

Properties​

Methods​

Constructors​

constructor​

• new HotRoute(connection, route, methods?)

Parameters​

NameTypeDefault value
connectionHotServer | HotClientundefined
routestringundefined
methodsHotRouteMethod[][]

Defined in​

HotRoute.ts:46

Properties​

authCredentials​

• authCredentials: any

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

Defined in​

HotRoute.ts:35


connection​

• connection: HotServer | HotClient

The server that maintains the connections.

Defined in​

HotRoute.ts:14


errors​

• errors: Object

The errors and their JSON that can be thrown. Can be:

  • not_authorized

Index signature​

â–ª [error: string]: any

Defined in​

HotRoute.ts:44


logger​

• logger: HotLog

The associated logger.

Defined in​

HotRoute.ts:18


methods​

• methods: HotRouteMethod[]

The calls that can be made.

Defined in​

HotRoute.ts:39


onAuthorizeUser​

• onAuthorizeUser: (req: any, res: any) => Promise<any> = null

Type declaration​

â–¸ (req, res): Promise<any>

Executes when authorizing a called method. The value returned from here will be passed to onExecute in the called HotRouteMethod. Undefined returning from here will mean the authorization failed.

Parameters​
NameType
reqany
resany
Returns​

Promise<any>

Defined in​

HotRoute.ts:136


onPostRegister​

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

Type declaration​

â–¸ (): Promise<void>

Executes after all routes have been registered.

Returns​

Promise<void>

Defined in​

HotRoute.ts:128


onPreRegister​

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

Type declaration​

â–¸ (): Promise<void>

Executes before all routes have been registered.

Returns​

Promise<void>

Defined in​

HotRoute.ts:119


onRegister​

• onRegister: () => Promise<boolean> = null

Type declaration​

â–¸ (): Promise<boolean>

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

Returns​

Promise<boolean>

Defined in​

HotRoute.ts:124


prefix​

• prefix: string

The prefix to add to the beginning of each route method.

Defined in​

HotRoute.ts:30


route​

• route: string

The route.

Defined in​

HotRoute.ts:22


version​

• version: string

The version.

Defined in​

HotRoute.ts:26

Methods​

addMethod​

â–¸ addMethod(method, executeFunction?, type?, testCases?): void

Add an API method to this route.

Parameters​

NameTypeDefault valueDescription
methodstring | HotRouteMethodundefinedThe name of the method to add. If a HotRouteMethod is supplied, the rest of the arguments supplied will be ignored.
executeFunctionServerExecutionFunctionnull-
typeHTTPMethodHTTPMethod.POST-
testCases(string | TestCaseFunction)[] | TestCaseFunction[] | TestCaseObject[]null-

Returns​

void

Defined in​

HotRoute.ts:81


getMethod​

â–¸ getMethod(name): HotRouteMethod

Get a method by it's name.

Parameters​

NameType
namestring

Returns​

HotRouteMethod

Defined in​

HotRoute.ts:97


createError​

â–¸ Static createError(message): any

Create an error JSON object.

Parameters​

NameType
messagestring

Returns​

any

Defined in​

HotRoute.ts:70