Skip to content
This repository has been archived by the owner on Mar 22, 2022. It is now read-only.

Commit

Permalink
Remove dependency on Express and Express middleware (#683)
Browse files Browse the repository at this point in the history
  • Loading branch information
daffl authored Jun 28, 2018
1 parent 1f0942a commit b9ca32f
Show file tree
Hide file tree
Showing 24 changed files with 5 additions and 1,092 deletions.
68 changes: 0 additions & 68 deletions lib/express/authenticate.js

This file was deleted.

31 changes: 0 additions & 31 deletions lib/express/emit-events.js

This file was deleted.

12 changes: 0 additions & 12 deletions lib/express/expose-cookies.js

This file was deleted.

12 changes: 0 additions & 12 deletions lib/express/expose-headers.js

This file was deleted.

23 changes: 0 additions & 23 deletions lib/express/failure-redirect.js

This file was deleted.

17 changes: 0 additions & 17 deletions lib/express/index.js

This file was deleted.

69 changes: 0 additions & 69 deletions lib/express/set-cookie.js

This file was deleted.

18 changes: 0 additions & 18 deletions lib/express/success-redirect.js

This file was deleted.

10 changes: 0 additions & 10 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const Debug = require('debug');
const hooks = require('./hooks');
const express = require('./express');
const passport = require('passport');
const adapter = require('./passport');
const getOptions = require('./options');
Expand Down Expand Up @@ -40,14 +39,6 @@ function init (config = {}) {
app.passport = passport;
// Alias to passport for less keystrokes
app.authenticate = passport.authenticate.bind(passport);
// Expose express request headers to Feathers services and hooks.
app.use(express.exposeHeaders());

if (options.cookie.enabled) {
// Expose express cookies to Feathers services and hooks.
debug('Setting up Express exposeCookie middleware');
app.use(express.exposeCookies());
}

// TODO (EK): Support passing your own service or force
// developer to register it themselves.
Expand Down Expand Up @@ -80,6 +71,5 @@ module.exports = init;
Object.assign(module.exports, {
default: init,
hooks,
express,
service
});
16 changes: 1 addition & 15 deletions lib/service.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const Debug = require('debug');
const merge = require('lodash.merge');
const express = require('./express');

const debug = Debug('@feathersjs/authentication:authentication:service');

Expand Down Expand Up @@ -44,27 +43,14 @@ module.exports = function init (options) {
return function () {
const app = this;
const path = options.path;
const {
successRedirect,
failureRedirect,
setCookie,
emitEvents
} = express;

if (typeof path !== 'string') {
throw new Error(`You must provide a 'path' in your authentication configuration or pass one explicitly.`);
}

debug('Configuring authentication service at path', path);

app.use(
path,
new Service(app, options),
emitEvents(options),
setCookie(options),
successRedirect(),
failureRedirect(options)
);
app.use(path, new Service(app, options));

const service = app.service(path);

Expand Down
Loading

0 comments on commit b9ca32f

Please sign in to comment.