Skip to content

feat(event-handler): add resolution logic to base router #4349

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

svozza
Copy link
Contributor

@svozza svozza commented Aug 16, 2025

Summary

This PR implements the final resolution logic for the BaseRouter class. The resolve method is no longer abstract and has a concrete implementation where it looks up the route registry using the path and tries to retirve a resolver for the route. If not route is found, we throw a NotFoundErroe. If any exceptions are thrown from the handler, these are caught and handled by the already existing handleError method.

Changes

  • Update BaseRouter to have. oncrete implementation of resolve method
  • Added new conversion functions to produce the APIGatewayProxyResult type that lambda expects
  • Updated the unit tests now that the resolve function is implemented in the base class
  • Added tests to ensure this context is preserved when using decorators.

Issue number: closes #4142


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@svozza svozza added this to the Event Handler Beta (priority) milestone Aug 16, 2025
@svozza svozza requested a review from dreamorosi August 16, 2025 16:38
@svozza svozza self-assigned this Aug 16, 2025
@pull-request-size pull-request-size bot added the size/XXL PRs with 1K+ LOC, largely documentation related label Aug 16, 2025
@boring-cyborg boring-cyborg bot added event-handler This item relates to the Event Handler Utility tests PRs that add or change tests labels Aug 16, 2025
headers,
multiValueHeaders,
body: await response.text(),
isBase64Encoded: false,
Copy link
Contributor Author

@svozza svozza Aug 16, 2025

Choose a reason for hiding this comment

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

I've hardcodedisBase64Encoded for now but we will need to figure out how to deal with this

@@ -133,11 +139,49 @@ abstract class BaseRouter {
};
}

public abstract resolve(
public async resolve(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now that this function has an implementation, there are no abstract methos remaining. Should BaseRouter still be an abstract class?


try {
const request = proxyEventToWebRequest(event);
const path = new URL(request.url).pathname as Path;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In general, I dislike casting, should these two assignments use type guards?

@svozza svozza force-pushed the event-handler/response-resolver-logic branch from f5d5280 to 14a6f53 Compare August 17, 2025 19:12
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
event-handler This item relates to the Event Handler Utility size/XXL PRs with 1K+ LOC, largely documentation related tests PRs that add or change tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Implement Response Handling Architecture for Event Handler
1 participant