Skip to main content

HotTesterAPI

hotstaq / Modules / HotTesterAPI

Class: HotTesterAPI

Hierarchy​

Table of contents​

Constructors​

Properties​

Methods​

Constructors​

constructor​

• new HotTesterAPI(baseUrl, connection?, db?)

Parameters​

NameTypeDefault value
baseUrlstringundefined
connectionHotServer | HotClientnull
dbanynull

Overrides​

HotAPI.constructor

Defined in​

HotTesterAPI.ts:11

Properties​

authCredentials​

• authCredentials: any

The authorization credentials to use throughout the application.

Inherited from​

HotAPI.authCredentials

Defined in​

HotAPI.ts:58


baseUrl​

• baseUrl: string

The base url for the server.

Inherited from​

HotAPI.baseUrl

Defined in​

HotAPI.ts:41


connection​

• connection: HotServer | HotClient

The server connection.

Inherited from​

HotAPI.connection

Defined in​

HotAPI.ts:37


createFunctions​

• createFunctions: boolean

If set, this will create the route variables and functions for easy client/server calling.

Inherited from​

HotAPI.createFunctions

Defined in​

HotAPI.ts:46


db​

• db: HotDB<any, any, HotDBSchema>

The database connection.

Inherited from​

HotAPI.db

Defined in​

HotAPI.ts:54


executeEventsUsing​

• executeEventsUsing: EventExecutionType

The database connection.

Inherited from​

HotAPI.executeEventsUsing

Defined in​

HotAPI.ts:50


onPostRegister​

• onPostRegister: () => Promise<boolean>

Type declaration​

â–¸ (): Promise<boolean>

Executed when the API has finished registering routes. If this function returns false, the server will not start.

Returns​

Promise<boolean>

Inherited from​

HotAPI.onPostRegister

Defined in​

HotAPI.ts:76


onPreRegister​

• onPreRegister: () => Promise<boolean>

Type declaration​

â–¸ (): Promise<boolean>

Executed when the API is about to start registering routes. If this function returns false, the server will not start.

Returns​

Promise<boolean>

Inherited from​

HotAPI.onPreRegister

Defined in​

HotAPI.ts:71


routes​

• routes: Object

The database connection.

Index signature​

â–ª [name: string]: HotRoute

Inherited from​

HotAPI.routes

Defined in​

HotAPI.ts:66


userAuth​

• userAuth: ServerAuthorizationFunction

The function used for user authentication.

Inherited from​

HotAPI.userAuth

Defined in​

HotAPI.ts:62

Methods​

addRoute​

â–¸ addRoute(route, routeMethod?, executeFunction?): void

Add a route. If this.createFunctions is set to true, this will take the incoming route and create an object in this HotAPI object using the name of the route. If there's any HotRouteMethods inside of the incoming HotRoute, it will create the methods and attach them to the newly created HotRoute object.

Example:

export class Users extends HotRoute
{
constructor (api: FreeLightAPI)
{
super (api.connection, "user");

this.addMethod ("create", this._create, HTTPMethod.POST);
}

protected async _create (req: any, res: any, authorizedValue: any, jsonObj: any, queryObj: any): Promise<any>
{
return (true);
}
}

This in turn could be used like so:

Hot.API.user.create ({});

Additionally it would create the endpoint: http://127.0.0.1:8080/v1/user/create

Parameters​

NameTypeDefault valueDescription
routestring | HotRouteundefinedThe route to add. Can be either a full HotRoute object, or just the route's name. If a HotRoute object is supplied, the rest of the parameters will be ignored.
routeMethodstring | HotRouteMethodnullThe route's method to add. If the route parameter is a string, it will be interpreted as the route's name, and this will be the method added to the new route.
executeFunction(req: any, res: any, authorizedValue: any, jsonObj: any, queryObj: any) => Promise<any>nullThe function to execute when routeMethod is called by the API.

Returns​

void

Inherited from​

HotAPI.addRoute

Defined in​

HotAPI.ts:167


executeTests​

â–¸ executeTests(req, res, authorizedValue, jsonObj, queryObj): Promise<any>

Execute the tests for a page.

Parameters​

NameType
reqany
resany
authorizedValueany
jsonObjany
queryObjany

Returns​

Promise<any>

Defined in​

HotTesterAPI.ts:104


getDB​

â–¸ getDB(): HotDB<any, any, HotDBSchema>

Get the database being used.

Returns​

HotDB<any, any, HotDBSchema>

Inherited from​

HotAPI.getDB

Defined in​

HotAPI.ts:109


getDBSchema​

â–¸ getDBSchema(): HotDBSchema

Get the database schema being used.

Returns​

HotDBSchema

Inherited from​

HotAPI.getDBSchema

Defined in​

HotAPI.ts:120


makeCall​

â–¸ makeCall(route, data, httpMethod?): Promise<any>

Make a call to the API.

Parameters​

NameTypeDefault value
routestringundefined
dataanyundefined
httpMethodstring"POST"

Returns​

Promise<any>

Inherited from​

HotAPI.makeCall

Defined in​

HotAPI.ts:343


pageLoaded​

â–¸ pageLoaded(req, res, authorizedValue, jsonObj, queryObj): Promise<any>

This is called when the page has finished loading in development mode.

Parameters​

NameType
reqany
resany
authorizedValueany
jsonObjany
queryObjany

Returns​

Promise<any>

Defined in​

HotTesterAPI.ts:26


registerRoute​

â–¸ registerRoute(route): Promise<void>

Register a route with the server.

Parameters​

NameType
routeHotRoute

Returns​

Promise<void>

Inherited from​

HotAPI.registerRoute

Defined in​

HotAPI.ts:321


registerRoutes​

â–¸ registerRoutes(): Promise<void>

Register all routes with the server.

Returns​

Promise<void>

Inherited from​

HotAPI.registerRoutes

Defined in​

HotAPI.ts:330


setDBSchema​

â–¸ setDBSchema(schema): void

Set the database schema for use.

Parameters​

NameType
schemaHotDBSchema

Returns​

void

Inherited from​

HotAPI.setDBSchema

Defined in​

HotAPI.ts:95