mastercontroller 1.2.6 → 1.2.7

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.
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Alexander Rich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/MasterRouter.js CHANGED
@@ -3,6 +3,7 @@
3
3
  var master = require('./MasterControl');
4
4
  var toolClass = require('./MasterTools');
5
5
  const EventEmitter = require("events");
6
+ var path = require('path');
6
7
  var currentRoute = {};
7
8
  var tools = new toolClass();
8
9
 
@@ -36,6 +37,17 @@ var tools = new toolClass();
36
37
  var root = routeObject.root;
37
38
  var isComponent = routeObject.isComponent;
38
39
  try{
40
+ // Ensure routes is an array
41
+ if(!Array.isArray(routeList)){
42
+ master.error.log(`route list is not an array`, "error");
43
+ return -1;
44
+ }
45
+
46
+ // No routes registered for this scope; skip silently
47
+ if(routeList.length === 0){
48
+ return -1;
49
+ }
50
+
39
51
  if(routeList.length > 0){
40
52
  // loop through routes
41
53
  for(var item in routeList){
@@ -86,10 +98,6 @@ var tools = new toolClass();
86
98
  };
87
99
  return -1;
88
100
  }
89
- else{
90
- master.error.log(`route list is not an array`, "error");
91
- return -1;
92
- }
93
101
  }
94
102
  catch(e){
95
103
  throw new Error("Error processing routes: " + e.stack);
@@ -251,12 +259,15 @@ class MasterRouter {
251
259
 
252
260
  tools.combineObjects(master.requestList, requestObject);
253
261
  requestObject = master.requestList;
254
- var Control = require(`${currentRoute.root}/app/controllers/${tools.firstLetterlowercase(requestObject.toController)}Controller`);
255
- if(Control === null){
256
- Control = require(`${currentRoute.root}/app/controllers/${tools.firstLetterUppercase(requestObject.toController)}Controller`);
257
- if(Control === null){
258
- console.log(`Cannot find controller name - ${requestObject.toController}`);
259
- }
262
+ var Control = null;
263
+ try{
264
+ Control = require(path.join(currentRoute.root, 'app', 'controllers', `${tools.firstLetterlowercase(requestObject.toController)}Controller`));
265
+ }catch(e){
266
+ try{
267
+ Control = require(path.join(currentRoute.root, 'app', 'controllers', `${tools.firstLetterUppercase(requestObject.toController)}Controller`));
268
+ }catch(e2){
269
+ console.log(`Cannot find controller name - ${requestObject.toController}`);
270
+ }
260
271
  }
261
272
  tools.combineObjectPrototype(Control, master.controllerList);
262
273
  Control.prototype.__namespace = Control.name;
package/README.md CHANGED
@@ -54,5 +54,5 @@ Use `setupServer('https', credentials)` or configure via environment TLS; see do
54
54
  - If keeping TLS in Node, harden TLS and manage cert rotation.
55
55
 
56
56
  ### License
57
- ISC
57
+ MIT
58
58
 
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "description": "A class library that makes using the Master Framework a breeze",
10
10
  "homepage": "https://github.com/Tailor/MasterController#readme",
11
- "license": "ISC",
11
+ "license": "MIT",
12
12
  "main": "MasterControl.js",
13
13
  "name": "mastercontroller",
14
14
  "repository": {
@@ -18,5 +18,5 @@
18
18
  "scripts": {
19
19
  "test": "echo \"Error: no test specified\" && exit 1"
20
20
  },
21
- "version": "1.2.6"
21
+ "version": "1.2.7"
22
22
  }