Skip to content

docs(event-handler): add http router decorator examples#4950

Merged
dreamorosi merged 7 commits intoaws-powertools:mainfrom
matthew2564:docs/http-router-decorators
Jan 16, 2026
Merged

docs(event-handler): add http router decorator examples#4950
dreamorosi merged 7 commits intoaws-powertools:mainfrom
matthew2564:docs/http-router-decorators

Conversation

@matthew2564
Copy link
Copy Markdown
Contributor

@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
Copy Markdown

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

Comment thread docs/features/event-handler/http.md Outdated
Comment thread docs/features/event-handler/http.md Outdated
Comment thread docs/features/event-handler/http.md Outdated
Comment thread docs/features/event-handler/http.md Outdated
Comment thread docs/features/event-handler/http.md Outdated
@svozza
Copy link
Copy Markdown
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.

Comment thread docs/Dockerfile Outdated
Comment thread docs/features/event-handler/http.md Outdated
@svozza svozza changed the title docs: add http router decorator examples docs(event-handler): add http router decorator examples Jan 14, 2026
Comment thread examples/snippets/event-handler/http/gettingStarted_decorators_route.ts Outdated
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
Copy Markdown

@svozza
Copy link
Copy Markdown
Contributor

svozza commented Jan 16, 2026

Thank you @matthew2564 for your work on this! Merging now.

@svozza svozza requested a review from dreamorosi January 16, 2026 10:58
@dreamorosi dreamorosi merged commit b4acd18 into aws-powertools:main Jan 16, 2026
46 checks passed
@boring-cyborg
Copy link
Copy Markdown

boring-cyborg Bot commented Jan 16, 2026

Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience!

@github-actions
Copy link
Copy Markdown
Contributor

@aws-powertools/lambda-typescript No related issues found. Please ensure 'pending-release' label is applied before releasing.

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