Skip to content

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
merged 13 commits into from
May 9, 2022

Conversation

MassiGy
Copy link
Member

@MassiGy MassiGy commented May 7, 2022

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.

MassiGy added 13 commits May 4, 2022 12:39
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.
@MassiGy
Copy link
Member Author

MassiGy commented May 7, 2022

Note: This PR is built on top of #120.

Hope that is clear.
Massiles.

@NeilChaudhari NeilChaudhari merged commit dbec41a into fairfield-programming:master May 9, 2022
@NeilChaudhari
Copy link
Member

NeilChaudhari commented Oct 11, 2022 via email

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.

2 participants