-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
allow for ./server to export express app #3579
allow for ./server to export express app #3579
Conversation
Seems reasonable. This is just for dev harness stuff right? You aren't actually building your backend in the context of a cli app? |
4af11a3
to
b008b47
Compare
yeah the front end guy wants to be able to go ember serve and get live reload during dev but the backend guy doesn't want to change a thing in his code |
why not just use the proxy? HTTP is a wonderful interface. And i don't want to debug peoples backend code that leaked into the front-end project. :P |
so in the example there is no separate front end and back end projects. the express app and the ember app live together in the same project (and get deployed together to beanstalk) but ember-cli is only used for the ember half of it with express handling both the api and the serving of static files (though doesn't have to). cc @knownasilya |
Because if you have custom flags or builds, the proxy doesn't work because it tries to start the server and doesn't know about those extra things. |
Here's an error:
Normally the server is started with |
Ping @stefanpenner |
So I don't dis-agree with the above API improvement, but I do not feel good about your use-case. I will very likely merge this, but i want to understand what is going on here. I am extremely confused why ember-cli can't just proxy to the other node app, or the other node-app proxies back to ember-cli. HTTP is the boundary your app uses in project between the client-side and server-side, why can't it be that in development? |
why not just use those flags when starting ember cli? |
also re-starting app-veyor |
That is an alternative as well. node --harmony_arrow_functions `which ember` serve -pxy http://localhost:7012 but with the proxy you lose out on the server/client live reload, which is the main reason for this change, so that you can have those with a custom express app. |
are you aware that ember-cli has a proxy built-in, that works with live-reload? |
@stefanpenner was not aware. This doesn't work, so this PR is necessary it seams:
|
@stefanpenner I think we are conflating 2 issues here,
|
this I am +1 on
This I would prefer to discourage as ember-cli aims to be a UI development harness, as such the exposed express server really aims to satisfy the following needs:
Although one can build a full-backend into this, it really isn't supported. I would suggest instead utilizing the proxy and HTTP as a boundary between client and server. This prevents us from conflating package.json with client-side + build tool + server side dependencies. It also does the same for the express middleware stack. |
I think we're all on the same page now, and it looks like we uncovered an issue with the proxy feature, which should never try to initialize |
#1530 was added by the groupon folk for this use-case, there are also now generates for this.
|
instead it should do as @calvinmetcalf changed it do via arity check, correct? |
@stefanpenner that might solve it, but in reality |
it does care, because this is were it gets its extended proxy information from. This is a folder ember-cli expects by convention to produce something it understands. |
windows CI issues appear unrelated... |
@stefanpenner seems like there should be a way to change the server root directory that ember-cli expects, configurable in the |
I don't think so, this directory structure is managed by ember-cli. If you add to it, you are invading it's territory and doing so at your own risk. This is a config vs convention trade-off I am very interesting in keeping around. Additionally, opening this to configuration is encouraging behavior I do not feel comfortable with. |
@stefanpenner so you are forcing people to write custom post processing to make their apps work, as well as nesting folders with package.json, and complicating setups that have to work around the ember-cli structure.
Not everyone deploys their client-side code separately, since it complicates infrastructure, deployments and the costs increase, especially if all you do is client work. |
This is unfortunate, as ember-cli code is not something we currently feel comfortable deploying to production. I also do not believe this adds complexity, ember-cli produces static assets that any web-server can host.
|
I am fine actually with calling it |
@stefanpenner but ember-cli code isn't deployed as working, we do a build like you said, and we serve the built assets from our server in We do not run |
the reason for my negative feelings toward this, is I have repeatedly been approached with absolutely crazy scenarios node developers have put themselves in. These scenarios break ember-cli features and make development + upgrading incredibly hard. I also agree, the simplicity of a single project is nice. The solution for this, is put ember-cli managed directory into sub-folder of your server. In theory we could allow mounting ember-cli into some existing middelware stack or similar. This pain almost always manifests as pain towards |
This is not that case. This is the case of using conventions over configuration. I'll put together another issue, because I totally hijacked this thread 😸 |
also, please note I will merge this PR, once tests are actually green. Currently appveyor is trolling.. |
appveyor is failing for unrelated timeouts ... |
allow for ./server to export express app
the whole app factory pattern is a bit foreign for express apps as there is a build in mechanism for adding routes from one express app to another, that is the
.use
method. A common pattern is for the server function to export an app that can then be passed as middleware to somewhere else or get used with http[s].createServer, so this pull adds compatablity for having a server/index that does something likeby checking if the function exported by the server module has a length of 3, i.e. is of the form
which is what an express app is