Skip to content

Commit

Permalink
Merge pull request #105 from feathersjs/proto-fix
Browse files Browse the repository at this point in the history
Use Uberproto extended instance when creating services
  • Loading branch information
daffl committed Feb 4, 2015
2 parents 250d17d + b56a9b5 commit c6105c6
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 15 deletions.
9 changes: 3 additions & 6 deletions lib/application.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
'use strict';

var Proto = require('uberproto');
var Proto = require('uberproto').extend({
create: null
});
var _ = require('lodash');

var mixins = require('./mixins');
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, {
Expand Down
6 changes: 4 additions & 2 deletions lib/mixins/promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
}
2 changes: 1 addition & 1 deletion test/mixins/event.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
2 changes: 1 addition & 1 deletion test/mixins/promise.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
4 changes: 2 additions & 2 deletions test/providers/primus.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down

0 comments on commit c6105c6

Please sign in to comment.