HotHTTPServer
hotstaq / Modules / HotHTTPServer
Class: HotHTTPServer
A HTTP server.
Hierarchy​
↳
HotHTTPServer
Table of contents​
Constructors​
Properties​
- api
- expressApp
- hottFilesAssociatedInfo
- httpListener
- httpsListener
- ignoreHottFiles
- listenAddress
- logger
- ports
- processor
- redirectHTTPtoHTTPS
- routes
- secrets
- serveHottFiles
- serverType
- ssl
- staticRoutes
- type
Methods​
- addRoute
- addStaticRoute
- clearErrorHandlingRoutes
- getStaticRoute
- listen
- preregisterRoute
- registerRoute
- registerStaticRoute
- serveDirectory
- setAPI
- setErrorHandlingRoutes
- shutdown
- checkIfFileExists
- getFileUploads
- startServer
Constructors​
constructor​
• new HotHTTPServer(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​
hottFilesAssociatedInfo​
• hottFilesAssociatedInfo: Object
The associated info with any hott files served. All values here will be overwritten by whatever values are set in the server object in HotSite.json.
Type declaration​
Name | Type | Description |
---|---|---|
jsSrcPath | string | The JavaScript source path. |
name | string | The default name for a served Hott file. |
url | string | The base url for a hott file. |
Defined in​
httpListener​
• httpListener: Server
The HTTP listener to use.
Defined in​
httpsListener​
• httpsListener: Server
The HTTPS listener to use.
Defined in​
ignoreHottFiles​
• ignoreHottFiles: Object
Do not serve these hott files.
Index signature​
â–ª [name: string
]: boolean
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​
serveHottFiles​
• serveHottFiles: boolean
Serve hott files when requested. This value will be overwritten by whatever value is set to server.serveHottFiles in HotSite.json.
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​
staticRoutes​
• staticRoutes: StaticRoute
[]
The static files and folders to serve.
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​
addStaticRoute​
â–¸ addStaticRoute(route
, localPath?
): void
Add a static route.
Parameters​
Name | Type | Default value |
---|---|---|
route | string | StaticRoute | undefined |
localPath | string | "." |
Returns​
void
Defined in​
clearErrorHandlingRoutes​
â–¸ clearErrorHandlingRoutes(): void
Clear the last two express routes, which are reserved for the error handlers.
Returns​
void
Defined in​
getStaticRoute​
â–¸ getStaticRoute(route
): StaticRoute
Get a static route.
Parameters​
Name | Type |
---|---|
route | string |
Returns​
StaticRoute
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​
registerStaticRoute​
â–¸ registerStaticRoute(route
): void
Register a static route with Express.
Parameters​
Name | Type |
---|---|
route | StaticRoute |
Returns​
void
Defined in​
serveDirectory​
â–¸ serveDirectory(route
, localPath?
): void
Serve a directory. This is an alias for addStaticRoute.
Parameters​
Name | Type | Default value |
---|---|---|
route | string | StaticRoute | undefined |
localPath | string | "." |
Returns​
void
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​
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​
getFileUploads​
â–¸ Static
getFileUploads(req
, options?
): Promise
<Files
>
Get all files uploaded.
Parameters​
Name | Type |
---|---|
req | Request <ParamsDictionary , any , any , ParsedQs , Record <string , any >> |
options | any |
Returns​
Promise
<Files
>
Defined in​
startServer​
â–¸ Static
startServer(localStaticPath?
, httpPort?
, httpsPort?
, processor?
): Promise
<{ processor
: HotStaq
| HotServer
; server
: HotHTTPServer
}>
Start the server.
Parameters​
Name | Type | Default value | Description |
---|---|---|---|
localStaticPath | string | StaticRoute [] | null | The public path that contains the HTML, Hott files, images, and all public content. This can also be an array of StaticRoutes. |
httpPort | number | 80 | The HTTP port to listen on . |
httpsPort | number | 443 | The HTTPS port to listen on. |
processor | HotStaq | HotServer | null | The HotStaq or parent server being used for communication. |
Returns​
Promise
<{ processor
: HotStaq
| HotServer
; server
: HotHTTPServer
}>