-
-
Notifications
You must be signed in to change notification settings - Fork 13
Code cleanup + Optimization + Refactoring. #121
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
Merged
NeilChaudhari
merged 13 commits into
fairfield-programming:master
from
MassiGy:code-cleanup
May 9, 2022
Merged
Code cleanup + Optimization + Refactoring. #121
NeilChaudhari
merged 13 commits into
fairfield-programming:master
from
MassiGy:code-cleanup
May 9, 2022
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I've imported the express cookie parser and used it as a middelware so as we can access the upcomming cookies directly on the req.cookies.<name-of-the-cookie>. This makes the code more robust and more reliable then creating our own deconstruction algorithm ( with split methods ) to get the cookies. ( Reusing code principle ). Also, with this library setup, our middelwares are more focused about the task at hand then the preps that it needs. ( Abstraction | Removing Side effects ). Hope that is clear. _Please refer to me if something went wrong._ Thanks in advance. Massiles.
With this new code refactor, I've managed to fix the callback hell issue that we had in our controllers. I've acheived that by replacing the `.then` chainning methods with the async/await methodology. Also, to prevent our code from crashes and bugs, I wrapped all the async/await manipulation within a try/catch block to have a nice and clean error handling. (no need to handelError500 anymore ! ). Finnaly, I've noticed during the refactor process that some of the controllers are not well designed, same thing with the API routes. With that been said, I've tried to optimize the most obvious ones by using new ES6 functionnalities like Pomise.all to speed up the code execution. Although, the contollers check and the API routes design review will take me more time up front. Also this will need the attention of the front-end team as well. Hope that is clear. Please refer to me if something went wrong. Thanks in advance. Massiles.
Note: This PR is built on top of #120. Hope that is clear. |
This looks amazing Massiles, Thank you!
…On Sat, May 7, 2022 at 1:01 AM Massiles Ghernaout ***@***.***> wrote:
Note: This PR is built on top of #120
<#120>.
Hope that is clear.
Massiles.
—
Reply to this email directly, view it on GitHub
<#121 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHHTLJWLEOEPSUD7VZ73YGDVIX2LXANCNFSM5VJ3QRFA>
.
You are receiving this because your review was requested.Message ID:
***@***.***>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
hey everyone, hope that you are doing well.
In this PR, I've fixed the callback hell that we had in our backed code-base. Also, I've optimized the code execution for faster and more efficient server state.
Please refer to the git commits for better info.
Hope that is clear.
Massiles.