mythix 1.1.2 → 1.1.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mythix",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Mythix is a NodeJS web-app framework",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -299,7 +299,10 @@ class Application extends EventEmitter {
299
299
  }
300
300
 
301
301
  async stop(exitCode) {
302
- if (this.isStopping || !this.isStarted)
302
+ if (this.isStopping)
303
+ process.exit(1);
304
+
305
+ if (!this.isStarted)
303
306
  return;
304
307
 
305
308
  try {
@@ -83,11 +83,17 @@ class ControllerBase {
83
83
 
84
84
  getModel(name) {
85
85
  let application = this.getApplication();
86
+ if (typeof application.getModel !== 'function')
87
+ return;
88
+
86
89
  return application.getModel(name);
87
90
  }
88
91
 
89
92
  getModels() {
90
93
  let application = this.getApplication();
94
+ if (typeof application.getModels !== 'function')
95
+ return {};
96
+
91
97
  return application.getModels();
92
98
  }
93
99
 
@@ -164,6 +170,9 @@ class ControllerBase {
164
170
  async handleIncomingRequest(request, response, { route, controllerMethod, startTime, params, query /* , controller, controllerInstance, */ }) {
165
171
  this.route = route;
166
172
 
173
+ if (typeof this[controllerMethod] !== 'function')
174
+ this.throwInternalServerError(`Specified route handler named "${this.constructor.name}::${controllerMethod}" not found.`);
175
+
167
176
  return await this[controllerMethod].call(this, { params, query, body: request.body, request, response, startTime }, this.getModels());
168
177
  }
169
178
 
@@ -296,7 +296,7 @@ function compileRoutes(routes, customParserTypes, _context) {
296
296
  accept: '*',
297
297
  priority,
298
298
  },
299
- getRouteProperties(route),
299
+ route || {},
300
300
  {
301
301
  path: path.replace(/\/{2,}/g, '/'),
302
302
  },
@@ -362,7 +362,7 @@ function compileRoutes(routes, customParserTypes, _context) {
362
362
  addRoute(theseRoutes, route, newPath, basePriority + i);
363
363
  }
364
364
 
365
- if (ROUTE_PROPERTIES.indexOf(key) >= 0)
365
+ if (ROUTE_PROPERTIES.indexOf(key) >= 0 || Nife.instanceOf(route, 'boolean', 'string', 'number', 'bigint'))
366
366
  continue;
367
367
 
368
368
  let thisRouteName = (isArray) ? routeName : key;
@@ -116,6 +116,8 @@ class HTTPServer {
116
116
  }
117
117
 
118
118
  executeMiddleware(middleware, request, response) {
119
+ let { route, params } = (this.findFirstMatchingRoute(request, this.routes) || {});
120
+
119
121
  return new Promise((resolve, reject) => {
120
122
  if (Nife.isEmpty(middleware)) {
121
123
  resolve();
@@ -133,6 +135,9 @@ class HTTPServer {
133
135
  if (!request.Sequelize)
134
136
  request.Sequelize = Sequelize;
135
137
 
138
+ request.route = route;
139
+ request.params = params;
140
+
136
141
  let middlewareIndex = 0;
137
142
  const next = async () => {
138
143
  if (middlewareIndex >= middleware.length)
@@ -69,10 +69,14 @@ class FileWatcherModule extends BaseModule {
69
69
  return this.watchedPathsCache;
70
70
  }
71
71
 
72
- isWatchedFile(options, filePath) {
73
- let monitoredPaths = this.getMonitoredPaths(options);
72
+ isWatchedFile(_monitoredPaths, filePath) {
73
+ let monitoredPaths = Nife.toArray(_monitoredPaths);
74
+
74
75
  for (let i = 0, il = monitoredPaths.length; i < il; i++) {
75
76
  let monitoredPath = monitoredPaths[i];
77
+ if (!monitoredPath)
78
+ continue;
79
+
76
80
  if (filePath.substring(0, monitoredPath.length) === monitoredPath)
77
81
  return true;
78
82
  }
@@ -90,7 +94,8 @@ class FileWatcherModule extends BaseModule {
90
94
  if (!queueName)
91
95
  continue;
92
96
 
93
- if (this.isWatchedFile(options, filePath))
97
+ let paths = moduleInstance.fileWatcherGetMonitorPaths(options);
98
+ if (this.isWatchedFile(paths, filePath))
94
99
  return queueName;
95
100
  }
96
101