Skip to content

Commit 618e316

Browse files
author
Umed Khudoiberdiev
committed
exposed settings
1 parent 02c06d8 commit 618e316

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "microframework",
33
"private": true,
4-
"version": "0.6.1",
4+
"version": "0.6.2",
55
"description": "Microframework is a minimalistic framework you can use with TypeScript and JavaScript.",
66
"license": "MIT",
77
"readmeFilename": "README.md",
@@ -36,7 +36,6 @@
3636
"gulp-shell": "^0.6.1",
3737
"gulp-tslint": "^7.1.0",
3838
"gulpclass": "0.1.2",
39-
"i": "^0.3.5",
4039
"mocha": "^3.2.0",
4140
"mysql": "^2.13.0",
4241
"npm": "^4.3.0",

sample/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ bootstrapMicroframework({
99
showBootstrapTime: true, // completely optional
1010
},
1111
modules: [
12-
winstonModule,
1312
expressModule,
13+
winstonModule,
1414
typeormModule, // comment this module if you don't have database to setup connection with
1515

1616
// here we can setup other databases, any other lib we want to setup in our application

src/Microframework.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class Microframework {
2727
* Stores all settings of modules bootstrapped by microframework.
2828
* If its undefined it means framework is not bootstrapped yet.
2929
*/
30-
private settings?: MicroframeworkSettings;
30+
private frameworkSettings?: MicroframeworkSettings;
3131

3232
// -------------------------------------------------------------------------
3333
// Public Methods
@@ -103,15 +103,26 @@ export class Microframework {
103103
* Shutdowns all modules.
104104
*/
105105
shutdown(): Promise<this> {
106-
if (!this.settings)
106+
if (!this.frameworkSettings)
107107
throw new MicroframeworkNotBootstrappedError();
108108

109-
return this.runInSequence(this.settings.getShutdownHandlers(), handler => {
109+
return this.runInSequence(this.frameworkSettings.getShutdownHandlers(), handler => {
110110
const handlerResult = handler();
111111
return handlerResult instanceof Promise ? handlerResult : Promise.resolve();
112112
}).then(() => this);
113113
}
114114

115+
/**
116+
* Returns microframework settings used and modified by bootstrapped modules.
117+
* If framework was not bootstrapped yet, this accessor will throw an error.
118+
*/
119+
get settings(): MicroframeworkSettings {
120+
if (!this.frameworkSettings)
121+
throw new MicroframeworkNotBootstrappedError();
122+
123+
return this.frameworkSettings;
124+
}
125+
115126
// -------------------------------------------------------------------------
116127
// Private Methods
117128
// -------------------------------------------------------------------------

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export * from "./Microframework";
1111
export * from "./MicroframeworkModule";
1212
export * from "./ShutdownHandler";
1313
export * from "./MicroframeworkConfig";
14+
export * from "./MicroframeworkBootstrapConfig";
1415

1516
// -------------------------------------------------------------------------
1617
// Facade functions

0 commit comments

Comments
 (0)