Skip to content
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

refactor: middleware functions #229

Open
7 tasks done
shon-button opened this issue Apr 18, 2023 · 0 comments
Open
7 tasks done

refactor: middleware functions #229

shon-button opened this issue Apr 18, 2023 · 0 comments
Assignees

Comments

@shon-button
Copy link
Contributor

shon-button commented Apr 18, 2023

Description

Currently, middleware.ts is used to redirect requests based on the authenticated user's jwt and role property.
If adopting v13.2 route changes then middleware.ts code would need modifications of the redirects and these modifications might also be an opportunity to benefit from refactoring the large single function into a utility function that can chain multiple middlewares for better organization.

Impact

Description of the current or future impact of this tech debt and the risks associated with leaving this debt unresolved.

Proposed Solution(s)

Solution 1.

🔗 Chain: Implement multiple middlewares for improved organization

📝 Objective:
Enhance code organization and maintainability by chaining multiple middlewares. This approach streamlines the request processing flow and ensures a clear separation of concerns.

🛠️ Implementation:

  • Integrate a series of middlewares to handle distinct aspects of request processing
  • Order the middlewares logically to achieve a cohesive processing flow
  • Maintain consistent error handling and response handling across middlewares

🚀 Benefits:
Chaining multiple middlewares facilitates modular development, promotes code reusability, and simplifies maintenance. This approach leads to a well-organized codebase that is easier to understand and extend.

User Story:
As a developer working on our web application, I want to chain multiple middlewares to enhance the organization of our request processing flow. This will help improve code maintainability and ensure a clear separation of concerns in our application's middleware handling.

Acceptance Criteria:

  • Given the need to improve code organization, when chaining multiple middlewares, the request should flow through each middleware in a logical sequence.
  • Each middleware in the chain should handle a specific aspect of request processing, such as authentication, validation, authorization, or logging.
  • Middleware functions should be modular and focused on a single responsibility, promoting code reusability and maintainability.
  • Error handling within each middleware should be consistent, ensuring that errors are properly caught, logged, and appropriate responses are sent to the client.
  • The chaining of middlewares should not introduce any unintended side effects or disrupt the overall functionality of the application.
  • The middleware chain should be documented to clearly outline the purpose and order of each middleware, making it easy for other developers to understand and modify as needed.
  • The improved organization of the middleware chain should lead to more readable and understandable code, enabling smoother collaboration among developers.
@shon-button shon-button changed the title middleware auth functions Middleware Functions Chaining Apr 19, 2023
@shon-button shon-button changed the title Middleware Functions Chaining refactor: Middleware Functions Chaining Apr 19, 2023
@shon-button shon-button changed the title refactor: Middleware Functions Chaining refactor: middleware functions Apr 19, 2023
@shon-button shon-button self-assigned this May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: No status
Development

No branches or pull requests

1 participant