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(route)!: change method handling #588

Merged
merged 3 commits into from
Jun 29, 2024

Conversation

kyranet
Copy link
Member

@kyranet kyranet commented Jun 29, 2024

  • 🚀 Added support for specifying a route's supported methods in the options
  • 🚀 Added support for specifying a route's method in the file name
  • ⌨️ Added MediaParser.Request and MediaParser.Response type aliases
  • ⌨️ Added Middleware.Request and Middleware.Response type aliases
  • 🏠 Hardened the onLoad and onUnload hooks from the Route class
  • 🔥 BREAKING CHANGE: The headers middleware now uses the supported HTTP methods from the route or the store instead of sending all supported methods
  • 🔥 BREAKING CHANGE: Changed the method handling in the Route class to not be keyed by the method name, sending all requests to the run method. This allows for more flexibility in the route handling
  • 🔥 BREAKING CHANGE: Writing the name of a file as <name>.<method>.ts will now set <method> as a method for the route

👀
Code_Q58K8JkR3H

@kyranet kyranet requested review from favna and vladfrangu as code owners June 29, 2024 06:57
@kyranet kyranet force-pushed the refactor/change-method-handling branch from bd104f9 to ca2412b Compare June 29, 2024 07:01
Copy link

codecov bot commented Jun 29, 2024

Codecov Report

Attention: Patch coverage is 70.14925% with 60 lines in your changes missing coverage. Please review.

Project coverage is 36.87%. Comparing base (d27dc1c) to head (c229fe5).

Files Patch % Lines
packages/api/src/lib/structures/Route.ts 79.10% 14 Missing ⚠️
packages/api/src/middlewares/headers.ts 31.57% 13 Missing ⚠️
...ages/api/src/lib/structures/RouteLoaderStrategy.ts 45.45% 12 Missing ⚠️
packages/api/src/lib/structures/RouteStore.ts 42.85% 8 Missing ⚠️
packages/api/src/listeners/PluginServerRequest.ts 0.00% 5 Missing ⚠️
packages/api/src/lib/structures/api/CookieStore.ts 0.00% 3 Missing ⚠️
...api/src/listeners/PluginServerMiddlewareSuccess.ts 50.00% 2 Missing ⚠️
packages/api/src/listeners/PluginServerMatch.ts 66.66% 1 Missing ⚠️
packages/api/src/routes/oauth/callback.post.ts 50.00% 1 Missing ⚠️
packages/api/src/routes/oauth/logout.post.ts 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #588      +/-   ##
==========================================
+ Coverage   36.79%   36.87%   +0.08%     
==========================================
  Files         106      107       +1     
  Lines        7738     7767      +29     
  Branches       89       88       -1     
==========================================
+ Hits         2847     2864      +17     
- Misses       4890     4902      +12     
  Partials        1        1              
Flag Coverage Δ
18 36.87% <70.14%> (+0.08%) ⬆️
19 36.87% <70.14%> (+0.08%) ⬆️
20 36.87% <70.14%> (+0.08%) ⬆️
21 36.87% <70.14%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kyranet kyranet force-pushed the refactor/change-method-handling branch 2 times, most recently from 913aaa6 to 74da8e4 Compare June 29, 2024 07:09
Added support for specifying a route's supported methods in the options
Added support for specifying a route's method in the file name
Added `MediaParser.Request` and `MediaParser.Response` type aliases
Added `Middleware.Request` and `Middleware.Response` type aliases
Hardened the `onLoad` and `onUnload` hooks from the `Route` class

BREAKING CHANGE: The headers middleware now uses the supported HTTP methods from the route or the store instead of sending all supported methods
BREAKING CHANGE: Changed the method handling in the `Route` class to not be keyed by the method name, sending all requests to the `run` method. This allows for more flexibility in the route handling
BREAKING CHANGE: Writing the name of a file as `<name>.<method>.ts` will now set `<method>` as a method for the route
packages/api/src/lib/structures/Route.ts Outdated Show resolved Hide resolved
Copy link
Member

@favna favna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

misclicked

@kyranet kyranet requested a review from favna June 29, 2024 12:46
favna
favna previously approved these changes Jun 29, 2024
@kyranet kyranet merged commit 08a81b1 into main Jun 29, 2024
13 checks passed
@kyranet kyranet deleted the refactor/change-method-handling branch June 29, 2024 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants