Skip to content

Commit

Permalink
Use strong-remoting's new TypeRegistry
Browse files Browse the repository at this point in the history
  • Loading branch information
bajtos committed Sep 9, 2016
1 parent 92a5a08 commit 6e1defc
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
3 changes: 3 additions & 0 deletions lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ app.model = function(Model, config) {
this.models().push(Model);

if (isPublic && Model.sharedClass) {
this.remotes().defineObjectType(Model.modelName, function(data) {
return new Model(data);
});
this.remotes().addClass(Model.sharedClass);
if (Model.settings.trackChanges && Model.Change) {
this.remotes().addClass(Model.Change.sharedClass);
Expand Down
5 changes: 0 additions & 5 deletions lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,6 @@ module.exports = function(registry) {
remotingOptions
);

// setup a remoting type converter for this model
RemoteObjects.convert(typeName, function(val) {
return val ? new ModelCtor(val) : val;
});

// support remoting prototype methods
ModelCtor.sharedCtor = function(data, id, fn) {
var ModelCtor = this;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"ejs": "^2.3.1",
"express": "^4.14.0",
"inflection": "^1.6.0",
"loopback-connector-remote": "^2.0.0-alpha.1",
"loopback-connector-remote": "^2.0.0-alpha.2",
"loopback-datasource-juggler": "^3.0.0-alpha.7",
"isemail": "^1.2.0",
"loopback-phase": "^1.2.0",
Expand All @@ -55,7 +55,7 @@
"serve-favicon": "^2.2.0",
"stable": "^0.1.5",
"strong-globalize": "^2.6.2",
"strong-remoting": "^3.0.0-alpha.5",
"strong-remoting": "^3.0.0-alpha.6",
"uid2": "0.0.3",
"underscore.string": "^3.0.3"
},
Expand Down
3 changes: 3 additions & 0 deletions test/relations.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,9 @@ describe('relations - integration', function() {

describe('hasAndBelongsToMany', function() {
beforeEach(function defineProductAndCategoryModels() {
// Disable "Warning: overriding remoting type product"
this.app.remotes()._typeRegistry._options.warnWhenOverridingType = false;

var product = app.registry.createModel(
'product',
{ id: 'string', name: 'string' }
Expand Down
8 changes: 7 additions & 1 deletion test/remote-connector.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ describe('RemoteConnector', function() {
beforeEach: function(done) {
var test = this;
remoteApp = loopback();
remoteApp.set('remoting', { errorHandler: { debug: true, log: false }});
remoteApp.set('remoting', {
errorHandler: { debug: true, log: false },
types: { warnWhenOverridingType: false },
});
remoteApp.use(loopback.rest());
remoteApp.listen(0, function() {
test.dataSource = loopback.createDataSource({
Expand Down Expand Up @@ -51,6 +54,9 @@ describe('RemoteConnector', function() {
beforeEach(function(done) {
var test = this;
remoteApp = this.remoteApp = loopback();
remoteApp.set('remoting', {
types: { warnWhenOverridingType: false },
});
remoteApp.use(loopback.rest());
var ServerModel = this.ServerModel = loopback.PersistedModel.extend('TestModel');

Expand Down

0 comments on commit 6e1defc

Please sign in to comment.