@@ -10,18 +10,47 @@ An Extensible Config & Logging Application Bootstrap Function
10
10
<a name =" intro " >Introduction</a >
11
11
--------------------------------
12
12
An opinionated application config and logging bootstrap that streamlines the use of the
13
- - [ @alt-javascript/config ] ( https://www.npmjs.com/package/@alt-javascript/config ) , and
14
- - [ @alt-javascript/logger ] ( https://www.npmjs.com/package/@alt-javascript/logger )
13
+ - [ @alt-javascript/config ] ( https://www.npmjs.com/package/@alt-javascript/config ) ,
14
+ - [ @alt-javascript/logger ] ( https://www.npmjs.com/package/@alt-javascript/logger ) , and
15
+ - [ @alt-javascript/cdi ] ( https://www.npmjs.com/package/@alt-javascript/cdi )
15
16
17
+ The ` Application ` class implements a familiar application context and dependency injection
18
+ (cdi) implementation, supporting simple singleton and prototype component factory definitions, with a choice of
19
+ manual or auto wiring (injection) of property references and config placeholders.
16
20
17
- The boot function binds a global root context with configured LoggerFactory
21
+ The ` Application ` class extends the standalone ` boot ` function, which binds a global root context with configured LoggerFactory
18
22
to negate the need for requiring and injecting the application config in every module, and optionally the ` node-fetch `
19
23
implementation for config pulled from a service url.
20
-
24
+
25
+ The ` config ` , ` loggerFactory ` , ` LoggerCategoryCache ` are registered as injectable singleton components, and the ` logger `
26
+ is an injectable prototype. See the [ @alt-javascript/cdi ] ( https://www.npmjs.com/package/@alt-javascript/cdi ) package for more
27
+ detail on how the dependency injection works.
28
+
21
29
<a name =" usage " >Usage</a >
22
30
-------------------------
23
31
24
- To use the module, substitute the named {config} module export, in place of the popular
32
+ The following example bootstraps an Application with an EmphemeraConfig (but could easily be a regular config
33
+ or alt-javascript/config instance), with a basic config context component definition.
34
+
35
+ ``` javascript
36
+ const ephemeralConfig = new EphemeralConfig (
37
+ {
38
+ context: {
39
+ SimpleClass: {
40
+ require: ' ./test/service/SimpleClass' ,
41
+ },
42
+ },
43
+ },
44
+ );
45
+
46
+ const applicationContext = Application .run ({ config: ephemeralConfig });
47
+
48
+ const simpleClass = applicationContext .get (' simpleClass' );
49
+ assert .exists (simpleClass, ' simpleClass exists' );
50
+
51
+ ```
52
+
53
+ To use the module boot function standalone, substitute the named {config} module export, in place of the popular
25
54
[ config] ( https://www.npmjs.com/package/config ) default, and ` boot ` it &ndash ; note, we use a named export for config,
26
55
because the module exports other useful classes as well.
27
56
0 commit comments