import { Writable } from 'stream' ; type OptionalHeaders = { [ key ] : string ; } | undefined ; export type Response < Status , Body , Headers extends OptionalHeaders > = { status : Status ; body : Body ; headers : Headers ; } ; export type Generic = Response < number , any , OptionalHeaders > ; export type Continue < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 100 , Body , Headers > ; export function continue_ < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function continue_ < Body > ( body ) ; export function continue_ ( ) ; export function continue_ ( body = undefined , headers = undefined ) { return { status : 100 , body , headers } ; } export type SwitchingProtocols < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 101 , Body , Headers > ; export function switchingProtocols < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function switchingProtocols < Body > ( body ) ; export function switchingProtocols ( ) ; export function switchingProtocols ( body = undefined , headers = undefined ) { return { status : 101 , body , headers } ; } export type Processing < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 102 , Body , Headers > ; export function processing < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function processing < Body > ( body ) ; export function processing ( ) ; export function processing ( body = undefined , headers = undefined ) { return { status : 102 , body , headers } ; } export type EarlyHints < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 103 , Body , Headers > ; export function earlyHints < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function earlyHints < Body > ( body ) ; export function earlyHints ( ) ; export function earlyHints ( body = undefined , headers = undefined ) { return { status : 103 , body , headers } ; } export type Ok < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 200 , Body , Headers > ; export function ok < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function ok < Body > ( body ) ; export function ok ( ) ; export function ok ( body = undefined , headers = undefined ) { return { status : 200 , body , headers } ; } export type Created < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 201 , Body , Headers > ; export function created < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function created < Body > ( body ) ; export function created ( ) ; export function created ( body = undefined , headers = undefined ) { return { status : 201 , body , headers } ; } export type Accepted < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 202 , Body , Headers > ; export function accepted < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function accepted < Body > ( body ) ; export function accepted ( ) ; export function accepted ( body = undefined , headers = undefined ) { return { status : 202 , body , headers } ; } export type NonAuthoritativeInformation < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 203 , Body , Headers > ; export function nonAuthoritativeInformation < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function nonAuthoritativeInformation < Body > ( body ) ; export function nonAuthoritativeInformation ( ) ; export function nonAuthoritativeInformation ( body = undefined , headers = undefined ) { return { status : 203 , body , headers } ; } export type NoContent < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 204 , Body , Headers > ; export function noContent < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function noContent < Body > ( body ) ; export function noContent ( ) ; export function noContent ( body = undefined , headers = undefined ) { return { status : 204 , body , headers } ; } export type ResetContent < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 205 , Body , Headers > ; export function resetContent < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function resetContent < Body > ( body ) ; export function resetContent ( ) ; export function resetContent ( body = undefined , headers = undefined ) { return { status : 205 , body , headers } ; } export type PartialContent < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 206 , Body , Headers > ; export function partialContent < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function partialContent < Body > ( body ) ; export function partialContent ( ) ; export function partialContent ( body = undefined , headers = undefined ) { return { status : 206 , body , headers } ; } export type MultiStatus < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 207 , Body , Headers > ; export function multiStatus < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function multiStatus < Body > ( body ) ; export function multiStatus ( ) ; export function multiStatus ( body = undefined , headers = undefined ) { return { status : 207 , body , headers } ; } export type AlreadyReported < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 208 , Body , Headers > ; export function alreadyReported < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function alreadyReported < Body > ( body ) ; export function alreadyReported ( ) ; export function alreadyReported ( body = undefined , headers = undefined ) { return { status : 208 , body , headers } ; } export type IMUsed < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 226 , Body , Headers > ; export function iMUsed < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function iMUsed < Body > ( body ) ; export function iMUsed ( ) ; export function iMUsed ( body = undefined , headers = undefined ) { return { status : 226 , body , headers } ; } export type MultipleChoices < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 300 , Body , Headers > ; export function multipleChoices < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function multipleChoices < Body > ( body ) ; export function multipleChoices ( ) ; export function multipleChoices ( body = undefined , headers = undefined ) { return { status : 300 , body , headers } ; } export type MovedPermanently < Body = string , Headers extends OptionalHeaders = { location : string ; } > = Response < 301 , Body , Headers > ; export function movedPermanently < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function movedPermanently < Body > ( body ) ; export function movedPermanently ( ) ; export function movedPermanently ( body = undefined , headers = undefined ) { return { status : 301 , body , headers } ; } export type Found < Body = string , Headers extends OptionalHeaders = { location : string ; } > = Response < 302 , Body , Headers > ; export function found < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function found < Body > ( body ) ; export function found ( ) ; export function found ( body = undefined , headers = undefined ) { return { status : 302 , body , headers } ; } export type SeeOther < Body = string , Headers extends OptionalHeaders = { location : string ; } > = Response < 303 , Body , Headers > ; export function seeOther < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function seeOther < Body > ( body ) ; export function seeOther ( ) ; export function seeOther ( body = undefined , headers = undefined ) { return { status : 303 , body , headers } ; } export type NotModified < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 304 , Body , Headers > ; export function notModified < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function notModified < Body > ( body ) ; export function notModified ( ) ; export function notModified ( body = undefined , headers = undefined ) { return { status : 304 , body , headers } ; } export type UseProxy < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 305 , Body , Headers > ; export function useProxy < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function useProxy < Body > ( body ) ; export function useProxy ( ) ; export function useProxy ( body = undefined , headers = undefined ) { return { status : 305 , body , headers } ; } export type SwitchProxy < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 306 , Body , Headers > ; export function switchProxy < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function switchProxy < Body > ( body ) ; export function switchProxy ( ) ; export function switchProxy ( body = undefined , headers = undefined ) { return { status : 306 , body , headers } ; } export type TemporaryRedirect < Body = string , Headers extends OptionalHeaders = { location : string ; } > = Response < 307 , Body , Headers > ; export function temporaryRedirect < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function temporaryRedirect < Body > ( body ) ; export function temporaryRedirect ( ) ; export function temporaryRedirect ( body = undefined , headers = undefined ) { return { status : 307 , body , headers } ; } export type PermanentRedirect < Body = string , Headers extends OptionalHeaders = { location : string ; } > = Response < 308 , Body , Headers > ; export function permanentRedirect < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function permanentRedirect < Body > ( body ) ; export function permanentRedirect ( ) ; export function permanentRedirect ( body = undefined , headers = undefined ) { return { status : 308 , body , headers } ; } export type BadRequest < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 400 , Body , Headers > ; export function badRequest < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function badRequest < Body > ( body ) ; export function badRequest ( ) ; export function badRequest ( body = undefined , headers = undefined ) { return { status : 400 , body , headers } ; } export type Unauthorized < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 401 , Body , Headers > ; export function unauthorized < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function unauthorized < Body > ( body ) ; export function unauthorized ( ) ; export function unauthorized ( body = undefined , headers = undefined ) { return { status : 401 , body , headers } ; } export type PaymentRequired < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 402 , Body , Headers > ; export function paymentRequired < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function paymentRequired < Body > ( body ) ; export function paymentRequired ( ) ; export function paymentRequired ( body = undefined , headers = undefined ) { return { status : 402 , body , headers } ; } export type Forbidden < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 403 , Body , Headers > ; export function forbidden < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function forbidden < Body > ( body ) ; export function forbidden ( ) ; export function forbidden ( body = undefined , headers = undefined ) { return { status : 403 , body , headers } ; } export type NotFound < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 404 , Body , Headers > ; export function notFound < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function notFound < Body > ( body ) ; export function notFound ( ) ; export function notFound ( body = undefined , headers = undefined ) { return { status : 404 , body , headers } ; } export type MethodNotAllowed < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 405 , Body , Headers > ; export function methodNotAllowed < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function methodNotAllowed < Body > ( body ) ; export function methodNotAllowed ( ) ; export function methodNotAllowed ( body = undefined , headers = undefined ) { return { status : 405 , body , headers } ; } export type NotAcceptable < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 406 , Body , Headers > ; export function notAcceptable < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function notAcceptable < Body > ( body ) ; export function notAcceptable ( ) ; export function notAcceptable ( body = undefined , headers = undefined ) { return { status : 406 , body , headers } ; } export type ProxyAuthenticationRequired < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 407 , Body , Headers > ; export function proxyAuthenticationRequired < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function proxyAuthenticationRequired < Body > ( body ) ; export function proxyAuthenticationRequired ( ) ; export function proxyAuthenticationRequired ( body = undefined , headers = undefined ) { return { status : 407 , body , headers } ; } export type RequestTimeout < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 408 , Body , Headers > ; export function requestTimeout < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function requestTimeout < Body > ( body ) ; export function requestTimeout ( ) ; export function requestTimeout ( body = undefined , headers = undefined ) { return { status : 408 , body , headers } ; } export type Conflict < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 409 , Body , Headers > ; export function conflict < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function conflict < Body > ( body ) ; export function conflict ( ) ; export function conflict ( body = undefined , headers = undefined ) { return { status : 409 , body , headers } ; } export type Gone < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 410 , Body , Headers > ; export function gone < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function gone < Body > ( body ) ; export function gone ( ) ; export function gone ( body = undefined , headers = undefined ) { return { status : 410 , body , headers } ; } export type LengthRequired < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 411 , Body , Headers > ; export function lengthRequired < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function lengthRequired < Body > ( body ) ; export function lengthRequired ( ) ; export function lengthRequired ( body = undefined , headers = undefined ) { return { status : 411 , body , headers } ; } export type PreconditionFailed < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 412 , Body , Headers > ; export function preconditionFailed < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function preconditionFailed < Body > ( body ) ; export function preconditionFailed ( ) ; export function preconditionFailed ( body = undefined , headers = undefined ) { return { status : 412 , body , headers } ; } export type PayloadTooLarge < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 413 , Body , Headers > ; export function payloadTooLarge < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function payloadTooLarge < Body > ( body ) ; export function payloadTooLarge ( ) ; export function payloadTooLarge ( body = undefined , headers = undefined ) { return { status : 413 , body , headers } ; } export type URITooLong < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 414 , Body , Headers > ; export function uRITooLong < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function uRITooLong < Body > ( body ) ; export function uRITooLong ( ) ; export function uRITooLong ( body = undefined , headers = undefined ) { return { status : 414 , body , headers } ; } export type UnsupportedMediaType < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 415 , Body , Headers > ; export function unsupportedMediaType < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function unsupportedMediaType < Body > ( body ) ; export function unsupportedMediaType ( ) ; export function unsupportedMediaType ( body = undefined , headers = undefined ) { return { status : 415 , body , headers } ; } export type RangeNotSatisfiable < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 416 , Body , Headers > ; export function rangeNotSatisfiable < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function rangeNotSatisfiable < Body > ( body ) ; export function rangeNotSatisfiable ( ) ; export function rangeNotSatisfiable ( body = undefined , headers = undefined ) { return { status : 416 , body , headers } ; } export type ExpectationFailed < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 417 , Body , Headers > ; export function expectationFailed < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function expectationFailed < Body > ( body ) ; export function expectationFailed ( ) ; export function expectationFailed ( body = undefined , headers = undefined ) { return { status : 417 , body , headers } ; } export type ImATeapot < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 418 , Body , Headers > ; export function imATeapot < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function imATeapot < Body > ( body ) ; export function imATeapot ( ) ; export function imATeapot ( body = undefined , headers = undefined ) { return { status : 418 , body , headers } ; } export type MisdirectedRequest < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 421 , Body , Headers > ; export function misdirectedRequest < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function misdirectedRequest < Body > ( body ) ; export function misdirectedRequest ( ) ; export function misdirectedRequest ( body = undefined , headers = undefined ) { return { status : 421 , body , headers } ; } export type UnprocessableEntity < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 422 , Body , Headers > ; export function unprocessableEntity < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function unprocessableEntity < Body > ( body ) ; export function unprocessableEntity ( ) ; export function unprocessableEntity ( body = undefined , headers = undefined ) { return { status : 422 , body , headers } ; } export type Locked < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 423 , Body , Headers > ; export function locked < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function locked < Body > ( body ) ; export function locked ( ) ; export function locked ( body = undefined , headers = undefined ) { return { status : 423 , body , headers } ; } export type FailedDependency < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 424 , Body , Headers > ; export function failedDependency < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function failedDependency < Body > ( body ) ; export function failedDependency ( ) ; export function failedDependency ( body = undefined , headers = undefined ) { return { status : 424 , body , headers } ; } export type TooEarly < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 425 , Body , Headers > ; export function tooEarly < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function tooEarly < Body > ( body ) ; export function tooEarly ( ) ; export function tooEarly ( body = undefined , headers = undefined ) { return { status : 425 , body , headers } ; } export type UpgradeRequired < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 426 , Body , Headers > ; export function upgradeRequired < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function upgradeRequired < Body > ( body ) ; export function upgradeRequired ( ) ; export function upgradeRequired ( body = undefined , headers = undefined ) { return { status : 426 , body , headers } ; } export type PreconditionRequired < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 428 , Body , Headers > ; export function preconditionRequired < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function preconditionRequired < Body > ( body ) ; export function preconditionRequired ( ) ; export function preconditionRequired ( body = undefined , headers = undefined ) { return { status : 428 , body , headers } ; } export type TooManyRequests < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 429 , Body , Headers > ; export function tooManyRequests < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function tooManyRequests < Body > ( body ) ; export function tooManyRequests ( ) ; export function tooManyRequests ( body = undefined , headers = undefined ) { return { status : 429 , body , headers } ; } export type RequestHeaderFieldsTooLarge < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 431 , Body , Headers > ; export function requestHeaderFieldsTooLarge < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function requestHeaderFieldsTooLarge < Body > ( body ) ; export function requestHeaderFieldsTooLarge ( ) ; export function requestHeaderFieldsTooLarge ( body = undefined , headers = undefined ) { return { status : 431 , body , headers } ; } export type UnavailableForLegalReasons < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 451 , Body , Headers > ; export function unavailableForLegalReasons < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function unavailableForLegalReasons < Body > ( body ) ; export function unavailableForLegalReasons ( ) ; export function unavailableForLegalReasons ( body = undefined , headers = undefined ) { return { status : 451 , body , headers } ; } export type InternalServerError < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 500 , Body , Headers > ; export function internalServerError < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function internalServerError < Body > ( body ) ; export function internalServerError ( ) ; export function internalServerError ( body = undefined , headers = undefined ) { return { status : 500 , body , headers } ; } export type NotImplemented < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 501 , Body , Headers > ; export function notImplemented < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function notImplemented < Body > ( body ) ; export function notImplemented ( ) ; export function notImplemented ( body = undefined , headers = undefined ) { return { status : 501 , body , headers } ; } export type BadGateway < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 502 , Body , Headers > ; export function badGateway < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function badGateway < Body > ( body ) ; export function badGateway ( ) ; export function badGateway ( body = undefined , headers = undefined ) { return { status : 502 , body , headers } ; } export type ServiceUnavailable < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 503 , Body , Headers > ; export function serviceUnavailable < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function serviceUnavailable < Body > ( body ) ; export function serviceUnavailable ( ) ; export function serviceUnavailable ( body = undefined , headers = undefined ) { return { status : 503 , body , headers } ; } export type GatewayTimeout < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 504 , Body , Headers > ; export function gatewayTimeout < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function gatewayTimeout < Body > ( body ) ; export function gatewayTimeout ( ) ; export function gatewayTimeout ( body = undefined , headers = undefined ) { return { status : 504 , body , headers } ; } export type HTTPVersionNotSupported < Body = undefined , Headers extends OptionalHeaders = undefined > = Response < 505 , Body , Headers > ; export function hTTPVersionNotSupported < Body , Headers extends OptionalHeaders > ( body , headers ) ; export function hTTPVersionNotSupported < Body > ( body ) ; export function hTTPVersionNotSupported ( ) ; export function hTTPVersionNotSupported ( body = undefined , headers = undefined ) { return { status : 505 , body , headers } ; } type RedirectStatus = 301 | 302 | 303 | 307 | 308 ; function redirectName ( status ) { switch ( status ) { case 301 : return 'Moved permanently' ; case 302 : return 'Found' ; case 303 : return 'See other' ; case 307 : return 'Temporary redirect' ; case 308 : return 'Permanent redirect' ; } } export function redirect < Status extends RedirectStatus > ( status , location ) { return { status , body : `${ redirectName ( status ) }. Redirecting to ${ location }` , headers : { location } , } ; } export type StreamingBodyCallback = ( stream : Writable ) => void ; export type StreamingBody = { _kind : 'StreamingBody' ; callback : StreamingBodyCallback ; } ; export function streamingBody ( callback ) { return { _kind : 'StreamingBody' , callback } ; } export function isStreamingBody ( body ) { return body && body . _kind === 'StreamingBody' && body . callback ; }