mastercontroller 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/MasterControl.js +25 -2
  2. package/package.json +1 -1
package/MasterControl.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // MasterControl - by Alexander rich
2
- // version 1.0.21
2
+ // version 1.0.22
3
3
 
4
4
  var url = require('url');
5
5
  var fileserver = require('fs');
@@ -19,6 +19,7 @@ class MasterControl {
19
19
  _environmentType = null
20
20
  _serverProtocol = null
21
21
  _scopedList = []
22
+ _loadedFunc = null
22
23
 
23
24
  #loadTransientListClasses(name, params){
24
25
  Object.defineProperty(this.requestList, name, {
@@ -70,6 +71,12 @@ class MasterControl {
70
71
  this[name] = new element()
71
72
  }
72
73
 
74
+ loaded(func){
75
+ if (typeof func === 'function') {
76
+ this._loadedFunc = func;
77
+ }
78
+ }
79
+
73
80
  // extends class methods to be used inside of the view class using the THIS keyword
74
81
  extendView( name, element){
75
82
  element = new element();
@@ -174,6 +181,14 @@ class MasterControl {
174
181
 
175
182
  }
176
183
 
184
+ useHTTPServer(port, func){
185
+ if (typeof func === 'function') {
186
+ http.createServer(function (req, res) {
187
+ func(req, res);
188
+ }).listen(port);
189
+ }
190
+ }
191
+
177
192
  // sets up https or http server protocals
178
193
  setupServer(type, credentials ){
179
194
  var $that = this;
@@ -210,7 +225,15 @@ class MasterControl {
210
225
  if(ext === ""){
211
226
  var requestObject = await this.middleware(req, res);
212
227
  if(requestObject !== -1){
213
- require(`${this.root}/config/load`)(requestObject);
228
+ var loadedDone = false;
229
+ if (typeof $that._loadedFunc === 'function') {
230
+ loadedDone = $that._loadedFunc(requestObject);
231
+
232
+ }
233
+ if (loadedDone){
234
+ require(`${this.root}/config/load`)(requestObject);
235
+ }
236
+
214
237
  }
215
238
  }
216
239
  else{
package/package.json CHANGED
@@ -18,5 +18,5 @@
18
18
  "scripts": {
19
19
  "test": "echo \"Error: no test specified\" && exit 1"
20
20
  },
21
- "version": "1.2.0"
21
+ "version": "1.2.1"
22
22
  }