Skip to content

Commit

Permalink
Removed monkeypatching http
Browse files Browse the repository at this point in the history
  • Loading branch information
Iyanu-Tomiwa authored and rwky committed Jan 22, 2019
1 parent f99d8a8 commit f8aabfd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 19 deletions.
17 changes: 0 additions & 17 deletions lib/framework/connect.js
Expand Up @@ -3,11 +3,8 @@
*/
/* eslint-disable camelcase, no-proto, no-shadow */

const http = require('http');
const initialize = require('../middleware/initialize');
const authenticate = require('../middleware/authenticate');
const IncomingMessageExt = require('../http/request');

/**
* Framework support for Connect/Express.
*
Expand All @@ -22,22 +19,8 @@ const IncomingMessageExt = require('../http/request');

// eslint-disable-next-line no-multi-assign, func-names
exports = module.exports = function () {
// HTTP extensions.
exports.__monkeypatchNode();

return {
initialize,
authenticate,
};
};

exports.__monkeypatchNode = function __monkeypatchNode() {
http.IncomingMessage.prototype.logIn = IncomingMessageExt.logIn;
http.IncomingMessage.prototype.login = http.IncomingMessage.prototype.logIn;

http.IncomingMessage.prototype.logOut = IncomingMessageExt.logOut;
http.IncomingMessage.prototype.logout = http.IncomingMessage.prototype.logOut;

http.IncomingMessage.prototype.isAuthenticated = IncomingMessageExt.isAuthenticated;
http.IncomingMessage.prototype.isUnauthenticated = IncomingMessageExt.isUnauthenticated;
};
7 changes: 6 additions & 1 deletion lib/http/request.js
Expand Up @@ -4,10 +4,13 @@

// var http = require('http')
// , req = http.IncomingMessage.prototype;
const http = require('http');

const req = http.IncomingMessage.prototype;

/* eslint-disable no-multi-assign, camelcase, no-proto, no-shadow */

const req = exports = module.exports = {};
// const req = exports = module.exports = {};

/**
* Initiate a login session for `user`.
Expand Down Expand Up @@ -104,3 +107,5 @@ req.isAuthenticated = function isAuthenticated() {
req.isUnauthenticated = function isUnauthenticated() {
return !this.isAuthenticated();
};

module.exports = req;
2 changes: 1 addition & 1 deletion test/http/request.test.js
Expand Up @@ -6,7 +6,7 @@
const http = require('http');
const Passport = require('../..').Passport;

require('../../lib/framework/connect').__monkeypatchNode();
require('../../lib/framework/connect')();


describe('http.ServerRequest', () => {
Expand Down

0 comments on commit f8aabfd

Please sign in to comment.