HotTesterServer
hotstaq / Modules / HotTesterServer
Class: HotTesterServer
An API server for use during testing.
Hierarchy​
↳
HotTesterServer
Table of contents​
Constructors​
Properties​
- api
- expressApp
- httpListener
- httpsListener
- listenAddress
- logger
- ports
- processor
- redirectHTTPtoHTTPS
- routes
- secrets
- serverType
- ssl
- type
Methods​
- addRoute
- addTester
- clearErrorHandlingRoutes
- executeAllAPITests
- executeAllWebTests
- executeTests
- listen
- preregisterRoute
- registerRoute
- setAPI
- setErrorHandlingRoutes
- setupTesterAPI
- shutdown
- checkIfFileExists
- startServer
Constructors​
constructor​
• new HotTesterServer(processor
, httpPort?
, httpsPort?
)
Parameters​
Name | Type | Default value |
---|---|---|
processor | HotStaq | HotServer | undefined |
httpPort | number | null |
httpsPort | number | null |
Overrides​
Defined in​
Properties​
api​
• api: HotAPI
The API to use.
Inherited from​
Defined in​
expressApp​
• expressApp: Express
The express app to use.
Defined in​
httpListener​
• httpListener: Server
The HTTP listener to use.
Defined in​
httpsListener​
• httpsListener: Server
The HTTPS listener to use.
Defined in​
listenAddress​
• listenAddress: string
The network address to listen on.
Inherited from​
Defined in​
logger​
• logger: HotLog
The logger.
Inherited from​
Defined in​
ports​
• ports: Object
The ports to use.
Type declaration​
Name | Type |
---|---|
http | number |
https | number |
Inherited from​
Defined in​
processor​
• processor: HotStaq
The processor to use.
Inherited from​
Defined in​
redirectHTTPtoHTTPS​
• redirectHTTPtoHTTPS: boolean
Redirect HTTP traffic to HTTPS.
Inherited from​
Defined in​
routes​
• routes: { route
: string
; type
: HTTPMethod
; method
: (req
: Request
<ParamsDictionary
, any
, any
, ParsedQs
, Record
<string
, any
>>, res
: Response
<any
, Record
<string
, any
>>) => Promise
<void
> }[]
Any non-static routes that need to be added. These will be added during the preregistration phase, before all API routes are added.
Defined in​
secrets​
• secrets: any
Any secrets associated with this server.
Inherited from​
Defined in​
serverType​
• serverType: string
The server type.
Inherited from​
Defined in​
ssl​
• ssl: Object
SSL settings.
Type declaration​
Name | Type | Description |
---|---|---|
ca | string | The SSL certificate CA to use. |
cert | string | The SSL certificate to use. |
key | string | The SSL certificate key to use. |
Inherited from​
Defined in​
type​
• type: HotServerType
The type of server.
Inherited from​
Defined in​
Methods​
addRoute​
â–¸ addRoute(route
, method
, type?
): void
Add a route. This will be registered before any APIs are registered.
Parameters​
Name | Type | Default value |
---|---|---|
route | string | undefined |
method | (req : Request <ParamsDictionary , any , any , ParsedQs , Record <string , any >>, res : Response <any , Record <string , any >>) => Promise <void > | undefined |
type | HTTPMethod | HTTPMethod.GET |
Returns​
void
Defined in​
addTester​
â–¸ addTester(tester
): void
Add a tester for use later.
Parameters​
Name | Type |
---|---|
tester | HotTester |
Returns​
void
Defined in​
clearErrorHandlingRoutes​
â–¸ clearErrorHandlingRoutes(): void
Clear the last two express routes, which are reserved for the error handlers.
Returns​
void
Defined in​
executeAllAPITests​
â–¸ executeAllAPITests(testerName
): Promise
<void
>
Execute all api tests for all maps in the HotSite testing api object.
Parameters​
Name | Type |
---|---|
testerName | string |
Returns​
Promise
<void
>
Defined in​
executeAllWebTests​
â–¸ executeAllWebTests(testerName
): Promise
<void
>
Execute all web tests for all maps in the HotSite testing web object.
Parameters​
Name | Type |
---|---|
testerName | string |
Returns​
Promise
<void
>
Defined in​
executeTests​
â–¸ executeTests(testerName
, mapName
): Promise
<void
>
Execute tests.
Parameters​
Name | Type |
---|---|
testerName | string |
mapName | string |
Returns​
Promise
<void
>
Defined in​
listen​
â–¸ listen(): Promise
<void
>
Start listening for requests.
Returns​
Promise
<void
>
Overrides​
Defined in​
preregisterRoute​
â–¸ preregisterRoute(): void
The routes to add before registering a route.
Returns​
void
Defined in​
registerRoute​
â–¸ registerRoute(route
): Promise
<void
>
Register a route.
Parameters​
Name | Type |
---|---|
route | HotRoute |
Returns​
Promise
<void
>
Overrides​
Defined in​
setAPI​
â–¸ setAPI(api
): Promise
<void
>
Set an API to this server. This will also set the associated processor to this API as well.
Parameters​
Name | Type |
---|---|
api | HotAPI |
Returns​
Promise
<void
>
Inherited from​
Defined in​
setErrorHandlingRoutes​
â–¸ setErrorHandlingRoutes(handle404?
, handleOther?
): void
Set the error handlers. This will create two express routes at the bottom of the route stack. The first will be to capture any 404 errors, the second would be to catch any remaining errors.
Parameters​
Name | Type | Default value |
---|---|---|
handle404 | (req : Request <ParamsDictionary , any , any , ParsedQs , Record <string , any >>, res : Response <any , Record <string , any >>, next : any ) => void | null |
handleOther | (err : any , req : Request <ParamsDictionary , any , any , ParsedQs , Record <string , any >>, res : Response <any , Record <string , any >>, next : any ) => void | null |
Returns​
void
Defined in​
setupTesterAPI​
â–¸ setupTesterAPI(baseUrl
): Promise
<void
>
Setup the tester api.
Parameters​
Name | Type |
---|---|
baseUrl | string |
Returns​
Promise
<void
>
Defined in​
shutdown​
â–¸ shutdown(): Promise
<void
>
Shutdown the server.
Returns​
Promise
<void
>
Overrides​
Defined in​
checkIfFileExists​
â–¸ Static
checkIfFileExists(filepath
): Promise
<boolean
>
Check if a file exists.
Parameters​
Name | Type |
---|---|
filepath | string |
Returns​
Promise
<boolean
>
Defined in​
startServer​
â–¸ Static
startServer(baseUrl?
, httpPort?
, httpsPort?
, processor?
, logLevel?
): Promise
<{ processor
: HotStaq
| HotServer
; server
: HotTesterServer
}>
Start the server.
Parameters​
Name | Type | Default value | Description |
---|---|---|---|
baseUrl | string | undefined | - |
httpPort | number | 8182 | The HTTP port to listen on. |
httpsPort | number | 4142 | The HTTPS port to listen on. |
processor | HotStaq | HotServer | null | The HotStaq or parent server being used for communication. |
logLevel | HotLogLevel | HotLogLevel.Info | - |
Returns​
Promise
<{ processor
: HotStaq
| HotServer
; server
: HotTesterServer
}>