Methods
(async, static) buildLocals(options) → {Promise.<object>}
Build the locals object for the template rendering.
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | object | The options for building locals Properties
|
- Source
- 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.
| Name | Type | Description |
|---|---|---|
glob | string | The glob pattern to match files |
baseNs | string | The base namespace |
- Source
- 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.
- Source
(async, static) download(input, req, reply) → {Promise.<object>}
Helper to handle file download. It will set proper content-type based on file extension.
| Name | Type | Description |
|---|---|---|
input | string | | File path or function that returns file path. If it is a function, it will be called with |
req | object | The request object_handleNot |
reply | object | The reply object |
- Source
- 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.
| Name | Type | Description |
|---|---|---|
name | string | The name of the error handler to invoke |
err | Error | The error object |
req | object | The request object |
reply | object | The reply object |
- Source
- 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.
| Name | Type | Description |
|---|---|---|
err | Error | The error object |
req | object | The request object |
reply | object | The reply object |
- Source
- 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.
| Name | Type | Description |
|---|---|---|
err | Error | The error object |
req | object | The request object |
reply | object | The reply object |
- Source
- 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.
| Name | Type | Description |
|---|---|---|
req | object | The request object |
reply | object | The reply object |
tpl | string | The template file path |
payload | object | The data to be injected into the template |
- Source
- The compiled HTML content
- Type:
- string