express overview

Added in v0.5.0


Table of contents


model

ExpressConnection (class)

Signature

export declare class ExpressConnection<S> {
  constructor(
    readonly req: Request,
    readonly res: Response,
    readonly actions: L.List<Action> = L.nil,
    readonly ended: boolean = false
  )
}

Added in v0.5.0

chain (method)

Signature

chain<T>(action: Action, ended: boolean = false): ExpressConnection<T>

Added in v0.5.0

getRequest (method)

Signature

getRequest(): IncomingMessage

Added in v0.5.0

getBody (method)

Signature

getBody(): unknown

Added in v0.5.0

getHeader (method)

Signature

getHeader(name: string): unknown

Added in v0.5.0

getParams (method)

Signature

getParams(): unknown

Added in v0.5.0

getQuery (method)

Signature

getQuery(): unknown

Added in v0.5.0

getOriginalUrl (method)

Signature

getOriginalUrl(): string

Added in v0.5.0

getMethod (method)

Signature

getMethod(): string

Added in v0.5.0

setCookie (method)

Signature

setCookie(name: string, value: string, options: CookieOptions): ExpressConnection<HeadersOpen>

Added in v0.5.0

clearCookie (method)

Signature

clearCookie(name: string, options: CookieOptions): ExpressConnection<HeadersOpen>

Added in v0.5.0

setHeader (method)

Signature

setHeader(name: string, value: string): ExpressConnection<HeadersOpen>

Added in v0.5.0

setStatus (method)

Signature

setStatus(status: Status): ExpressConnection<HeadersOpen>

Added in v0.5.0

setBody (method)

Signature

setBody(body: string | Buffer): ExpressConnection<ResponseEnded>

Added in v0.5.0

pipeStream (method)

Signature

pipeStream(stream: NodeJS.ReadableStream, onError: (e: unknown) => IO.IO<void>): ExpressConnection<ResponseEnded>

Added in v0.6.2

endResponse (method)

Signature

endResponse(): ExpressConnection<ResponseEnded>

Added in v0.5.0

_S (property)

Signature

readonly _S: S

Added in v0.5.0

utils

fromRequestHandler

The overload without error handler is unsafe and deprecated, use the one with the error handler instead.

Signature

export declare function fromRequestHandler<I = StatusOpen, E = never, A = never>(
  requestHandler: RequestHandler,
  f: (req: Request) => A
): Middleware<I, I, E, A>
export declare function fromRequestHandler<I = StatusOpen, E = never, A = never>(
  requestHandler: RequestHandler,
  f: (req: Request) => E.Either<E, A>,
  onError: (reason: unknown) => E
): Middleware<I, I, E, A>

Added in v0.5.0

toErrorRequestHandler

Signature

export declare function toErrorRequestHandler<I, O, E>(
  f: (err: unknown) => Middleware<I, O, E, void>
): ErrorRequestHandler

Added in v0.5.0

toRequestHandler

Signature

export declare function toRequestHandler<I, O, E>(middleware: Middleware<I, O, E, void>): RequestHandler

Added in v0.5.0