Skip to content

Conversation

@matthew2564
Copy link

@matthew2564 matthew2564 commented Jan 13, 2026

Summary

I was looking into using the new Event Handler utility, but specifically with decorators. This PR adds documentation and examples for HTTP Router decorators in the Event Handler utility. The decorator syntax was fully implemented but completely undocumented - this fills that documentation gap.

Changes

Documentation (docs/features/event-handler/http.md):

  • Added "Using decorators" section after HTTP Methods with basic decorator examples
  • Added decorator examples for error handling (@app.errorHandler())
  • Added decorator examples for built-in error handlers (@app.notFound(), @app.methodNotAllowed())

Example Files (4 new files in examples/snippets/event-handler/http/):

  • gettingStarted_decorators_basic.ts - Basic route handler decorators
  • gettingStarted_error_handling_decorators.ts - Error handler decorators
  • gettingStarted_built_in_error_handler_decorators.ts - Built-in error handler decorators
  • advanced_mw_middleware_order_decorators.ts - Middleware with decorators

Coverage:

  • ✅ All HTTP method decorators (@app.get(), @app.post(), @app.put(), etc)
  • ✅ Custom error handlers with @app.errorHandler(ErrorClass)
  • ✅ Built-in error handlers (@app.notFound(), @app.methodNotAllowed())
  • ✅ Scope preservation with { scope: this }

Issue number: closes #4951


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.

@pull-request-size pull-request-size bot added the size/L PRs between 100-499 LOC label Jan 13, 2026
@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Jan 13, 2026
@boring-cyborg
Copy link

boring-cyborg bot commented Jan 13, 2026

Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need.
In the meantime, check out the #typescript channel on our Powertools for AWS Lambda Discord: Invite link

@svozza
Copy link
Contributor

svozza commented Jan 14, 2026

Have added a few comments. Something I noticed is that a lot the highlighting in the code examples was off by one or two lines. If you do npm run docs:local:setup followed by docs:local:run you will be able to view your docs on http://127.0.0.1:8000/powertools/typescript/latest/features/event-handler/http to verifiy that they look correct.

@svozza svozza changed the title docs: add http router decorator examples docs(event-handler): add http router decorator examples Jan 14, 2026
const app = new Router({ logger });

class Lambda implements LambdaInterface {
@app.route('/todos/:todoId', ['GET', 'HEAD'])
Copy link
Contributor

Choose a reason for hiding this comment

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

@svozza I don't think we support this - do we?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yes, you're correct! I should have caught that. @matthew2564 can you remove the docs for the route method.

svozza
svozza previously approved these changes Jan 15, 2026
@svozza svozza dismissed their stale review January 15, 2026 19:19

Route method is not a decorator

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/L PRs between 100-499 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docs: Missing HTTP Router decorator examples

3 participants