@@ -18,6 +18,11 @@ export class Microframework {
1818 */
1919 private frameworkConfig ?: MicroframeworkConfig ;
2020
21+ /**
22+ * Stores configurations from all configuration files provided to microframework.
23+ */
24+ private allConfiguration : any = { } ;
25+
2126 /**
2227 * Stores all registered microframework loaders.
2328 */
@@ -36,8 +41,23 @@ export class Microframework {
3641 /**
3742 * Configs microframework.
3843 */
39- config ( config : MicroframeworkConfig ) : this {
40- this . frameworkConfig = config ;
44+ config ( config : MicroframeworkConfig | string | string [ ] ) : this {
45+
46+ const appRootDir = require ( "app-root-path" ) . path ;
47+ if ( config instanceof String ) {
48+ this . allConfiguration = require ( appRootDir + "/" + config + ".json" ) || { } ;
49+ if ( this . allConfiguration . microframework )
50+ this . frameworkConfig = this . allConfiguration . microframework ;
51+
52+ } else if ( config instanceof Array ) { // string[]
53+ if ( config . length > 0 ) {
54+ this . allConfiguration = { } ;
55+ Object . assign ( this . allConfiguration , ...config . map ( conf => require ( appRootDir + "/" + conf + ".json" ) || { } ) ) ;
56+ }
57+ } else {
58+ this . frameworkConfig = config ;
59+ }
60+
4161 return this ;
4262 }
4363
@@ -77,7 +97,7 @@ export class Microframework {
7797 * Bootstraps microframework and loads all loaders.
7898 */
7999 bootstrap ( ) : Promise < this> {
80- const settings = new MicroframeworkSettings ( ) ;
100+ const settings = new MicroframeworkSettings ( this . allConfiguration ) ;
81101 const bootstrapTime = + new Date ( ) ;
82102
83103 return this . generateLogo ( )
0 commit comments