Skip to content

Commit 853a6b0

Browse files
authored
feat: @feathersjs/express allow to pass an existing Express application instance (#1446)
1 parent 703611e commit 853a6b0

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

packages/express/lib/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ const authentication = require('./authentication');
77
const notFound = require('./not-found-handler');
88
const rest = require('./rest');
99

10-
function feathersExpress (feathersApp) {
10+
function feathersExpress (feathersApp, expressApp = express()) {
1111
if (!feathersApp) {
12-
return express();
12+
return expressApp;
1313
}
1414

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

23-
const expressApp = express();
2423
// An Uberproto mixin that provides the extended functionality
2524
const mixin = {
2625
use (location) {

packages/express/test/index.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ describe('@feathersjs/express', () => {
2929
assert.strictEqual(typeof app, 'function');
3030
});
3131

32+
it('allows to use an existing Express instance', () => {
33+
const expressApp = express();
34+
const app = expressify(feathers(), expressApp);
35+
36+
assert.strictEqual(app, expressApp);
37+
});
38+
3239
it('exports `express.rest`', () => {
3340
assert.ok(typeof expressify.rest === 'function');
3441
});

0 commit comments

Comments
 (0)