-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[refactor] move to leaner architecture
- Loading branch information
Showing
5 changed files
with
53 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,10 @@ | ||
/*! | ||
* | ||
* Charon the demon, with the eyes of glede, | ||
* Beckoning to them, collects them all together, | ||
* Beats with his oar whoever lags behind | ||
* Dante - The Divine Comedy (Canto III) | ||
* | ||
*/ | ||
|
||
module.exports = require('./lib/caronte'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,34 @@ | ||
var caronte = exports; | ||
var caronte = exports, | ||
web = require('./passes/web'); | ||
ws = require('./passes/ws'); | ||
|
||
caronte.createWebProxy = createRightProxy('web'); | ||
caronte.createWsProxy = createRightProxy('ws'); | ||
|
||
function createRightProxy(type) { | ||
passes = type === 'ws' ? ws : web; | ||
return function(options) { | ||
|
||
passes = Object.keys(passes).map(function(pass) { | ||
return passes[pass]; | ||
}); | ||
|
||
return function(req, res) { | ||
var self = this, | ||
ev = 'caronte:' + type + ':'; | ||
|
||
self.emit(ev + 'begin', req, res); | ||
|
||
passes.forEach(function(pass) { | ||
var event = ev + pass.name.toLowerCase(); | ||
|
||
self.emit(event + 'begin', req, res); | ||
pass(req, res, options); | ||
self.emit(event + 'end'); | ||
}); | ||
|
||
self.emit(ev + 'end'); | ||
}; | ||
}; | ||
} | ||
|
||
caronte.createWebProxy = require('./web'); | ||
caronte.createWsProxy = require('./ws'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.