sunnah-com / corrections

55 stars 35 forks source link

Refactor application to factory pattern #82

Closed businessglitch closed 3 years ago

businessglitch commented 3 years ago
  1. Main benefits of the application factory pattern is the ability to test the instance of the application with different configs https://flask.palletsprojects.com/en/2.0.x/patterns/appfactories/
  2. Utilize blueprint's url prefix's
  3. Create a separate folder for blueprints which contains that blueprint's respective model and views
  4. For production purposes, add an instance folder which contains config (https://flask.palletsprojects.com/en/2.0.x/config/)
  5. encapsulate and json response in a separate function in lib (jsonify(create_response_message(False, e.response["Error"]["Message"]))) jsonify used multiple times
hasankhan commented 3 years ago

I think that's a good idea. We have a few uses of the global app object outside the request context, that would need to be fixed first.

Please go ahead with the proposal but kindly send a separate pull request for each small change instead of one pull request for everything. That helps follow the changes in each commit. Each pull request should have a single squashed commit with all the review feedback addressed in the same commit.

1 PR can be for just replacing the use of global app object with helper methods called from inside the request context 1 PR can be for creating the factory method for app 1 PR can be for using the URL prefix for blueprints 1 PR can just be re-organizing the files i.e. separate blueprint folder etc but without making any changes to the contents of the file 1 PR can be for the json response helper method mentioned above.

JazakAllah khair! all good suggestions.

businessglitch commented 3 years ago

Perfect, that sounds like a plan and will definitely break it out to smaller PR's.

hasankhan commented 3 years ago

@businessglitch is there any update on this? If you're no longer available, please let us know and we'll close the issue.