StaticUnit

libflitter/static/StaticUnit~ StaticUnit

The static unit initializes the favicon and the static assets folder. This allows static assets to be served from Flitter from a path prefix and assumes a favicon.ico file exists.

Constructor

new StaticUnit(static_asset_diropt)

Source:

Instantiate the class. Resolves the path to the static assets.

Parameters:
Name Type Attributes Default Description
static_asset_dir string <optional>
'./app/assets'

the path to the static assets

Extends

Methods

(async) cleanup(app) → {Promise.<void>}

Source:
Inherited From:

Cleans up the unit's resources before Flitter closes.

Parameters:
Name Type Description
app module:libflitter/app/FlitterApp~FlitterApp

the Flitter app

Returns:
Type
Promise.<void>

directories() → {Object}

Source:
Overrides:

Get the directories provided by this unit. module:libflitter/static/StaticUnit~StaticUnit#static_asset_directory as "assets".

Returns:
Type
Object

(async) go(app) → {Promise.<void>}

Source:
Overrides:

Loads the unit. Configures the underlying Express app to serve files in module:libflitter/static/StaticUnit~StaticUnit#static_asset_directory on the '/assets' route. Also, configures the express-favicon package to serve the favicon.ico file in that directory.

Parameters:
Name Type Description
app module:libflitter/app/FlitterApp~FlitterApp

the Flitter app

Returns:
Type
Promise.<void>

name() → {string}

Source:
Overrides:

Get the name of the unit.

Returns:

"static"

Type
string