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)

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

Members

(static) name

Get the name of the service provided by this unit: 'static'

(private) _di_allow_defer :boolean

If true, the injector will defer the class if the class requests any services that the container is missing. These services are filled in later and added to the prototype and any instances. True by default.

Type:
  • boolean

(private) _di_deferred_instances :Array.<module:flitter-di/src/Injectable~Injectable>

Collection of instances of this class that need to have the deferred service instances injected into them when the deferred services are finally provided.

(private) _di_deferred_services :Array.<string>

List of services that were deferred and not provided at the time of injection.

Type:
  • Array.<string>

Methods

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

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}

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>}

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}

Get the name of the unit. Should be a lowercase, alphanum/dash/underscore string.

Returns:
Type
String

status(setopt) → {string}

Get or set the unit's current status.

Parameters:
Name Type Attributes Description
set string <optional>

if provided, set the status of the unit

Returns:
  • current status of the unit
Type
string