-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.ts
37 lines (33 loc) 路 1.12 KB
/
bootstrap.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import {Application} from './interfaces/application.interface.ts';
import {SustainServer} from './server.ts';
import {getAllModuleMetaData, executeOnServerStart} from './utils/module.helper.ts';
import {loadControllers} from './utils/http-request.helper.ts';
class BootstrapFramework {
application: Application;
mainModuleMetaData: any;
applicationRequests: any;
constructor(app: any) {
this.application = app;
this.mainModuleMetaData = getAllModuleMetaData(this.application);
const {controllers, modules} = this.mainModuleMetaData;
this.applicationRequests = loadControllers(controllers);
executeOnServerStart(modules, this.applicationRequests);
this.bootServer(this.applicationRequests, this.mainModuleMetaData);
}
bootServer(requests: any, mainModuleMetaData: any) {
const {port, staticFolders = [], extensions = {}, middleswares = []} = mainModuleMetaData;
new SustainServer(requests, {
port,
staticFolders,
extensions,
middleswares,
});
}
}
/**
* Boostratp the Application
* @param app
*/
export function bootstrap(app: any): any {
new BootstrapFramework(app);
}