2.0.0 • Published 3 years ago

@tshttp/header v2.0.0

Weekly downloads
14
License
MIT
Repository
github
Last release
3 years ago

@tshttp/header 📰

Ultra typed, over documented, and neatly organised HTTP header enums, to use for a great developper experience.

Get started

yarn add @tshttp/header
npm install @tshttp/header
import { Header } from '@tshttp/header'

req.header(Header.ContentType)

Enums

Header enum is composed of the following exported enums:

  • RequestHeader for the HTTP request headers.
  • ResponseHeader for the HTTP response headers.
import { RequestHeader, ResponseHeader } from '@tshttp/header'

req.get(RequestHeader.XForwardedFor)
res.set(ResponseHeader.Allow, 'GET')

These enums are actually object litterals with a const assertion.`

Unions

When use as a type, each category is a union of corresponding headers.

import { Header, ResponseHeader } from '@tshttp/status'

function setHeader(name: ResponseHeader, value: string) {
  //...
}