Headerify: {
    [P in keyof T]?: T[P] extends HeaderValue
    | undefined
        ? P extends string
            ? Lowercase<P> extends "set-cookie"
                ? T[P] extends HeaderValue[] ? T[P] | undefined : never
                : Lowercase<P> extends
                    | "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"
                    ? T[P] extends HeaderValue[] ? never : T[P] | undefined
                    : T[P] | undefined
            : never
        : never
}

Type of headers

Headerify removes every properties that are not allowed in the HTTP headers type.

Below are list of prohibited in HTTP headers.

  1. Value type one of HeaderValue
  2. Key is "set-cookie", but value is not an Array type
  3. Key is one of them, but value is 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 | undefined