Skip to main content

HotHTTPServer

hotstaq / Modules / HotHTTPServer

Class: HotHTTPServer

A HTTP server.

Hierarchy​

Table of contents​

Constructors​

Properties​

Methods​

Constructors​

constructor​

• new HotHTTPServer(processor, httpPort?, httpsPort?)

Parameters​

NameTypeDefault value
processorHotStaq | HotServerundefined
httpPortnumbernull
httpsPortnumbernull

Overrides​

HotServer.constructor

Defined in​

HotHTTPServer.ts:100

Properties​

api​

• api: HotAPI

The API to use.

Inherited from​

HotServer.api

Defined in​

HotServer.ts:94


expressApp​

• expressApp: Express

The express app to use.

Defined in​

HotHTTPServer.ts:40


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​

NameTypeDescription
jsSrcPathstringThe JavaScript source path.
namestringThe default name for a served Hott file.
urlstringThe base url for a hott file.

Defined in​

HotHTTPServer.ts:85


httpListener​

• httpListener: Server

The HTTP listener to use.

Defined in​

HotHTTPServer.ts:44


httpsListener​

• httpsListener: Server

The HTTPS listener to use.

Defined in​

HotHTTPServer.ts:48


ignoreHottFiles​

• ignoreHottFiles: Object

Do not serve these hott files.

Index signature​

â–ª [name: string]: boolean

Defined in​

HotHTTPServer.ts:80


listenAddress​

• listenAddress: string

The network address to listen on.

Inherited from​

HotServer.listenAddress

Defined in​

HotServer.ts:98


logger​

• logger: HotLog

The logger.

Inherited from​

HotServer.logger

Defined in​

HotServer.ts:134


ports​

• ports: Object

The ports to use.

Type declaration​

NameType
httpnumber
httpsnumber

Inherited from​

HotServer.ports

Defined in​

HotServer.ts:102


processor​

• processor: HotStaq

The processor to use.

Inherited from​

HotServer.processor

Defined in​

HotServer.ts:86


redirectHTTPtoHTTPS​

• redirectHTTPtoHTTPS: boolean

Redirect HTTP traffic to HTTPS.

Inherited from​

HotServer.redirectHTTPtoHTTPS

Defined in​

HotServer.ts:126


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​

HotHTTPServer.ts:58


secrets​

• secrets: any

Any secrets associated with this server.

Inherited from​

HotServer.secrets

Defined in​

HotServer.ts:138


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​

HotHTTPServer.ts:76


serverType​

• serverType: string

The server type.

Inherited from​

HotServer.serverType

Defined in​

HotServer.ts:90


ssl​

• ssl: Object

SSL settings.

Type declaration​

NameTypeDescription
castringThe SSL certificate CA to use.
certstringThe SSL certificate to use.
keystringThe SSL certificate key to use.

Inherited from​

HotServer.ssl

Defined in​

HotServer.ts:109


staticRoutes​

• staticRoutes: StaticRoute[]

The static files and folders to serve.

Defined in​

HotHTTPServer.ts:52


type​

• type: HotServerType

The type of server.

Inherited from​

HotServer.type

Defined in​

HotServer.ts:130

Methods​

addRoute​

â–¸ addRoute(route, method, type?): void

Add a route. This will be registered before any APIs are registered.

Parameters​

NameTypeDefault value
routestringundefined
method(req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>) => Promise<void>undefined
typeHTTPMethodHTTPMethod.GET

Returns​

void

Defined in​

HotHTTPServer.ts:215


addStaticRoute​

â–¸ addStaticRoute(route, localPath?): void

Add a static route.

Parameters​

NameTypeDefault value
routestring | StaticRouteundefined
localPathstring"."

Returns​

void

Defined in​

HotHTTPServer.ts:194


clearErrorHandlingRoutes​

â–¸ clearErrorHandlingRoutes(): void

Clear the last two express routes, which are reserved for the error handlers.

Returns​

void

Defined in​

HotHTTPServer.ts:683


getStaticRoute​

â–¸ getStaticRoute(route): StaticRoute

Get a static route.

Parameters​

NameType
routestring

Returns​

StaticRoute

Defined in​

HotHTTPServer.ts:252


listen​

â–¸ listen(): Promise<void>

Start listening for requests.

Returns​

Promise<void>

Overrides​

HotServer.listen

Defined in​

HotHTTPServer.ts:711


preregisterRoute​

â–¸ preregisterRoute(): void

The routes to add before registering a route.

Returns​

void

Defined in​

HotHTTPServer.ts:440


registerRoute​

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

Register a route.

Parameters​

NameType
routeHotRoute

Returns​

Promise<void>

Overrides​

HotServer.registerRoute

Defined in​

HotHTTPServer.ts:274


registerStaticRoute​

â–¸ registerStaticRoute(route): void

Register a static route with Express.

Parameters​

NameType
routeStaticRoute

Returns​

void

Defined in​

HotHTTPServer.ts:238


serveDirectory​

â–¸ serveDirectory(route, localPath?): void

Serve a directory. This is an alias for addStaticRoute.

Parameters​

NameTypeDefault value
routestring | StaticRouteundefined
localPathstring"."

Returns​

void

Defined in​

HotHTTPServer.ts:230


setAPI​

â–¸ setAPI(api): Promise<void>

Set an API to this server. This will also set the associated processor to this API as well.

Parameters​

NameType
apiHotAPI

Returns​

Promise<void>

Inherited from​

HotServer.setAPI

Defined in​

HotServer.ts:188


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​

NameTypeDefault value
handle404(req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: any) => voidnull
handleOther(err: any, req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: any) => voidnull

Returns​

void

Defined in​

HotHTTPServer.ts:643


shutdown​

â–¸ shutdown(): Promise<void>

Shutdown the server.

Returns​

Promise<void>

Overrides​

HotServer.shutdown

Defined in​

HotHTTPServer.ts:937


checkIfFileExists​

â–¸ Static checkIfFileExists(filepath): Promise<boolean>

Check if a file exists.

Parameters​

NameType
filepathstring

Returns​

Promise<boolean>

Defined in​

HotHTTPServer.ts:423


getFileUploads​

â–¸ Static getFileUploads(req, options?): Promise<Files>

Get all files uploaded.

Parameters​

NameType
reqRequest<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
optionsany

Returns​

Promise<Files>

Defined in​

HotHTTPServer.ts:622


startServer​

â–¸ Static startServer(localStaticPath?, httpPort?, httpsPort?, processor?): Promise<{ processor: HotStaq | HotServer ; server: HotHTTPServer }>

Start the server.

Parameters​

NameTypeDefault valueDescription
localStaticPathstring | StaticRoute[]nullThe public path that contains the HTML, Hott files, images, and all public content. This can also be an array of StaticRoutes.
httpPortnumber80The HTTP port to listen on .
httpsPortnumber443The HTTPS port to listen on.
processorHotStaq | HotServernullThe HotStaq or parent server being used for communication.

Returns​

Promise<{ processor: HotStaq | HotServer ; server: HotHTTPServer }>

Defined in​

HotHTTPServer.ts:904