Methods

(async, static) buildLocals(options) → {Promise.<object>}

Build the locals object for the template rendering.

Parameters:
NameTypeDescription
optionsobject

The options for building locals

Properties
NameTypeDescription
tplstring

The template name

paramsobject

The parameters for the template

optsobject

Additional options

Returns:
  • The locals object
Type: 
Promise.<object>

(async, static) collectWebApps(glob, baseNs) → {Promise.<Array.<TWaibuWebappBoot>>}

Collect web apps by scanning for files that match the specified glob pattern. It will import the modules and gather their metadata.

Parameters:
NameTypeDescription
globstring

The glob pattern to match files

baseNsstring

The base namespace

Returns:
  • The collected web apps
Type: 
Promise.<Array.<TWaibuWebappBoot>>

(static) decorate()

Decorate the request object with additional properties and methods for handling language, translation, formatting, and settings retrieval.

(async, static) download(input, req, reply) → {Promise.<object>}

Helper to handle file download. It will set proper content-type based on file extension.

Parameters:
NameTypeDescription
inputstring | function

File path or function that returns file path. If it is a function, it will be called with this context and req as parameter

reqobject

The request object_handleNot

replyobject

The reply object

Returns:
  • The reply object
Type: 
Promise.<object>

(async, static) interceptor(name, err, req, reply) → {Promise.<any>}

Interceptor for handling errors and delegating to specific web app handlers if available.

Parameters:
NameTypeDescription
namestring

The name of the error handler to invoke

errError

The error object

reqobject

The request object

replyobject

The reply object

Returns:
  • The result of the invoked handler, if any
Type: 
Promise.<any>

(async, static) notFound(err, req, reply) → {Promise.<any>}

Handle 404 Not Found errors. It will check for a redirect route, and if found, redirect the user. If no redirect route is found, it will render a 404 error page using the specified template.

Parameters:
NameTypeDescription
errError

The error object

reqobject

The request object

replyobject

The reply object

Returns:
  • The result of the handler, if any
Type: 
Promise.<any>

(static) redirect(err, req, reply) → {object}

Handle redirection based on the error object. It will redirect to the specified path or URL.

Parameters:
NameTypeDescription
errError

The error object

reqobject

The request object

replyobject

The reply object

Returns:
  • The reply object
Type: 
object

(static) writeHtml(req, reply, tpl, payload) → {string}

Write HTML content to the reply object. It will read the template file, compile it with the provided payload, and send the resulting HTML as the response.

Parameters:
NameTypeDescription
reqobject

The request object

replyobject

The reply object

tplstring

The template file path

payloadobject

The data to be injected into the template

Returns:
  • The compiled HTML content
Type: 
string