Skip to content

Commit

Permalink
feat: update to support both loopback 3.x and 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Kirkpatrick authored and Tom Kirkpatrick committed Jun 14, 2017
1 parent cf41441 commit d0c26e6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
7 changes: 7 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ module.exports = function(app, options) {
migrationModelSettings.acls = migrationMapModelSettings.acls = options.acls;
}

// Support for loopback 2.x.
if (app.loopback.version.startsWith(2)) {
Object.keys(migrationModelSettings.methods).forEach(key => {
migrationModelSettings.methods[key].isStatic = true;
});
}

debug('Creating Migration model using settings: %o', migrationModelSettings);
var MigrationModel = dataSource.createModel(
migrationDef.name,
Expand Down
2 changes: 1 addition & 1 deletion lib/models/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var debug = require('debug')('loopback-component-migrate');
var path = require('path');
var fs = require('fs');
var assert = require('assert');
var utils = require('loopback-datasource-juggler/lib/utils');
var utils = require('loopback/lib/utils');
var util = require('util');

module.exports = function(Migration, options) {
Expand Down
18 changes: 17 additions & 1 deletion test/fixtures/simple-app/server/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
{
"restApiRoot": "/api",
"host": "localhost",
"host": "0.0.0.0",
"port": 3000,
"remoting": {
"context": false,
"rest": {
"normalizeHttpPath": false,
"xml": false
},
"json": {
"strict": false,
"limit": "100kb"
},
"urlencoded": {
"extended": true,
"limit": "100kb"
},
"cors": false
},
"legacyExplorer": false
}

0 comments on commit d0c26e6

Please sign in to comment.