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

Alter the HTTP Decorators to set the default status code upon return a request #267

Open
3 tasks
rsaz opened this issue Apr 12, 2024 · 0 comments
Open
3 tasks
Assignees
Labels
enhancement New feature or request

Comments

@rsaz
Copy link
Member

rsaz commented Apr 12, 2024

Description

The purpose of this task is to modify the existing HTTP decorators (@get, @post, @put, @patch, @Head, @delete) used in the ExpressoTS framework to automatically set appropriate default HTTP status codes when a controller method returns a response. This enhancement aims to streamline response handling by ensuring that common HTTP response status codes are automatically applied based on the type of request, thereby reducing boilerplate code and potential for error.

Goals

  • Automation of Response Codes: Automatically set HTTP response codes that are typical for each type of request to improve consistency across the application.
  • Reduction in Manual Code: Decrease the need for developers to manually set status codes in every controller method.
  • Compliance with HTTP Standards: Ensure that the implementation adheres to standard HTTP practices for response codes.

Requirements

Decorator Enhancements:

  • Modify the @post decorator to automatically set the HTTP status code to 201 (Created) unless otherwise specified.
  • Ensure that the @get, @put, @patch, and @delete decorators set appropriate default status codes like 200 (OK), 204 (No Content) for no-return methods, or others as relevant.
  • Allow decorators to accept an optional parameter to override the default status code if a custom response is needed.

Integration with Controller Methods:

  • Ensure that the enhanced decorators correctly interact with the controller methods to set the specified or default HTTP status codes based on the action performed.
  • Validate the correct status code setting even when the methods are asynchronous or involve complex logic.

Testing and Validation:

  • Develop comprehensive tests to ensure that the correct status codes are automatically set for each type of HTTP method.
  • Include tests for scenarios where the default status codes are overridden by custom codes provided by developers.

Documentation:

  • Update the documentation for the HTTP decorators to include information about the default status codes.
  • Provide guidelines on how to override the default status codes with custom values when necessary.

Backward Compatibility:

  • Ensure that these changes do not break existing implementations where specific status codes are manually set within the controllers.
  • Provide a clear migration path for updating existing code to the new decorator system.

Deliverables

  • Updated HTTP decorators with automatic status code setting capabilities.
  • A suite of tests confirming the functionality and robustness of the new decorator behavior.
  • Comprehensive documentation detailing the changes, usage examples, and migration guide for existing codebases.
  • This task will significantly enhance the developer experience by automating a common repetitive task, ensuring consistency, and reducing the potential for errors in HTTP status code management within the ExpressoTS framework.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: 💻 In Development
Development

No branches or pull requests

2 participants