-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Refactors PushController and FilesController to support multiple apps #501
Refactors PushController and FilesController to support multiple apps #501
Conversation
@flovilmart updated the pull request. |
There are few things worth discussing here - the flow that we are trying to get into is that FIlesController/PushController/etc don't actually know about HTTP layer at all, they contain a business logic for retrieving files or sending push notifications. Tight coupling of request/response/next with them is an interim state, that I am trying to move us away from. The goal here is that we will be able to unit test everything absolutely without relying on integration or e2e test as a first resort, but have unit tests for the whole server. Another important piece - Routers actually follow the same architecture. A single class per endpoint type (say classes or files), which encapsulates logic for handling HTTP layer, and can talk to Controllers to figure out the logic. All of the above (Controllers/Adapters/Routers) are instances of different classes, so we can reuse logic with subclassing/etc, as well as the entire thing becomes purely functional, since we have a single consistent state that is created at the point of construction of the server. I might be wrong in my assumptions here, but this architecture proved to be very helpful in terms of testability, modularization and stability. It's closely modeled after what me and SDK team designed to power all of our SDKs. So... Let's discuss it... I am looking for your feedback on this, so we can move together faster. |
So with the current implementation we're completely off that target. What we should have is
|
Yup, that example above is perfect! I couldn't write better in my 3 week-old knowledge of javascript. :) There is a lot of places where we are off target, but it's ok. |
I'm revamping the original Classes, User, Installation etc... with that pattern, I'll start applying it across the board :) |
@flovilmart updated the pull request. |
Looks amazing! Should I just merge it now or there is more things coming in this one? |
I'm doing all routers that can be, Functions, Schemas as well |
Lovely, sounds good. Ping me when you need a review on this. FilesController is quite tricky, there is direct dependency on non-promise based router, so there is more changes needed for it, I might as well try to tackle it tonight. |
Yeah, and PushController too :) That,S why I don,t want to touch them yet :) |
@flovilmart updated the pull request. |
And you got it! :) Good luck! The refactoring is mostly external, placed some todos here and there for some of the internals to be updated at a later date. |
@nlutsenko and if you're curious, have a look there: https://github.com/flovilmart/__AppStack__/ |
And looks great, merging in a moment... |
Refactors PushController and FilesController to support multiple apps
@nlutsenko, started that in November last year in the eventuality I had to move servers away from Parse |
effort to decouple the heavy lifting of #263