-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQG_Engine.ts
51 lines (39 loc) · 1.21 KB
/
QG_Engine.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
38
39
40
41
42
43
44
45
46
47
48
49
import express from "express";
import {RequestGroup} from './Utilities/RequestsGroup'
import {ErrorHandler} from './ErrorHandler/ErrorHandler'
import * as core from "express-serve-static-core";
const bodyParser = require('body-parser');
export class QG_Engine{
_rg :Array<RequestGroup> = [];
app:core.Application = express();
errorHandler: ErrorHandler = new ErrorHandler("ErrorHandler");
constructor()
{
console.log("initializing QG Engine...")
this.app.use(bodyParser.urlencoded({extended:false}));
this.app.use(bodyParser.json());
}
getRequestGroup(requestGroupName:string)
{
return this._rg.find(function(rg){
return rg.requestGroupName == requestGroupName;
})
}
RegisterRequestGroup(child:RequestGroup){
this._rg.push(child);
}
Initialize()
{
this._InitializeModularRequestGroups();
//Have to be at the end
this.errorHandler.Initialize(this.app);
}
_InitializeModularRequestGroups()
{
let myApp = this.app;
//console.log("RequestGroup count: "+this._rg.length)
this._rg.forEach(function(value){
value.Initialize(myApp);
})
}
}