mythix 2.7.3 → 2.8.0

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": "2.7.3",
3
+ "version": "2.8.0",
4
4
  "description": "Mythix is a NodeJS web-app framework",
5
5
  "main": "src/index",
6
6
  "scripts": {
@@ -8,6 +8,7 @@ import { Modules, ModuleClasses, BaseModuleClass } from './modules/base-module';
8
8
  export declare type ApplicationClass = typeof Application;
9
9
 
10
10
  export declare interface ApplicationOptions {
11
+ cli: boolean;
11
12
  environment: string;
12
13
  appName: string;
13
14
  rootPath: string;
@@ -29,7 +30,7 @@ export declare interface ApplicationOptions {
29
30
  database: boolean | GenericObject;
30
31
  httpServer: boolean | GenericObject;
31
32
  tempPath: string;
32
- routeParserTypes: { [ key: string ]: (value: string, param: GenericObject, index?: number) => any };
33
+ routeParserTypes: { [key: string]: (value: string, param: GenericObject, index?: number) => any };
33
34
  }
34
35
 
35
36
  export declare class Application {
@@ -54,7 +55,7 @@ export declare class Application {
54
55
  public setConfig(options: GenericObject): Application;
55
56
  public getApplicationName(): string;
56
57
  public getRoutes(): GenericObject;
57
- public getCustomRouteParserTypes(): { [ key: string ]: (value: string, param: GenericObject, index?: number) => any };
58
+ public getCustomRouteParserTypes(): { [key: string]: (value: string, param: GenericObject, index?: number) => any };
58
59
  public createLogger(loggerOptions: LoggerOptions, LoggerClass: LoggerClass): Logger;
59
60
  public getLogger(): Logger;
60
61
  public start(): Promise<void>;
@@ -81,7 +81,6 @@ class Application extends EventEmitter {
81
81
  templatesPath: Path.resolve(ROOT_PATH, 'templates'),
82
82
  commandsPath: Path.resolve(ROOT_PATH, 'commands'),
83
83
  tasksPath: Path.resolve(ROOT_PATH, 'tasks'),
84
- modules: this.constructor.getDefaultModules(),
85
84
  autoReload: ((_opts && _opts.environment) || process.env.NODE_ENV || 'development') === 'development',
86
85
  exitOnShutdown: null,
87
86
  runTasks: true,
@@ -149,6 +148,8 @@ class Application extends EventEmitter {
149
148
 
150
149
  if (Nife.isEmpty(opts.tempPath))
151
150
  opts.tempPath = Path.resolve(OS.tmpdir(), this.getApplicationName().replace(/[^\w-]/g, ''), ('' + process.pid));
151
+
152
+ opts.modules = this.constructor.getDefaultModules(this, opts);
152
153
  }
153
154
 
154
155
  getApplicationName() {
@@ -176,7 +177,7 @@ class Application extends EventEmitter {
176
177
 
177
178
  for (let i = 0, il = modules.length; i < il; i++) {
178
179
  let ModuleClass = modules[i];
179
- if (typeof ModuleClass.shouldUse === 'function' && ModuleClass.shouldUse.call(this, options) === false)
180
+ if (typeof ModuleClass.shouldUse === 'function' && ModuleClass.shouldUse.call(ModuleClass, this, options) === false)
180
181
  continue;
181
182
 
182
183
  let moduleInstance = new ModuleClass(this);
@@ -250,10 +250,10 @@ function defineCommand(_commandName, definer, _parent) {
250
250
  if (typeof applicationConfig === 'function')
251
251
  applicationConfig = applicationConfig(config, Application);
252
252
  else if (applicationConfig)
253
- applicationConfig = Nife.extend(true, { httpServer: false, autoReload: false, logger: { level: Logger.LEVEL_WARN }, runTasks: false }, applicationConfig);
253
+ applicationConfig = Nife.extend(true, { cli: true, httpServer: false, autoReload: false, logger: { level: Logger.LEVEL_WARN }, runTasks: false }, applicationConfig);
254
254
 
255
255
  if (!applicationConfig)
256
- applicationConfig = { httpServer: false, autoReload: false, logger: { level: Logger.LEVEL_WARN }, runTasks: false };
256
+ applicationConfig = { cli: true, ttpServer: false, autoReload: false, logger: { level: Logger.LEVEL_WARN }, runTasks: false };
257
257
 
258
258
  let doStartApplication = (applicationConfig.autoStart !== false);
259
259
 
@@ -11,7 +11,7 @@ const {
11
11
  class ControllerModule extends BaseModule {
12
12
  static fileWatcherQueueName = 'controllers';
13
13
 
14
- static shouldUse(options) {
14
+ static shouldUse(application, options) {
15
15
  if (options.httpServer === false)
16
16
  return false;
17
17
 
@@ -5,7 +5,7 @@ const { BaseModule } = require('../modules/base-module');
5
5
  const { HTTPServer } = require('./http-server');
6
6
 
7
7
  class HTTPServerModule extends BaseModule {
8
- static shouldUse(options) {
8
+ static shouldUse(application, options) {
9
9
  if (options.httpServer === false)
10
10
  return false;
11
11
 
@@ -16,7 +16,7 @@ class ModelModule extends BaseModule {
16
16
  return 'ModelModule';
17
17
  }
18
18
 
19
- static shouldUse(options) {
19
+ static shouldUse(application, options) {
20
20
  if (options.database === false)
21
21
  return false;
22
22
 
@@ -11,7 +11,7 @@ export declare class BaseModule {
11
11
  public declare static fileWatcherQueueName: string;
12
12
 
13
13
  public static getModuleName(): string;
14
- public static shouldUse(options?: GenericObject): boolean;
14
+ public static shouldUse(application: Application, options: GenericObject): boolean;
15
15
 
16
16
  public fileWatcherGetMonitorPaths(options?: GenericObject): Array<string>;
17
17
  public fileWatcherHandler(options?: GenericObject): Promise<void>;
@@ -9,7 +9,7 @@ class DatabaseModule extends BaseModule {
9
9
  return 'DatabaseModule';
10
10
  }
11
11
 
12
- static shouldUse(options) {
12
+ static shouldUse(application, options) {
13
13
  if (options.database === false)
14
14
  return false;
15
15
 
@@ -9,7 +9,7 @@ class FileWatcherModule extends BaseModule {
9
9
  return 'FileWatcherModule';
10
10
  }
11
11
 
12
- static shouldUse(options) {
12
+ static shouldUse(application, options) {
13
13
  if (options.autoReload === false)
14
14
  return false;
15
15
 
@@ -23,7 +23,7 @@ class TaskModule extends BaseModule {
23
23
 
24
24
  static fileWatcherQueueName = 'tasks';
25
25
 
26
- static shouldUse(options) {
26
+ static shouldUse(application, options) {
27
27
  if (options.runTasks === false)
28
28
  return false;
29
29