mythix 2.5.1 → 2.5.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 +1 -1
- package/src/application.js +4 -1
- package/src/cli/cli-utils.js +1 -1
- package/src/cli/routes-command.js +1 -1
- package/src/controllers/controller-module.js +1 -1
- package/src/controllers/generate-client-api-interface.js +1 -1
- package/src/http-server/http-server.js +7 -1
- package/src/index.js +2 -1
- package/src/models/model-module.js +1 -1
- package/src/tasks/task-module.js +1 -1
- package/src/utils/test-utils.js +2 -2
package/package.json
CHANGED
package/src/application.js
CHANGED
|
@@ -232,7 +232,10 @@ class Application extends EventEmitter {
|
|
|
232
232
|
try {
|
|
233
233
|
let appOptions = this.getOptions();
|
|
234
234
|
|
|
235
|
-
|
|
235
|
+
let config = require(configPath);
|
|
236
|
+
if (config.__esModule)
|
|
237
|
+
config = config['default'];
|
|
238
|
+
|
|
236
239
|
return wrapConfig(Object.assign({}, config || {}, { environment: (appOptions.environment || config.environment || 'development')}));
|
|
237
240
|
} catch (error) {
|
|
238
241
|
this.getLogger().error(`Error while trying to load application configuration ${configPath}: `, error);
|
package/src/cli/cli-utils.js
CHANGED
|
@@ -80,7 +80,7 @@ class ControllerModule extends BaseModule {
|
|
|
80
80
|
|
|
81
81
|
try {
|
|
82
82
|
let controllerGenerator = require(controllerFile);
|
|
83
|
-
if (controllerGenerator
|
|
83
|
+
if (controllerGenerator.__esModule)
|
|
84
84
|
controllerGenerator = controllerGenerator['default'];
|
|
85
85
|
|
|
86
86
|
Object.assign(controllers, controllerGenerator(args));
|
|
@@ -374,7 +374,7 @@ function generateRoutes(_routes, _options) {
|
|
|
374
374
|
if (clientOptions == null) {
|
|
375
375
|
var contentType = route.accept;
|
|
376
376
|
if (Nife.isEmpty(contentType))
|
|
377
|
-
contentType = 'application/json
|
|
377
|
+
contentType = 'application/json';
|
|
378
378
|
else if (Array.isArray(contentType))
|
|
379
379
|
contentType = contentType[0];
|
|
380
380
|
|
|
@@ -434,7 +434,13 @@ class HTTPServer {
|
|
|
434
434
|
app.use((request, response, next) => {
|
|
435
435
|
if ((/application\/json/i).test(request.headers['content-type']) && Buffer.isBuffer(request.body)) {
|
|
436
436
|
let bodyStr = request.body.toString('utf8');
|
|
437
|
-
request._rawBody =
|
|
437
|
+
request._rawBody = bodyStr;
|
|
438
|
+
|
|
439
|
+
try {
|
|
440
|
+
request.body = JSON.parse(bodyStr);
|
|
441
|
+
} catch (error) {
|
|
442
|
+
request.body = bodyStr;
|
|
443
|
+
}
|
|
438
444
|
}
|
|
439
445
|
|
|
440
446
|
next();
|
package/src/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const { Application } = require('./application');
|
|
4
|
+
const { Logger } = require('./logger');
|
|
4
5
|
const ModelScope = require('./models');
|
|
5
6
|
const HTTPServerScope = require('./http-server');
|
|
6
7
|
const ControllerScope = require('./controllers');
|
|
7
8
|
const CLIUtilsScope = require('./cli');
|
|
8
9
|
const TasksScope = require('./tasks');
|
|
9
|
-
const Logger = require('./logger');
|
|
10
10
|
const Utils = require('./utils');
|
|
11
11
|
const Modules = require('./modules');
|
|
12
12
|
|
|
@@ -14,6 +14,7 @@ module.exports = {
|
|
|
14
14
|
defineCommand: CLIUtilsScope.defineCommand,
|
|
15
15
|
defineController: ControllerScope.defineController,
|
|
16
16
|
defineModel: ModelScope.defineModel,
|
|
17
|
+
registerModel: ModelScope.registerModel,
|
|
17
18
|
defineTask: TasksScope.defineTask,
|
|
18
19
|
|
|
19
20
|
CLI: CLIUtilsScope,
|
|
@@ -86,7 +86,7 @@ class ModelModule extends BaseModule {
|
|
|
86
86
|
|
|
87
87
|
try {
|
|
88
88
|
let modelGenerator = require(modelFile);
|
|
89
|
-
if (modelGenerator
|
|
89
|
+
if (modelGenerator.__esModule)
|
|
90
90
|
modelGenerator = modelGenerator['default'];
|
|
91
91
|
|
|
92
92
|
Object.assign(models, modelGenerator(args));
|
package/src/tasks/task-module.js
CHANGED
|
@@ -91,7 +91,7 @@ class TaskModule extends BaseModule {
|
|
|
91
91
|
|
|
92
92
|
try {
|
|
93
93
|
let taskGenerator = require(taskFile);
|
|
94
|
-
if (taskGenerator
|
|
94
|
+
if (taskGenerator.__esModule)
|
|
95
95
|
taskGenerator = taskGenerator['default'];
|
|
96
96
|
|
|
97
97
|
Object.assign(tasks, taskGenerator(args));
|
package/src/utils/test-utils.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
const Nife = require('nife');
|
|
6
6
|
const { Utils } = require('mythix-orm');
|
|
7
|
-
const Logger
|
|
8
|
-
const DatabaseModule
|
|
7
|
+
const { Logger } = require('../logger');
|
|
8
|
+
const { DatabaseModule } = require('../modules/database-module');
|
|
9
9
|
const { HTTPInterface } = require('./http-interface');
|
|
10
10
|
const { HTTPServerModule } = require('../http-server/http-server-module');
|
|
11
11
|
|