Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: @feathersjs/express allow to pass an existing Express application instance #1446

Merged
merged 3 commits into from Jul 10, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions packages/express/lib/index.js
Expand Up @@ -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') {
Expand All @@ -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) {
Expand Down
7 changes: 7 additions & 0 deletions packages/express/test/index.test.js
Expand Up @@ -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');
});
Expand Down