mythix 3.0.0 → 4.0.2

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 (128) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +27 -30
  3. package/{src → lib}/application.d.ts +25 -39
  4. package/{src/application.js → lib/application.mjs} +110 -135
  5. package/lib/cli/cli-utils.d.ts +21 -0
  6. package/lib/cli/cli-utils.mjs +319 -0
  7. package/lib/cli/command-base.d.ts +33 -0
  8. package/lib/cli/command-base.mjs +118 -0
  9. package/lib/cli/command-executor.mjs +14 -0
  10. package/lib/cli/commands/deploy-command.mjs +1010 -0
  11. package/lib/cli/commands/generators/generate-command.mjs +117 -0
  12. package/lib/cli/commands/generators/index.mjs +2 -0
  13. package/{src/cli/generators/migration-generator.js → lib/cli/commands/generators/migration-generator.mjs} +11 -13
  14. package/lib/cli/commands/index.mjs +22 -0
  15. package/lib/cli/commands/migrate-command.mjs +184 -0
  16. package/lib/cli/commands/routes-command.mjs +40 -0
  17. package/lib/cli/commands/serve-command.mjs +63 -0
  18. package/lib/cli/commands/shell-command.mjs +95 -0
  19. package/lib/cli/index.mjs +3 -0
  20. package/{src → lib}/controllers/controller-base.d.ts +1 -1
  21. package/{src/controllers/controller-base.js → lib/controllers/controller-base.mjs} +3 -9
  22. package/{src → lib}/controllers/controller-module.d.ts +3 -3
  23. package/lib/controllers/controller-module.mjs +70 -0
  24. package/lib/controllers/generate-client-api-interface-spec.mjs +44 -0
  25. package/{src → lib}/controllers/generate-client-api-interface.d.ts +1 -0
  26. package/{src/controllers/generate-client-api-interface.js → lib/controllers/generate-client-api-interface.mjs} +39 -16
  27. package/{src → lib}/controllers/index.d.ts +2 -3
  28. package/lib/controllers/index.mjs +4 -0
  29. package/lib/controllers/routes/index.mjs +4 -0
  30. package/{src/controllers/routes/route-capture.js → lib/controllers/routes/route-capture.mjs} +2 -8
  31. package/{src/controllers/routes/route-endpoint.js → lib/controllers/routes/route-endpoint.mjs} +8 -8
  32. package/{src/controllers/routes/route-scope-base.js → lib/controllers/routes/route-scope-base.mjs} +19 -15
  33. package/{src/controllers/routes/route-scope.js → lib/controllers/routes/route-scope.mjs} +10 -12
  34. package/{src/http-server/http-errors.js → lib/http/http-errors.mjs} +9 -20
  35. package/{src/utils/http-interface.js → lib/http/http-interface.mjs} +6 -14
  36. package/{src/http-server → lib/http}/http-server-module.d.ts +2 -2
  37. package/{src/http-server/http-server-module.js → lib/http/http-server-module.mjs} +7 -11
  38. package/{src/http-server/http-server.js → lib/http/http-server.mjs} +17 -21
  39. package/lib/http/index.d.ts +4 -0
  40. package/lib/http/index.mjs +5 -0
  41. package/lib/index.d.ts +30 -0
  42. package/lib/index.mjs +31 -0
  43. package/lib/logger-spec.mjs +121 -0
  44. package/{src → lib}/logger.d.ts +1 -3
  45. package/{src/logger.js → lib/logger.mjs} +10 -24
  46. package/lib/models/index.d.ts +2 -0
  47. package/lib/models/index.mjs +2 -0
  48. package/{src/models/migration-model.js → lib/models/migration-model.mjs} +3 -11
  49. package/lib/models/model.d.ts +10 -0
  50. package/lib/models/model.mjs +28 -0
  51. package/{src → lib}/modules/database-module.d.ts +2 -2
  52. package/{src/modules/database-module.js → lib/modules/database-module.mjs} +19 -14
  53. package/lib/modules/index.d.ts +2 -0
  54. package/lib/modules/index.mjs +2 -0
  55. package/{src/modules/base-module.d.ts → lib/modules/module-base.d.ts} +3 -10
  56. package/{src/modules/base-module.js → lib/modules/module-base.mjs} +16 -6
  57. package/lib/tasks/index.d.ts +2 -0
  58. package/lib/tasks/index.mjs +2 -0
  59. package/{src → lib}/tasks/task-base.d.ts +4 -14
  60. package/lib/tasks/task-base.mjs +73 -0
  61. package/{src → lib}/tasks/task-module.d.ts +3 -3
  62. package/{src/tasks/task-module.js → lib/tasks/task-module.mjs} +43 -98
  63. package/{src/utils/config-utils.js → lib/utils/config-utils.mjs} +2 -10
  64. package/lib/utils/crypto-utils-spec.mjs +24 -0
  65. package/{src/utils/crypto-utils.js → lib/utils/crypto-utils.mjs} +16 -38
  66. package/lib/utils/file-utils-spec.mjs +10 -0
  67. package/{src/utils/file-utils.js → lib/utils/file-utils.mjs} +4 -11
  68. package/{src/utils/http-utils.js → lib/utils/http-utils.mjs} +3 -10
  69. package/{src → lib}/utils/index.d.ts +1 -1
  70. package/lib/utils/index.mjs +6 -0
  71. package/lib/utils/mime-utils-spec.mjs +171 -0
  72. package/{src/utils/mime-utils.js → lib/utils/mime-utils.mjs} +5 -14
  73. package/{src/utils/test-utils.js → lib/utils/test-utils.mjs} +14 -42
  74. package/package.json +5 -5
  75. package/src/cli/cli-utils.d.ts +0 -80
  76. package/src/cli/cli-utils.js +0 -547
  77. package/src/cli/command-executor.js +0 -31
  78. package/src/cli/deploy-command.js +0 -1010
  79. package/src/cli/generators/generate-command.js +0 -149
  80. package/src/cli/index.js +0 -5
  81. package/src/cli/migrate-command.js +0 -181
  82. package/src/cli/routes-command.js +0 -40
  83. package/src/cli/serve-command.js +0 -63
  84. package/src/cli/shell-command.js +0 -96
  85. package/src/controllers/controller-module.js +0 -126
  86. package/src/controllers/controller-utils.d.ts +0 -19
  87. package/src/controllers/controller-utils.js +0 -24
  88. package/src/controllers/index.js +0 -19
  89. package/src/controllers/routes/index.js +0 -31
  90. package/src/http-server/index.d.ts +0 -3
  91. package/src/http-server/index.js +0 -16
  92. package/src/index.d.ts +0 -49
  93. package/src/index.js +0 -47
  94. package/src/models/index.d.ts +0 -4
  95. package/src/models/index.js +0 -17
  96. package/src/models/model-module.d.ts +0 -9
  97. package/src/models/model-module.js +0 -130
  98. package/src/models/model-utils.d.ts +0 -20
  99. package/src/models/model-utils.js +0 -46
  100. package/src/models/model.d.ts +0 -20
  101. package/src/models/model.js +0 -65
  102. package/src/modules/file-watcher-module.d.ts +0 -13
  103. package/src/modules/file-watcher-module.js +0 -220
  104. package/src/modules/index.d.ts +0 -3
  105. package/src/modules/index.js +0 -11
  106. package/src/tasks/index.d.ts +0 -3
  107. package/src/tasks/index.js +0 -11
  108. package/src/tasks/task-base.js +0 -117
  109. package/src/tasks/task-utils.d.ts +0 -46
  110. package/src/tasks/task-utils.js +0 -130
  111. package/src/utils/index.js +0 -25
  112. /package/{src → lib}/cli/index.d.ts +0 -0
  113. /package/{src → lib}/controllers/routes/index.d.ts +0 -0
  114. /package/{src → lib}/controllers/routes/route-capture.d.ts +0 -0
  115. /package/{src → lib}/controllers/routes/route-endpoint.d.ts +0 -0
  116. /package/{src → lib}/controllers/routes/route-scope-base.d.ts +0 -0
  117. /package/{src → lib}/controllers/routes/route-scope.d.ts +0 -0
  118. /package/{src/http-server → lib/http}/http-errors.d.ts +0 -0
  119. /package/{src/utils → lib/http}/http-interface.d.ts +0 -0
  120. /package/{src/http-server → lib/http}/http-server.d.ts +0 -0
  121. /package/{src → lib}/interfaces/common.ts +0 -0
  122. /package/{src → lib}/models/migration-model.d.ts +0 -0
  123. /package/{src → lib}/utils/config-utils.d.ts +0 -0
  124. /package/{src → lib}/utils/crypto-utils.d.ts +0 -0
  125. /package/{src → lib}/utils/file-utils.d.ts +0 -0
  126. /package/{src → lib}/utils/http-utils.d.ts +0 -0
  127. /package/{src → lib}/utils/mime-utils.d.ts +0 -0
  128. /package/{src → lib}/utils/test-utils.d.ts +0 -0
