Skip to content

Commit 02c06d8

Browse files
author
Umed Khudoiberdiev
committed
renamed bootstrap settings to simply settings
1 parent 4c48e43 commit 02c06d8

File tree

12 files changed

+34
-32
lines changed

12 files changed

+34
-32
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ npm i microframework
1414
Second, create a simple "module" named `expressModule`:
1515

1616
```typescript
17-
import {MicroframeworkBootstrapSettings} from "microframework";
17+
import {MicroframeworkSettings} from "microframework";
1818

19-
export function expressModule(settings: MicroframeworkBootstrapSettings) {
19+
export function expressModule(settings: MicroframeworkSettings) {
2020

2121
// create express app
2222
const app = express();
@@ -83,9 +83,9 @@ For such purpose you can store the data in `settings` object passed to each modu
8383
and use stored data across all other modules. For example:
8484

8585
```typescript
86-
import {MicroframeworkBootstrapSettings} from "microframework";
86+
import {MicroframeworkSettings} from "microframework";
8787

88-
export function expressModule(settings: MicroframeworkBootstrapSettings) {
88+
export function expressModule(settings: MicroframeworkSettings) {
8989

9090
// create express app
9191
const app = express();
@@ -104,9 +104,9 @@ export function expressModule(settings: MicroframeworkBootstrapSettings) {
104104
And another modules can use data this way:
105105

106106
```typescript
107-
import {MicroframeworkBootstrapSettings} from "microframework";
107+
import {MicroframeworkSettings} from "microframework";
108108

109-
export function socketIoModule(settings: MicroframeworkBootstrapSettings) {
109+
export function socketIoModule(settings: MicroframeworkSettings) {
110110
const io = io();
111111
io.useExpress(settings.getData("express_app"));
112112
}
@@ -145,7 +145,7 @@ bootstrapMicroframework({
145145
All modules which use resources should release them, for example:
146146

147147
```typescript
148-
export async function typeormModule(settings: MicroframeworkBootstrapSettings) {
148+
export async function typeormModule(settings: MicroframeworkSettings) {
149149
const connection = await createConnection({
150150
driver: {
151151
type: "mysql",
@@ -156,6 +156,6 @@ export async function typeormModule(settings: MicroframeworkBootstrapSettings) {
156156
}
157157
});
158158

159-
settings.addShutdownHandler(() => connection.close());
159+
settings.onShutdown(() => connection.close());
160160
}
161161
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "microframework",
33
"private": true,
4-
"version": "0.6.0",
4+
"version": "0.6.1",
55
"description": "Microframework is a minimalistic framework you can use with TypeScript and JavaScript.",
66
"license": "MIT",
77
"readmeFilename": "README.md",

sample/app.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {bootstrapMicroframework} from "../src/index";
2-
import {expressModule} from "./framework/expressModule";
3-
import {typeormModule} from "./framework/typeormModule";
4-
import {winstonModule} from "./framework/winstonModule";
2+
import {expressModule} from "./modules/expressModule";
3+
import {typeormModule} from "./modules/typeormModule";
4+
import {winstonModule} from "./modules/winstonModule";
55

66
bootstrapMicroframework({
77
config: { // completely optional

sample/framework/expressModule.ts renamed to sample/modules/expressModule.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as express from "express";
2-
import {MicroframeworkBootstrapSettings} from "../../src/MicroframeworkBootstrapSettings";
2+
import {MicroframeworkSettings} from "../../src/MicroframeworkSettings";
33
import {Routes} from "../controllers/controllers";
44

5-
export function expressModule(settings: MicroframeworkBootstrapSettings) {
5+
export function expressModule(settings: MicroframeworkSettings) {
66

77
// create express app
88
const app = express();
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {createConnection} from "typeorm";
2-
import {MicroframeworkBootstrapSettings} from "../../src/MicroframeworkBootstrapSettings";
2+
import {MicroframeworkSettings} from "../../src/MicroframeworkSettings";
33

4-
export async function typeormModule(settings: MicroframeworkBootstrapSettings) {
4+
export async function typeormModule(settings: MicroframeworkSettings) {
55
const connection = await createConnection({
66
driver: {
77
type: "mysql",
@@ -12,5 +12,5 @@ export async function typeormModule(settings: MicroframeworkBootstrapSettings) {
1212
}
1313
});
1414

15-
settings.addShutdownHandler(() => connection.close());
15+
settings.onShutdown(() => connection.close());
1616
}

sample/framework/winstonModule.ts renamed to sample/modules/winstonModule.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import {MicroframeworkBootstrapSettings} from "../../src/MicroframeworkBootstrapSettings";
1+
import {MicroframeworkSettings} from "../../src/MicroframeworkSettings";
22
const winston = require("winston");
33

4-
export function winstonModule(settings: MicroframeworkBootstrapSettings) {
4+
export function winstonModule(settings: MicroframeworkSettings) {
55
winston.configure({
66
transports: [
77
new winston.transports.File({

src/Microframework.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {MicroframeworkBootstrapSettings} from "./MicroframeworkBootstrapSettings";
1+
import {MicroframeworkSettings} from "./MicroframeworkSettings";
22
import {MicroframeworkModule} from "./MicroframeworkModule";
33
import {MicroframeworkConfig} from "./MicroframeworkConfig";
44
import {MicroframeworkNotBootstrappedError} from "./error/MicroframeworkNotBootstrappedError";
@@ -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?: MicroframeworkBootstrapSettings;
30+
private settings?: MicroframeworkSettings;
3131

3232
// -------------------------------------------------------------------------
3333
// Public Methods
@@ -77,7 +77,7 @@ export class Microframework {
7777
* Bootstraps all modules.
7878
*/
7979
bootstrap(): Promise<this> {
80-
const settings = new MicroframeworkBootstrapSettings();
80+
const settings = new MicroframeworkSettings();
8181
const bootstrapTime = +new Date();
8282

8383
return this.generateLogo()

src/MicroframeworkConfig.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export interface MicroframeworkConfig {
66
/**
77
* Logo needs to be used before application launches.
88
* To use logo ansi-art module should be installed.
9+
*
10+
* @experimental
911
*/
1012
logo?: string;
1113

src/MicroframeworkModule.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import {MicroframeworkBootstrapSettings} from "./MicroframeworkBootstrapSettings";
1+
import {MicroframeworkSettings} from "./MicroframeworkSettings";
22

33
/**
44
* Microframework module is some functionality needs to be executed in order.
55
*/
66
export interface MicroframeworkModule {
7-
(options?: MicroframeworkBootstrapSettings): Promise<any>|any;
7+
(options?: MicroframeworkSettings): Promise<any>|any;
88
}

src/MicroframeworkBootstrapSettings.ts renamed to src/MicroframeworkSettings.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import {MicroframeworkShutdownHandler} from "./MicroframeworkShutdownHandler";
1+
import {ShutdownHandler} from "./ShutdownHandler";
22

33
/**
44
* Bootstrap settings used across all modules.
55
* Used to register shutdown handlers - special functions that will be executed when framework is shutdown.
66
* Also can be used to store and share data across modules.
77
*/
8-
export class MicroframeworkBootstrapSettings {
8+
export class MicroframeworkSettings {
99

1010
// -------------------------------------------------------------------------
1111
// Private Properties
@@ -19,7 +19,7 @@ export class MicroframeworkBootstrapSettings {
1919
/**
2020
* Special functions that will be executed when framework is shutdown.
2121
*/
22-
private shutdownHandlers: MicroframeworkShutdownHandler[] = [];
22+
private shutdownHandlers: ShutdownHandler[] = [];
2323

2424
// -------------------------------------------------------------------------
2525
// Public Methods
@@ -43,15 +43,15 @@ export class MicroframeworkBootstrapSettings {
4343
/**
4444
* Adds a shutdown handler - special function that will be executed when framework is shutdown.
4545
*/
46-
addShutdownHandler(handler: MicroframeworkShutdownHandler): this {
46+
onShutdown(handler: ShutdownHandler): this {
4747
this.shutdownHandlers.push(handler);
4848
return this;
4949
}
5050

5151
/**
5252
* Gets all shutdown handlers - special functions that will be executed when framework is shutdown.
5353
*/
54-
getShutdownHandlers(): MicroframeworkShutdownHandler[] {
54+
getShutdownHandlers(): ShutdownHandler[] {
5555
return this.shutdownHandlers.map(handlers => handlers);
5656
}
5757

0 commit comments

Comments
 (0)