Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add middleware concept for addons. #1097

Merged
merged 1 commit into from
Jun 21, 2014

Conversation

rwjblue
Copy link
Member

@rwjblue rwjblue commented Jun 20, 2014

  • Refactors express server to explicitly start the http server. This was
    what it does naturally, but we need access to the raw server to be
    able to teardown the server between tests.
  • Refactor express server to make it a bit more testable.
  • Add addon.serverMiddleware callback function. The addon is called
    with the instance of the express app.
  • Refactor api-stub blueprint (and expected API) so that the express
    app is started in a consistent way. Prior to this, if you had a
    ./server/ folder, your code would create the express app add the
    ember-cli middleware.

Closes #1086.

@rwjblue
Copy link
Member Author

rwjblue commented Jun 20, 2014

/cc @bcardarella

secondCalled = true;
}
}, {
doesntGoBoom: null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To confirm that an addon that does not implement a serverMiddleware method does not throw an error.

@bcardarella
Copy link
Contributor

@rjackson correct me if I'm wrong but this implementation would only allow manipulation of other addon's middleware order. If that is the case does this mean having to change the existing middleware in ember-cli to be addons?

@stefanpenner
Copy link
Contributor

do we need to use a dag to specific the order? like ember initializers? If so we can just lift Ember.DAG and use it here.

@rwjblue
Copy link
Member Author

rwjblue commented Jun 20, 2014

Yes, I believe that we will need to, but plan on adding it across the board in a later PR (likely just in the Project.prototype.initializeAddons function).

I think this will service all of our various plugins better (since it is conceivable that even an asset based plugin will need to be added after or before another).

@WMeldon
Copy link
Contributor

WMeldon commented Jun 20, 2014

Is there a way to access the options from the addons? body-parser for instance breaks the Proxy server. Access to options.proxy can prevent that.

@rwjblue
Copy link
Member Author

rwjblue commented Jun 21, 2014

@WMeldon - Updated to provide options to addons.

@stefanpenner - This look good to you?

@stefanpenner stefanpenner self-assigned this Jun 21, 2014
@stefanpenner
Copy link
Contributor

LGTM

* Refactors express server to explicitly start the http server. This was
  what it does naturally, but we need access to the raw server to be
  able to teardown the server between tests.
* Refactor express server to make it a bit more testable.
* Add `addon.serverMiddleware` callback function.  The addon is called
  with the instance of the express app.
* Refactor `api-stub` blueprint (and expected API) so that the express
  app is started in a consistent way. Prior to this, if you had a
  `./server/` folder, your code would create the `express` app add the `ember-cli`
  middleware.
rwjblue added a commit that referenced this pull request Jun 21, 2014
Add middleware concept for addons.
@rwjblue rwjblue merged commit 2bfc24c into ember-cli:master Jun 21, 2014
@rwjblue rwjblue deleted the addon-middleware branch June 21, 2014 04:16
@stefanpenner
Copy link
Contributor

we will need to consider ordering of these (and other addon injected things)

So when some addons have ordering constraints we can consider a DAG or some other mechanism.

@rwjblue
Copy link
Member Author

rwjblue commented Jun 21, 2014

I am working up a PR that adds the DAG stuff from Ember. I plan on implementing it to the Project.prototype.initializeAddons function so that all addon usages will get to take advantage of it. Then once initializeAddons was called, the project.addons array is already ordered properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

addons support injecting of middleware
4 participants