Documentation
    Preparing search index...

    Function TypedHeaders

    • Type safe HTTP headers decorator.

      TypedHeaders is a decorator function that can parse HTTP headers. It is almost same with nest.Headers, but it can automatically cast property type following its DTO definition. Also, TypedHeaders performs type validation.

      For reference, target type T must follow such restrictions. Also, if actual HTTP header values are different with their promised type T, BadRequestException error (status code: 400) would be thrown.

      1. Type T must be an object type
      2. Do not allow dynamic property
      3. Property key must be lower case
      4. Property value cannot be null, but undefined is possible
      5. Only boolean, bigint, number, string or their array types are allowed
      6. By the way, union type never be not allowed
      7. Property set-cookie must be array type
      8. Those properties cannot be array type
      • Age
      • Authorization
      • Content-length
      • Content-type
      • Etag
      • Expires
      • From
      • Host
      • If-modified-since
      • If-unmodified-since
      • Last-modified
      • Location
      • Max-forwards
      • Proxy-authorization
      • Referer
      • Retry-after
      • Server
      • User-agent

      Type Parameters

      • T extends object

      Parameters

      • Optionalvalidator: IRequestHeadersValidator<T>

      Returns ParameterDecorator

      Parameter decorator

      Jeongho Nam - https://github.com/samchon

      contracts/common.md#principled-implementation The header record of the request is decoded by the transformed function into the typed object, whose failure is thrown as the response; header names arrive lower-cased from Node, which the generated decoder expects.

      contracts/common.md#clear-and-simple-design One parameter decorator built from the shared header validator runner.

      contracts/common.md#prohibited-implementation-shortcuts The decoder is generated from the type by the transform; without it the request headers are passed through only when the configuration guard is off.

      contracts/common.md#meaningful-documentation The comment documents the decoding, the supported property types, and the validation modes.

      contracts/portability.md#os-neutral-implementation Header names and decoded values belong to the HTTP protocol and are not native filesystem identities.