mythix 2.0.1 → 2.1.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.0.1",
3
+ "version": "2.1.0",
4
4
  "description": "Mythix is a NodeJS web-app framework",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -30,6 +30,7 @@
30
30
  "express": "^4.17.3",
31
31
  "express-busboy": "^8.0.2",
32
32
  "form-data": "^4.0.0",
33
+ "mythix-orm": "^1.0.4",
33
34
  "nife": "^1.11.3",
34
35
  "prompts": "^2.4.2"
35
36
  }
@@ -61,18 +61,18 @@ module.exports = defineCommand('migrate', ({ Parent }) => {
61
61
  return migrationFiles.slice((isRollback) ? index : index + 1);
62
62
  }
63
63
 
64
- async executeMigration(dbConnection, migrationFileName, useTransaction, rollback) {
64
+ async executeMigration(application, dbConnection, migrationFileName, useTransaction, rollback) {
65
65
  let migration = require(migrationFileName);
66
66
  let startTime = Nife.now();
67
67
 
68
68
  if (rollback) {
69
- await migration.down(dbConnection);
69
+ await migration.down(dbConnection, application);
70
70
  await this.removeMigrationFromDB(migration.MIGRATION_ID);
71
71
 
72
72
  let seconds = ((Nife.now() - startTime) / MILLISECONDS_PER_SECOND).toFixed(2);
73
73
  console.log(`Rolled back migration ${migrationFileName} successfully in ${seconds} seconds`);
74
74
  } else {
75
- await migration.up(dbConnection);
75
+ await migration.up(dbConnection, application);
76
76
  await this.storeSuccessfulMigrationToDB(migration.MIGRATION_ID);
77
77
 
78
78
  let seconds = ((Nife.now() - startTime) / MILLISECONDS_PER_SECOND).toFixed(2);
@@ -130,7 +130,7 @@ module.exports = defineCommand('migrate', ({ Parent }) => {
130
130
  else
131
131
  console.log(`Running migration ${migrationFileName}...`);
132
132
 
133
- this.executeMigration(dbConnection, migrationFileName, useTransaction, rollback).then(
133
+ this.executeMigration(application, dbConnection, migrationFileName, useTransaction, rollback).then(
134
134
  () => nextMigration(doneCallback, index + 1),
135
135
  (error) => {
136
136
  console.error(`Error while running migration ${migrationFileName}: `, error);
@@ -143,6 +143,22 @@ class ControllerBase {
143
143
  this.response.cookie(name, ('' + value), options || {});
144
144
  }
145
145
 
146
+ getHeader(name) {
147
+ return this.request.headers[name];
148
+ }
149
+
150
+ getHeaders(_names) {
151
+ let names = Nife.toArray(_names).filter(Boolean);
152
+ let headers = {};
153
+
154
+ for (let i = 0, il = names.length; i < il; i++) {
155
+ let name = names[i];
156
+ headers[name] = this.getHeader(name);
157
+ }
158
+
159
+ return headers;
160
+ }
161
+
146
162
  setHeader(name, value) {
147
163
  this.response.header(name, value);
148
164
  }
@@ -175,7 +175,7 @@ class HTTPServer {
175
175
  () => rootNext(),
176
176
  (error) => {
177
177
  if (!(error instanceof HTTPBaseError))
178
- this.getApplication().error('Error in middleware: ', error);
178
+ this.getApplication().getLogger().error('Error in middleware: ', error);
179
179
  },
180
180
  );
181
181
  }