Abstract
Protected
appThe base path directory where the canonical definitions reside.
Protected
Readonly
canonProtected
canonicalThe singular, programmatic name of one of these canonical items.
middleware
Protected
loadedObject mapping canonical names to loaded file references.
Protected
loadedObject mapping canonical namespaces to resolver functions.
Protected
Readonly
loggingThe current status of the unit.
Protected
suffixThe file suffix of files in the base path that should be loaded.
This should EXCLUDE .js
or .ts
. These file extensions are determined
by the framework depending on the Node runtime.
.service
.middleware
Private
appThe global application instance.
Get the plural name of the canonical items provided by this unit.
Get a Universal path to the base directory where this unit loads its canonical files from.
Protected
appGet the global Application.
Protected
buildProtected
Given the path to a file in the canonical items directory, create a CanonicalDefinition record from that file.
Optional
basePath: UniversalPathProtected
containerThis method is called to stop the unit when the application is shutting down. Here, you should do any teardown required to stop the package cleanly.
IN PARTICULAR take care to free blocking resources that could prevent the process from exiting without a kill.
Get the method with the given name from this class, bound to this class.
function
Get the method with the given name from this class, bound to this class.
function
Rest
...args: any[]Called for each canonical item loaded from a file. This function should do any setup necessary and return the item that should be associated with the canonical name.
Protected
makeRegister a namespace resolver with the canonical unit.
Namespaces are canonical names that start with a particular key, beginning with the @
character,
which resolve their resources using a resolver function.
const items = {
'foo:bar': 123,
'bob': 456,
}
const resolver = (key: string) => items[key]
canonical.registerNamespace('@mynamespace', resolver)
Now, the items in the @mynamespace
namespace can be accessed like so:
canonical.get('@mynamespace:foo:bar') // => 123
canonical.get('@mynamespace:bob') // => 456
Static
resolveResolve a canonical reference from its string form to a CanonicalReference.
CanonicalReference
Abstract unit type that loads items recursively from a directory structure, assigning them normalized names ("canonical names"), and providing a way to fetch the resources by name.
Example
The Config service is a Canonical derivative that loads files ending with
.config.js
from theapp/config
directory.If, for example, there is a config file
app/config/auth/Forms.config.js
(in the generated code), it can be loaded by the canonical nameauth:Forms
.