Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,20 @@ module.exports = {
},

use: function (location, service) {
var hasServiceMethod = function (name) {
return typeof service !== 'undefined' && typeof service[name] === 'function';

var hasMethod = function() {
return _.some(arguments, function(name) {
return (service && typeof service[name] === 'function');
});
};

// Check for service (any object with at least one service method)
if (_.some(this.methods, hasServiceMethod)) {
return this.service(location, service);
if(hasMethod('handle', 'set') || !hasMethod.apply(null, this.methods)) {
return this._super.apply(this, arguments);
}

// Pass to the original express app
return this._super.apply(this, arguments);
return this.service(location, service);

},

lookup: function (location) {
Expand Down
13 changes: 13 additions & 0 deletions test/application.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ var fs = require('fs');

var feathers = require('../lib/feathers');

describe("Express application", function() {

it("should use express apps", function() {
var app = feathers();
var child = feathers();

app.use('/path', child);
assert.equal(child.route, '/path');
});

});


describe('Feathers application', function () {
it('registers service and looks it up with and without leading and trailing slashes', function () {
var dummyService = {
Expand Down