-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
31 lines (28 loc) · 940 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* jshint node: true */
'use strict';
var AdvancedProxyAddon = require('./lib/ember-cli-advanced-proxy');
/*
* This number represents the position that the proxy middleware holds in
* Ember CLI's normal express middleware stack.
*/
var MIDDLEWARE_TO_REMOVE = 12;
module.exports = {
name: 'ember-cli-advanced-proxy',
serverMiddleware: function(config) {
var app = config.app;
var options = config.options;
var proxyAddon = new AdvancedProxyAddon(config.project);
// HACK: THIS IS A HUGE HACK.
// We shouldn't be removing middleware from the stack
// and it we can match on anonymous functions, so no guarentees
var middlewareStack = (app._router.stack || [])
if(middlewareStack.length > MIDDLEWARE_TO_REMOVE){
middlewareStack.splice(MIDDLEWARE_TO_REMOVE, 1);
app._router.stack = middlewareStack;
}
proxyAddon.serverMiddleware({
app: app,
options: options
});
}
};