From 08846517798e4bdc51bc32d16770be87dbe9b0f0 Mon Sep 17 00:00:00 2001 From: David Luecke Date: Tue, 3 Feb 2015 20:20:24 -0700 Subject: [PATCH 1/5] Use Uberproto extended instance when creating services. --- lib/application.js | 9 +++------ lib/mixins/promise.js | 6 ++++-- test/mixins/event.test.js | 2 +- test/mixins/promise.test.js | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/application.js b/lib/application.js index 9520afd0f8..4d3b86f3dd 100644 --- a/lib/application.js +++ b/lib/application.js @@ -1,6 +1,8 @@ 'use strict'; -var Proto = require('uberproto'); +var Proto = require('uberproto').extend({ + create: null +}); var _ = require('lodash'); var mixins = require('./mixins'); @@ -8,11 +10,6 @@ var stripSlashes = function (name) { return name.replace(/^\/|\/$/g, ''); }; -// We do not want to support Uberproto's create functionality -// Since our service methods have a method with the same name -Proto._create = Proto.create; -delete Proto.create; - module.exports = { init: function () { _.extend(this, { diff --git a/lib/mixins/promise.js b/lib/mixins/promise.js index 6588599231..4449250614 100644 --- a/lib/mixins/promise.js +++ b/lib/mixins/promise.js @@ -19,8 +19,10 @@ var makeWrapper = function() { module.exports = function (service) { if (typeof service.mixin === 'function') { - var mixin = _.transform(_.pick(service, this.methods), function(result, num, key) { - result[key] = makeWrapper(); + var mixin = _.transform(_.pick(service, this.methods), function(result, value, key) { + if(typeof value === 'function') { + result[key] = makeWrapper(); + } }); service.mixin(mixin); diff --git a/test/mixins/event.test.js b/test/mixins/event.test.js index 744b6bb9af..dbf20dc7a0 100644 --- a/test/mixins/event.test.js +++ b/test/mixins/event.test.js @@ -5,7 +5,7 @@ var _ = require('lodash'); var Proto = require('uberproto'); var mixinEvent = require('../../lib/mixins/event'); var EventMixin = mixinEvent.Mixin; -var create = Proto._create; +var create = Proto.create; describe('Event mixin', function () { it('initializes', function () { diff --git a/test/mixins/promise.test.js b/test/mixins/promise.test.js index 6bd63f7df9..e8e1927ea4 100644 --- a/test/mixins/promise.test.js +++ b/test/mixins/promise.test.js @@ -2,7 +2,7 @@ var assert = require('assert'); var Proto = require('uberproto'); -var create = Proto._create; +var create = Proto.create; var q = require('q'); var _ = require('lodash'); From b56a9b506694b45186990c0d5cf3a6c749e1dc82 Mon Sep 17 00:00:00 2001 From: David Luecke Date: Tue, 3 Feb 2015 20:35:46 -0700 Subject: [PATCH 2/5] Switch Primus to Websockets. --- package.json | 5 ++--- test/providers/primus.test.js | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index a871e57d49..9322334fc5 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "express": "^4.0.0", "body-parser": "^1.0.2", "feathers-errors": ">=0.2.0", - "lodash": "^2.4.1", + "lodash": "^3.1.0", "primus": "^2.4.0", "primus-emitter": "^3.0.2", "rubberduck": "^1.0.0", @@ -55,7 +55,6 @@ "q": "^1.0.1", "request": "^2.x", "socket.io-client": "^1.0.0", - "sockjs": "^0.3.9", - "sockjs-client-node": "^0.1.1" + "ws": "^0.7.1" } } diff --git a/test/providers/primus.test.js b/test/providers/primus.test.js index 0cd851032e..56a236329b 100644 --- a/test/providers/primus.test.js +++ b/test/providers/primus.test.js @@ -12,13 +12,13 @@ describe('Primus provider', function () { var server, socket, app, socketParams = { user: { name: 'David' }, - provider: 'sockjs' + provider: 'websockets' }; before(function () { app = feathers() .configure(feathers.primus({ - transformer: 'sockjs' + transformer: 'websockets' }, function(primus) { socket = new primus.Socket('http://localhost:7888'); From 55f8819837896e2aacf555e034ede132b46b2e13 Mon Sep 17 00:00:00 2001 From: David Luecke Date: Tue, 3 Feb 2015 19:54:51 -0700 Subject: [PATCH 3/5] Make sure that mixins are specific to each new app. --- lib/application.js | 2 +- lib/mixins/index.js | 10 ++++++---- test/application.test.js | 10 ++++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/application.js b/lib/application.js index 4d3b86f3dd..24ae4bde4d 100644 --- a/lib/application.js +++ b/lib/application.js @@ -14,7 +14,7 @@ module.exports = { init: function () { _.extend(this, { methods: ['find', 'get', 'create', 'update', 'patch', 'remove'], - mixins: mixins, + mixins: mixins(), services: {}, providers: [], _setup: false diff --git a/lib/mixins/index.js b/lib/mixins/index.js index 9ab12c36ad..1e3eff11a6 100644 --- a/lib/mixins/index.js +++ b/lib/mixins/index.js @@ -1,6 +1,8 @@ 'use strict'; -module.exports = [ - require('./promise'), - require('./event') -]; +module.exports = function() { + return [ + require('./promise'), + require('./event') + ]; +}; diff --git a/test/application.test.js b/test/application.test.js index 5d938c742e..3b5f088757 100644 --- a/test/application.test.js +++ b/test/application.test.js @@ -293,4 +293,14 @@ describe('Feathers application', function () { }); }); }); + + it('mixins are unique to one application', function() { + var app = feathers(); + app.mixins.push(function() {}); + assert.equal(app.mixins.length, 3); + + var otherApp = feathers(); + otherApp.mixins.push(function() {}); + assert.equal(otherApp.mixins.length, 3); + }); }); From 0237a36b0387104114c9efbebfbce9a864bfd38d Mon Sep 17 00:00:00 2001 From: David Luecke Date: Tue, 3 Feb 2015 20:50:31 -0700 Subject: [PATCH 4/5] Updating changelog for v1.0.2. --- changelog.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/changelog.md b/changelog.md index 39eedb6957..728da7458f 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,10 @@ ## Changelog +__1.0.2__ + +- Use Uberproto extended instance when creating services ([#105](https://github.com/feathersjs/feathers/pull/105)) +- Make sure that mixins are specific to each new app ([#104](https://github.com/feathersjs/feathers/pull/104)) + __1.0.1__ - Rename Uberproto .create to avoid conflicts with service method ([#100](https://github.com/feathersjs/feathers/pull/100), [#99](https://github.com/feathersjs/feathers/issues/99)) From 1573f72b0f258125cbe2ade68609486cb634df6d Mon Sep 17 00:00:00 2001 From: David Luecke Date: Tue, 3 Feb 2015 20:54:01 -0700 Subject: [PATCH 5/5] release 1.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9322334fc5..fd66298d32 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "feathers", "description": "Shared REST and real-time APIs with Express.", - "version": "1.0.1", + "version": "1.0.2", "homepage": "http://feathersjs.com", "repository": { "type": "git",