-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1446 from bcardarella/bc-middleware-addons
Extracted middleware to addons
- Loading branch information
Showing
17 changed files
with
128 additions
and
54 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
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
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict'; | ||
|
||
function LiveReloadAddon(project) { | ||
this.project = project; | ||
this.name = 'live-reload-middleware'; | ||
} | ||
|
||
LiveReloadAddon.prototype.serverMiddleware = function(options) { | ||
var app = options.app; | ||
options = options.options; | ||
|
||
if (options.liveReload === true) { | ||
var livereloadMiddleware = require('connect-livereload'); | ||
app.use(livereloadMiddleware({ | ||
port: options.loveReloadPort | ||
})); | ||
} | ||
}; | ||
|
||
module.exports = LiveReloadAddon; |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "live-reload-middleware", | ||
"keywords": [ | ||
"ember-addon" | ||
] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
|
||
function ProxyServerAddon(project) { | ||
this.project = project; | ||
this.name = 'proxy-server-middleware'; | ||
} | ||
|
||
ProxyServerAddon.prototype.serverMiddleware = function(options) { | ||
var app = options.app; | ||
options = options.options; | ||
|
||
if (options.proxy) { | ||
var urlOpts = require('url').parse(options.proxy); | ||
var proxy = require('proxy-middleware'); | ||
|
||
options.ui.write('Proxying to ' + options.proxy + '\n'); | ||
app.use(proxy(urlOpts)); | ||
} | ||
}; | ||
|
||
module.exports = ProxyServerAddon; |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "proxy-server-middleware", | ||
"keywords": [ | ||
"ember-addon" | ||
] | ||
} |
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict'; | ||
|
||
function ServeFilesAddon(project) { | ||
this.project = project; | ||
this.name = 'serve-files-middleware'; | ||
} | ||
|
||
ServeFilesAddon.prototype.serverMiddleware = function(options) { | ||
var app = options.app; | ||
options = options.options; | ||
|
||
var serveFilesMiddleware = require('./serve-files'); | ||
app.use(serveFilesMiddleware({ | ||
watcher: options.watcher, | ||
baseURL: options.baseURL | ||
})); | ||
}; | ||
|
||
module.exports = ServeFilesAddon; |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "serve-files-middleware", | ||
"keywords": [ | ||
"ember-addon" | ||
] | ||
} |
2 changes: 1 addition & 1 deletion
2
lib/tasks/server/middleware/serve-files.js → ...ver/middleware/serve-files/serve-files.js
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
|
||
var http = require('http'); | ||
|
||
var ProxyServer = function() { | ||
var _this = this; | ||
this.called = false; | ||
this.lastReq = null; | ||
this.httpServer = http.createServer(function(req, res) { | ||
_this.called = true; | ||
_this.lastReq = req; | ||
res.writeHead(200, {'Content-Type': 'text/plain'}); | ||
res.end('okay'); | ||
}); | ||
this.httpServer.listen(3001); | ||
}; | ||
|
||
module.exports = ProxyServer; |
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
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