@@ -1,220 +0,0 @@
1
- 'use strict';
2
-
3
- const chokidar = require('chokidar');
4
- const Nife = require('nife');
5
- const { BaseModule } = require('../modules/base-module');
6
-
7
- class FileWatcherModule extends BaseModule {
8
- static getModuleName() {
9
- return 'FileWatcherModule';
10
- }
11
-
12
- static shouldUse(application, options) {
13
- if (options.autoReload === false)
14
- return false;
15
-
16
- return true;
17
- }
18
-
19
- constructor(application) {
20
- super(application);
21
-
22
- Object.defineProperties(this, {
23
- 'fileWatcher': {
24
- writable: true,
25
- enumerable: false,
26
- configurable: true,
27
- value: null,
28
- },
29
- 'watchedPathsCache': {
30
- writable: true,
31
- enumerable: false,
32
- configurable: true,
33
- value: null,
34
- },
35
- });
36
-
37
- // Inject methods into the application
38
- Object.defineProperties(application, {
39
- 'autoReload': {
40
- writable: true,
41
- enumerable: false,
42
- configurable: true,
43
- value: this.autoReload.bind(this),
44
- },
45
- });
46
- }
47
-
48
- getMonitoredPaths(options) {
49
- if (this.watchedPathsCache)
50
- return this.watchedPathsCache;
51
-
52
- let application = this.getApplication();
53
- let moduleInstances = application.getModules();
54
- let allPaths = [];
55
-
56
- for (let i = 0, il = moduleInstances.length; i < il; i++) {
57
- let moduleInstance = moduleInstances[i];
58
- let queueName = moduleInstance.constructor.fileWatcherQueueName;
59
- if (!queueName || typeof moduleInstance.fileWatcherGetMonitorPaths !== 'function')
60
- continue;
61
-
62
- let paths = moduleInstance.fileWatcherGetMonitorPaths(options);
63
- if (paths)
64
- allPaths = allPaths.concat(paths);
65
- }
66
-
67
- this.watchedPathsCache = Nife.uniq(allPaths);
68
-
69
- return this.watchedPathsCache;
70
- }
71
-
72
- isWatchedFile(_monitoredPaths, filePath) {
73
- let monitoredPaths = Nife.toArray(_monitoredPaths);
74
-
75
- for (let i = 0, il = monitoredPaths.length; i < il; i++) {
76
- let monitoredPath = monitoredPaths[i];
77
- if (!monitoredPath)
78
- continue;
79
-
80
- if (filePath.substring(0, monitoredPath.length) === monitoredPath)
81
- return true;
82
- }
83
-
84
- return false;
85
- }
86
-
87
- getFileScope(options, filePath) {
88
- let application = this.getApplication();
89
- let moduleInstances = application.getModules();
90
-
91
- for (let i = 0, il = moduleInstances.length; i < il; i++) {
92
- let moduleInstance = moduleInstances[i];
93
- let queueName = moduleInstance.constructor.fileWatcherQueueName;
94
- if (!queueName)
95
- continue;
96
-
97
- let paths = moduleInstance.fileWatcherGetMonitorPaths(options);
98
- if (this.isWatchedFile(paths, filePath))
99
- return queueName;
100
- }
101
-
102
- return 'default';
103
- }
104
-
105
- async autoReload(_set, shuttingDown) {
106
- let options = this.getApplication().getOptions();
107
- if (arguments.length === 0)
108
- return options.autoReload;
109
-
110
- let set = !!_set;
111
-
112
- if (!shuttingDown)
113
- options.autoReload = set;
114
-
115
- if (this.fileWatcher) {
116
- try {
117
- await this.fileWatcher.close();
118
- } catch (error) {
119
- console.error(error);
120
- }
121
- }
122
-
123
- if (shuttingDown)
124
- return;
125
-
126
- if (!set)
127
- return;
128
-
129
- this.watchedPathsCache = null;
130
-
131
- const filesChanged = (eventName, path) => {
132
- if (filesChangedTimeout)
133
- clearTimeout(filesChangedTimeout);
134
-
135
- let scopeName = this.getFileScope(options, path);
136
- let scope = filesChangedQueue[scopeName];
137
- if (!scope)
138
- scope = filesChangedQueue[scopeName] = {};
139
-
140
- scope[path] = eventName;
141
-
142
- filesChangedTimeout = setTimeout(() => {
143
- this.watchedFilesChanged(Object.assign({}, filesChangedQueue));
144
-
145
- filesChangedTimeout = null;
146
- filesChangedQueue = {};
147
- }, 500);
148
- };
149
-
150
- let filesChangedQueue = {};
151
- let filesChangedTimeout;
152
- let monitoredPaths = this.getMonitoredPaths(options);
153
-
154
- this.fileWatcher = chokidar.watch(monitoredPaths, {
155
- persistent: true,
156
- followSymlinks: true,
157
- usePolling: false,
158
- ignoreInitial: true,
159
- interval: 200,
160
- binaryInterval: 500,
161
- depth: 10,
162
- });
163
-
164
- this.fileWatcher.on('all', filesChanged);
165
- }
166
-
167
- async watchedFilesChanged(files) {
168
- const flushRequireCache = (path) => {
169
- try {
170
- delete require.cache[require.resolve(path)];
171
- } catch (error) {
172
- console.error('Error while trying to flush require cache to reload modified files: ', error);
173
- }
174
- };
175
-
176
- const flushRequireCacheForFiles = (type, filesToFlushCache) => {
177
- for (let i = 0, il = filesToFlushCache.length; i < il; i++) {
178
- let fileName = filesToFlushCache[i];
179
- flushRequireCache(fileName);
180
-
181
- this.getLogger().info(`Loading ${type} ${fileName}...`);
182
- }
183
- };
184
-
185
- let application = this.getApplication();
186
- let options = application.getOptions();
187
- let moduleInstances = application.getModules();
188
-
189
- for (let i = 0, il = moduleInstances.length; i < il; i++) {
190
- let moduleInstance = moduleInstances[i];
191
- let queueName = moduleInstance.constructor.fileWatcherQueueName;
192
- if (!queueName || typeof moduleInstance.fileWatcherHandler !== 'function')
193
- continue;
194
-
195
- let scope = files[queueName];
196
- let fileNames = Object.keys(scope || {});
197
-
198
- if (Nife.isEmpty(fileNames))
199
- continue;
200
-
201
- flushRequireCacheForFiles(queueName, fileNames);
202
-
203
- try {
204
- await moduleInstance.fileWatcherHandler.call(moduleInstance, options);
205
- } catch (error) {
206
- this.getLogger().error(`Error while attempting to reload ${queueName}`, error);
207
- }
208
- }
209
- }
210
-
211
- async start(options) {
212
- await this.autoReload(options.autoReload, false);
213
- }
214
-
215
- async stop() {
216
- await this.autoReload(false, true);
217
- }
218
- }
219
-
220
- module.exports = { FileWatcherModule };
@@ -1,3 +0,0 @@
1
- export * from './base-module';
2
- export * from './database-module';
3
- export * from './file-watcher-module';
@@ -1,11 +0,0 @@
1
- 'use strict';
2
-
3
- const { BaseModule } = require('./base-module');
4
- const { DatabaseModule } = require('./database-module');
5
- const { FileWatcherModule } = require('./file-watcher-module');
6
-
7
- module.exports = {
8
- BaseModule,
9
- DatabaseModule,
10
- FileWatcherModule,
11
- };
@@ -1,3 +0,0 @@
1
- export * from './task-base';
2
- export * as TaskUtils from './task-utils';
3
- export { defineTask } from './task-utils';
@@ -1,11 +0,0 @@
1
- 'use strict';
2
-
3
- const { TaskBase } = require('./task-base');
4
- const { TaskModule } = require('./task-module');
5
- const { defineTask } = require('./task-utils');
6
-
7
- module.exports = {
8
- TaskBase,
9
- TaskModule,
10
- defineTask,
11
- };
@@ -1,117 +0,0 @@
1
- 'use strict';
2
-
3
- const { DateTime } = require('luxon');
4
-
5
- class TaskBase {
6
- static onTaskClassCreate(Klass) {
7
- return Klass;
8
- }
9
-
10
- // eslint-disable-next-line no-unused-vars
11
- static getFrequency(taskIndex) {
12
- return this._frequency || 0;
13
- }
14
-
15
- static getStartDelay(taskIndex) {
16
- let workers = this.workers || 1;
17
- let frequency = this.getFrequency(taskIndex);
18
- let startDelay = this._startDelay || 0;
19
-
20
- if (workers > 1) {
21
- let shift = (frequency / workers);
22
- startDelay = startDelay + (shift * taskIndex);
23
- }
24
-
25
- return startDelay;
26
- }
27
-
28
- static nextRun(taskIndex, lastTime, currentTime, diff) {
29
- if (!lastTime)
30
- return DateTime.now().plus({ milliseconds: this.getStartDelay(taskIndex) });
31
-
32
- return DateTime.now().plus({ milliseconds: Math.max(0, this.getFrequency(taskIndex) - diff) });
33
- }
34
-
35
- constructor(application, logger, runID) {
36
- Object.defineProperties(this, {
37
- 'application': {
38
- writable: false,
39
- enumerable: false,
40
- configurable: true,
41
- value: application,
42
- },
43
- 'logger': {
44
- writable: true,
45
- enumerable: false,
46
- configurable: true,
47
- value: logger,
48
- },
49
- 'runID': {
50
- writable: false,
51
- enumerable: false,
52
- configurable: true,
53
- value: runID,
54
- },
55
- });
56
- }
57
-
58
- async start() {
59
- }
60
-
61
- async stop() {
62
-
63
- }
64
-
65
- getApplication() {
66
- return this.application;
67
- }
68
-
69
- getLogger() {
70
- let logger = this.logger;
71
- if (!logger) {
72
- let application = this.getApplication();
73
- logger = application.getLogger();
74
- }
75
-
76
- return logger;
77
- }
78
-
79
- getRunID() {
80
- return this.runID;
81
- }
82
-
83
- getNumberOfWorkers() {
84
- let workers = this.constructor.workers || 1;
85
- return workers;
86
- }
87
-
88
- getModel(name) {
89
- let application = this.getApplication();
90
- return application.getModel(name);
91
- }
92
-
93
- getModels() {
94
- let application = this.getApplication();
95
- return application.getModels();
96
- }
97
-
98
- getConnection(connection) {
99
- let application = this.getApplication();
100
- return application.getConnection(connection);
101
- }
102
-
103
- // Deprecated
104
- getDBConnection(connection) {
105
- return this.getConnection(connection);
106
- }
107
-
108
- getFrequency(taskIndex) {
109
- return this.constructor.getFrequency(taskIndex);
110
- }
111
-
112
- getStartDelay(taskIndex) {
113
- return this.constructor.getStartDelay(taskIndex);
114
- }
115
- }
116
-
117
- module.exports = { TaskBase };
@@ -1,46 +0,0 @@
1
- import { ConnectionBase } from 'mythix-orm';
2
- import { Application } from '../application';
3
- import { GenericObject } from '../interfaces/common';
4
- import { TaskClass } from './task-base';
5
-
6
- export declare class TimeHelpers {
7
- constructor(days?: number, hours?: number, minutes?: number, seconds?: number);
8
- clone(days?: number, hours?: number, minutes?: number, seconds?: number): TimeHelpers;
9
- reset(): TimeHelpers;
10
- days(days: number): TimeHelpers;
11
- hours(hours: number): TimeHelpers;
12
- minutes(minutes: number): TimeHelpers;
13
- seconds(seconds: number): TimeHelpers;
14
- totalSeconds(): number;
15
- totalMilliseconds(): number;
16
-
17
- declare public _days: number;
18
- declare public _hours: number;
19
- declare public _minutes: number;
20
- declare public _seconds: number;
21
- }
22
-
23
- export declare type TimeHelpersClass = typeof TimeHelpers;
24
-
25
- export declare interface DefineTaskContext {
26
- Parent: TaskClass;
27
- application: Application;
28
- connection: ConnectionBase;
29
- dbConfig: GenericObject;
30
- taskName: string;
31
- time: TimeHelpers;
32
- }
33
-
34
- export declare function defineTask(
35
- taskName: string,
36
- definer: (context: DefineTaskContext) => TaskClass,
37
- parent?: TaskClass,
38
- ): (context: {
39
- application: Application,
40
- connection: ConnectionBase,
41
- dbConfig: GenericObject,
42
- }) => TaskClass;
43
-
44
- export declare namespace defineTask {
45
- const TimeHelpers: TimeHelpersClass;
46
- }
@@ -1,130 +0,0 @@
1
- 'use strict';
2
-
3
- const Nife = require('nife');
4
- const { TaskBase } = require('./task-base');
5
-
6
- const SECONDS_PER_MINUTE = 60;
7
- const MINUTES_PER_HOUR = 60;
8
- const SECONDS_PER_HOUR = (SECONDS_PER_MINUTE * MINUTES_PER_HOUR);
9
- const HOURS_PER_DAY = 24;
10
- const MINUTES_PER_DAY = (MINUTES_PER_HOUR * HOURS_PER_DAY);
11
- const SECONDS_PER_DAY = (MINUTES_PER_DAY * SECONDS_PER_MINUTE);
12
- const MILLISECONDS_PER_SECOND = 1000;
13
-
14
- class TimeHelpers {
15
- constructor(_days, _hours, _minutes, _seconds) {
16
- Object.defineProperties(this, {
17
- '_days': {
18
- writable: true,
19
- enumerable: false,
20
- configurable: true,
21
- value: _days || 0,
22
- },
23
- '_hours': {
24
- writable: true,
25
- enumerable: false,
26
- configurable: true,
27
- value: _hours || 0,
28
- },
29
- '_minutes': {
30
- writable: true,
31
- enumerable: false,
32
- configurable: true,
33
- value: _minutes || 0,
34
- },
35
- '_seconds': {
36
- writable: true,
37
- enumerable: false,
38
- configurable: true,
39
- value: _seconds || 0,
40
- },
41
- });
42
-
43
- this.days = this.days.bind(this);
44
- this.hours = this.hours.bind(this);
45
- this.minutes = this.minutes.bind(this);
46
- this.seconds = this.seconds.bind(this);
47
- }
48
-
49
- clone(_days, _hours, _minutes, _seconds) {
50
- return new TimeHelpers(_days || this._days, _hours || this._hours, _minutes || this._minutes, _seconds || this._seconds);
51
- }
52
-
53
- reset() {
54
- return new TimeHelpers();
55
- }
56
-
57
- days(days) {
58
- return this.clone(days);
59
- }
60
-
61
- hours(hours) {
62
- return this.clone(undefined, hours);
63
- }
64
-
65
- minutes(minutes) {
66
- return this.clone(undefined, undefined, minutes);
67
- }
68
-
69
- seconds(seconds) {
70
- return this.clone(undefined, undefined, undefined, seconds);
71
- }
72
-
73
- totalSeconds() {
74
- let totalTime = (this._days * SECONDS_PER_DAY) + (this._hours * SECONDS_PER_HOUR) + (this._minutes * SECONDS_PER_MINUTE) + this._seconds;
75
- return totalTime;
76
- }
77
-
78
- totalMilliseconds() {
79
- return Math.round(this.totalSeconds() * MILLISECONDS_PER_SECOND);
80
- }
81
- }
82
-
83
- function defineTask(taskName, definer, _parent) {
84
- let parentKlass = _parent || TaskBase;
85
-
86
- return function({ application, connection, dbConfig }) {
87
- let time = new TimeHelpers();
88
-
89
- let Klass = definer({
90
- Parent: parentKlass,
91
- application,
92
- connection,
93
- dbConfig,
94
- taskName,
95
- time,
96
- });
97
-
98
- if (typeof Klass.prototype.execute !== 'function')
99
- throw new Error(`Error while defining task ${taskName}: "execute" method is required`);
100
-
101
- Klass.taskName = taskName;
102
-
103
- Klass._frequency = Klass.frequency;
104
- if (Klass._frequency instanceof TimeHelpers)
105
- Klass._frequency = Klass._frequency.totalSeconds();
106
-
107
- Klass._startDelay = Klass.startDelay;
108
- if (Klass._startDelay instanceof TimeHelpers)
109
- Klass._startDelay = Klass._startDelay.totalSeconds();
110
-
111
- if (Nife.instanceOf(Klass._frequency, 'number') && (Klass._frequency <= 0 || !isFinite(Klass._frequency)))
112
- throw new Error(`Error while defining task ${taskName}: "static frequency" must be a valid number of seconds`);
113
- else if (Klass._frequency && !Nife.instanceOf(Klass._frequency, 'number'))
114
- throw new Error(`Error while defining task ${taskName}: "static frequency" must be a valid number of seconds`);
115
-
116
- if (Nife.instanceOf(Klass._startDelay, 'number') && (Klass._startDelay < 0 || !isFinite(Klass._startDelay)))
117
- throw new Error(`Error while defining task ${taskName}: "static startDelay" must be a valid number of seconds`);
118
- else if (Klass._startDelay && !Nife.instanceOf(Klass._startDelay, 'number'))
119
- throw new Error(`Error while defining task ${taskName}: "static startDelay" must be a valid number of seconds`);
120
-
121
- if (typeof Klass.onTaskClassCreate === 'function')
122
- Klass = Klass.onTaskClassCreate(Klass);
123
-
124
- return { [taskName]: Klass };
125
- };
126
- }
127
-
128
- defineTask.TimeHelpers = TimeHelpers;
129
-
130
- module.exports = { defineTask };
@@ -1,25 +0,0 @@
1
- 'use strict';
2
-
3
- const { wrapConfig } = require('./config-utils');
4
-
5
- const {
6
- walkDir,
7
- fileNameWithoutExtension,
8
- } = require('./file-utils');
9
-
10
- const HTTPUtils = require('./http-utils');
11
- const CryptoUtils = require('./crypto-utils');
12
- const TestUtils = require('./test-utils');
13
- const MimeUtils = require('./mime-utils');
14
- const { HTTPInterface } = require('./http-interface');
15
-
16
- module.exports = {
17
- CryptoUtils,
18
- HTTPUtils,
19
- MimeUtils,
20
- TestUtils,
21
- HTTPInterface,
22
- fileNameWithoutExtension,
23
- walkDir,
24
- wrapConfig,
25
- };
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes