Skip to content

Commit

Permalink
feat: @feathersjs/express allow to pass an existing Express applicati…
Browse files Browse the repository at this point in the history
…on instance (#1446)
  • Loading branch information
daffl authored Jul 10, 2019
1 parent 703611e commit 853a6b0
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/express/lib/index.js
Original file line number Diff line number Diff line change
@@ -7,9 +7,9 @@ const authentication = require('./authentication');
const notFound = require('./not-found-handler');
const rest = require('./rest');

function feathersExpress (feathersApp) {
function feathersExpress (feathersApp, expressApp = express()) {
if (!feathersApp) {
return express();
return expressApp;
}

if (typeof feathersApp.setup !== 'function') {
@@ -20,7 +20,6 @@ function feathersExpress (feathersApp) {
throw new Error(`@feathersjs/express requires an instance of a Feathers application version 3.x or later (got ${feathersApp.version || 'unknown'})`);
}

const expressApp = express();
// An Uberproto mixin that provides the extended functionality
const mixin = {
use (location) {
7 changes: 7 additions & 0 deletions packages/express/test/index.test.js
Original file line number Diff line number Diff line change
@@ -29,6 +29,13 @@ describe('@feathersjs/express', () => {
assert.strictEqual(typeof app, 'function');
});

it('allows to use an existing Express instance', () => {
const expressApp = express();
const app = expressify(feathers(), expressApp);

assert.strictEqual(app, expressApp);
});

it('exports `express.rest`', () => {
assert.ok(typeof expressify.rest === 'function');
});

0 comments on commit 853a6b0

Please sign in to comment.