Skip to content

Middy Middleware

Open in ChatGPTOpen in Claude

Axis ships Middy middleware so every handler gets consistent error handling and logging without repeating boilerplate. Wrap your handler and the middleware does the rest.

  • Error-handler middleware — catches thrown errors, maps AtfError subclasses to the right HTTP status via statusCodeFor, and returns a clean response without leaking a stack trace.
  • Logging middleware — wires the masked logger into the request lifecycle so every invocation gets structured, secret-scrubbed logs.

Throw a NotFoundError, ValidationError, ForbiddenError, ConflictError, or QuotaExceededError from service code and the error-handler middleware turns it into the correct status (404/400/403/409/429). This is why service code should throw typed errors rather than assembling HTTP responses by hand.

© 2026 Axis Tech. Powered by axis-tech.co.