HotTesterAPI
hotstaq / Modules / HotTesterAPI
Class: HotTesterAPI
Hierarchy​
↳
HotTesterAPI
Table of contents​
Constructors​
Properties​
- authCredentials
- baseUrl
- connection
- createFunctions
- db
- executeEventsUsing
- onPostRegister
- onPreRegister
- routes
- userAuth
Methods​
Constructors​
constructor​
• new HotTesterAPI(baseUrl
, connection?
, db?
)
Parameters​
Name | Type | Default value |
---|---|---|
baseUrl | string | undefined |
connection | HotServer | HotClient | null |
db | any | null |
Overrides​
Defined in​
Properties​
authCredentials​
• authCredentials: any
The authorization credentials to use throughout the application.
Inherited from​
Defined in​
baseUrl​
• baseUrl: string
The base url for the server.
Inherited from​
Defined in​
connection​
• connection: HotServer
| HotClient
The server connection.
Inherited from​
Defined in​
createFunctions​
• createFunctions: boolean
If set, this will create the route variables and functions for easy client/server calling.
Inherited from​
Defined in​
db​
• db: HotDB
<any
, any
, HotDBSchema
>
The database connection.
Inherited from​
Defined in​
executeEventsUsing​
• executeEventsUsing: EventExecutionType
The database connection.
Inherited from​
Defined in​
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​
Defined in​
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​
Defined in​
routes​
• routes: Object
The database connection.
Index signature​
â–ª [name: string
]: HotRoute
Inherited from​
Defined in​
userAuth​
• userAuth: ServerAuthorizationFunction
The function used for user authentication.
Inherited from​
Defined in​
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​
Name | Type | Default value | Description |
---|---|---|---|
route | string | HotRoute | undefined | The 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. |
routeMethod | string | HotRouteMethod | null | The 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 > | null | The function to execute when routeMethod is called by the API. |
Returns​
void
Inherited from​
Defined in​
executeTests​
â–¸ executeTests(req
, res
, authorizedValue
, jsonObj
, queryObj
): Promise
<any
>
Execute the tests for a page.
Parameters​
Name | Type |
---|---|
req | any |
res | any |
authorizedValue | any |
jsonObj | any |
queryObj | any |
Returns​
Promise
<any
>
Defined in​
getDB​
â–¸ getDB(): HotDB
<any
, any
, HotDBSchema
>
Get the database being used.
Returns​
HotDB
<any
, any
, HotDBSchema
>
Inherited from​
Defined in​
getDBSchema​
â–¸ getDBSchema(): HotDBSchema
Get the database schema being used.
Returns​
Inherited from​
Defined in​
makeCall​
â–¸ makeCall(route
, data
, httpMethod?
): Promise
<any
>
Make a call to the API.
Parameters​
Name | Type | Default value |
---|---|---|
route | string | undefined |
data | any | undefined |
httpMethod | string | "POST" |
Returns​
Promise
<any
>
Inherited from​
Defined in​
pageLoaded​
â–¸ pageLoaded(req
, res
, authorizedValue
, jsonObj
, queryObj
): Promise
<any
>
This is called when the page has finished loading in development mode.
Parameters​
Name | Type |
---|---|
req | any |
res | any |
authorizedValue | any |
jsonObj | any |
queryObj | any |
Returns​
Promise
<any
>
Defined in​
registerRoute​
â–¸ registerRoute(route
): Promise
<void
>
Register a route with the server.
Parameters​
Name | Type |
---|---|
route | HotRoute |
Returns​
Promise
<void
>
Inherited from​
Defined in​
registerRoutes​
â–¸ registerRoutes(): Promise
<void
>
Register all routes with the server.
Returns​
Promise
<void
>
Inherited from​
Defined in​
setDBSchema​
â–¸ setDBSchema(schema
): void
Set the database schema for use.
Parameters​
Name | Type |
---|---|
schema | HotDBSchema |
Returns​
void