The Static Unit


exports:  class StaticUnit

class StaticUnit

extends:  libflitter/Unit

Tells the underlying Express app to serve static requests from the specified directory and initializes the express-favicon package.

constructor(String static_assets_dir = './app/assets')

overrides:  super.constructor()         returns:  this

Initializes the class. Resolves the fully qualified directory of the static assets (static_assets_dir) and stores it in this.static_asset_directory.

go(express app, function next)

overrides:  super.go()         returns:  undefined

Tells the underlying Express app to serve this.static_asset_directory as static under the base route /assets by calling express.static. Configures the underlying Express install to use the express-favicon package to serve the favicon.ico file in this.static_asset_directory. This establishes the Static context and calls the next function in the stack under it.


returns:  Object

Returns an Object describing the services, templates, and directories provided by this unit. They are as follows:

Type Key Value Notes
Service Name name "static" The name of the service. This is added to the array so other units can check for this unit.
Directory directories.assets this.static_asset_directory The fully-qualified path of the static asset files. This is added to the _flit.directories store so other units can access it.

type:  String

Set on initialization. Specifies the the fully-qualified path of the static assets. Files in this directory are served by Express statically.

Static Context

This context guarantees that the underlying Express install is configured to serve the files in the specified assets directory with the /assets route prefix.

No Comments
Back to top