Skip to main content Link Search Menu Expand Document (external link)

ServerResponse overview

Added in v1.0.0


Table of contents


combinators

removeCookie

Signature

export declare const removeCookie: {
  (name: string): (self: ServerResponse) => ServerResponse
  (self: ServerResponse, name: string): ServerResponse
}

Added in v1.0.0

replaceCookies

Signature

export declare const replaceCookies: {
  (cookies: Cookies): (self: ServerResponse) => ServerResponse
  (self: ServerResponse, cookies: Cookies): ServerResponse
}

Added in v1.0.0

setBody

Signature

export declare const setBody: {
  (body: Body.Body): (self: ServerResponse) => ServerResponse
  (self: ServerResponse, body: Body.Body): ServerResponse
}

Added in v1.0.0

setCookie

Signature

export declare const setCookie: {
  (
    name: string,
    value: string,
    options?: Cookie["options"]
  ): (self: ServerResponse) => Effect.Effect<ServerResponse, CookiesError>
  (
    self: ServerResponse,
    name: string,
    value: string,
    options?: Cookie["options"]
  ): Effect.Effect<ServerResponse, CookiesError>
}

Added in v1.0.0

setCookies

Signature

export declare const setCookies: {
  (
    cookies: Iterable<readonly [name: string, value: string, options?: Cookie["options"]]>
  ): (self: ServerResponse) => Effect.Effect<ServerResponse, CookiesError, never>
  (
    self: ServerResponse,
    cookies: Iterable<readonly [name: string, value: string, options?: Cookie["options"]]>
  ): Effect.Effect<ServerResponse, CookiesError, never>
}

Added in v1.0.0

setHeader

Signature

export declare const setHeader: {
  (key: string, value: string): (self: ServerResponse) => ServerResponse
  (self: ServerResponse, key: string, value: string): ServerResponse
}

Added in v1.0.0

setHeaders

Signature

export declare const setHeaders: {
  (input: Headers.Input): (self: ServerResponse) => ServerResponse
  (self: ServerResponse, input: Headers.Input): ServerResponse
}

Added in v1.0.0

setStatus

Signature

export declare const setStatus: {
  (status: number, statusText?: string | undefined): (self: ServerResponse) => ServerResponse
  (self: ServerResponse, status: number, statusText?: string | undefined): ServerResponse
}

Added in v1.0.0

unsafeSetCookie

Signature

export declare const unsafeSetCookie: {
  (name: string, value: string, options?: Cookie["options"]): (self: ServerResponse) => ServerResponse
  (self: ServerResponse, name: string, value: string, options?: Cookie["options"]): ServerResponse
}

Added in v1.0.0

unsafeSetCookies

Signature

export declare const unsafeSetCookies: {
  (
    cookies: Iterable<readonly [name: string, value: string, options?: Cookie["options"]]>
  ): (self: ServerResponse) => ServerResponse
  (
    self: ServerResponse,
    cookies: Iterable<readonly [name: string, value: string, options?: Cookie["options"]]>
  ): ServerResponse
}

Added in v1.0.0

updateCookies

Signature

export declare const updateCookies: {
  (f: (cookies: Cookies) => Cookies): (self: ServerResponse) => ServerResponse
  (self: ServerResponse, f: (cookies: Cookies) => Cookies): ServerResponse
}

Added in v1.0.0

constructors

empty

Signature

export declare const empty: (options?: Options.WithContent | undefined) => ServerResponse

Added in v1.0.0

file

Signature

export declare const file: (
  path: string,
  options?: (Options & FileSystem.StreamOptions) | undefined
) => Effect.Effect<ServerResponse, PlatformError.PlatformError, Platform.Platform>

Added in v1.0.0

fileWeb

Signature

export declare const fileWeb: (
  file: Body.Body.FileLike,
  options?: (Options.WithContent & FileSystem.StreamOptions) | undefined
) => Effect.Effect<ServerResponse, never, Platform.Platform>

Added in v1.0.0

formData

Signature

export declare const formData: (body: FormData, options?: Options.WithContent | undefined) => ServerResponse

Added in v1.0.0

html

Signature

export declare const html: {
  <A extends readonly any[]>(
    strings: TemplateStringsArray,
    ...args: A
  ): Effect.Effect<ServerResponse, Template.Interpolated.Error<A[number]>, Template.Interpolated.Context<A[number]>>
  (html: string): ServerResponse
}

Added in v1.0.0

htmlStream

Signature

export declare const htmlStream: <A extends readonly any[]>(
  strings: TemplateStringsArray,
  ...args: A
) => Effect.Effect<ServerResponse, never, Template.Interpolated.Context<A[number]>>

Added in v1.0.0

json

Signature

export declare const json: (
  body: unknown,
  options?: Options.WithContent | undefined
) => Effect.Effect<ServerResponse, Body.BodyError>

Added in v1.0.0

raw

Signature

export declare const raw: (body: unknown, options?: Options | undefined) => ServerResponse

Added in v1.0.0

schemaJson

Signature

export declare const schemaJson: <A, I, R>(
  schema: Schema.Schema<A, I, R>,
  options?: ParseOptions | undefined
) => (body: A, options?: Options.WithContent | undefined) => Effect.Effect<ServerResponse, Body.BodyError, R>

Added in v1.0.0

stream

Signature

export declare const stream: (body: Stream.Stream<Uint8Array, unknown>, options?: Options | undefined) => ServerResponse

Added in v1.0.0

text

Signature

export declare const text: (body: string, options?: Options.WithContentType | undefined) => ServerResponse

Added in v1.0.0

uint8Array

Signature

export declare const uint8Array: (body: Uint8Array, options?: Options.WithContentType | undefined) => ServerResponse

Added in v1.0.0

unsafeJson

Signature

export declare const unsafeJson: (body: unknown, options?: Options.WithContent | undefined) => ServerResponse

Added in v1.0.0

urlParams

Signature

export declare const urlParams: (body: UrlParams.Input, options?: Options.WithContent | undefined) => ServerResponse

Added in v1.0.0

conversions

toWeb

Signature

export declare const toWeb: (response: ServerResponse, withoutBody?: boolean | undefined) => Response

Added in v1.0.0

models

Options (interface)

Signature

export interface Options {
  readonly status?: number | undefined
  readonly statusText?: string | undefined
  readonly headers?: Headers.Headers | undefined
  readonly cookies?: Cookies | undefined
  readonly contentType?: string | undefined
  readonly contentLength?: number | undefined
}

Added in v1.0.0

ServerResponse (interface)

Signature

export interface ServerResponse extends Effect.Effect<ServerResponse>, Inspectable {
  readonly [TypeId]: TypeId
  readonly status: number
  readonly statusText?: string | undefined
  readonly headers: Headers.Headers
  readonly cookies: Cookies
  readonly body: Body.Body
}

Added in v1.0.0

type ids

TypeId

Signature

export declare const TypeId: typeof TypeId

Added in v1.0.0

TypeId (type alias)

Signature

export type TypeId = typeof TypeId

Added in v1.0.0

utils

Options (namespace)

Added in v1.0.0

WithContent (interface)

Signature

export interface WithContent extends Omit<Options, "contentType" | "contentLength"> {}

Added in v1.0.0

WithContentType (interface)

Signature

export interface WithContentType extends Omit<Options, "contentLength"> {}

Added in v1.0.0

isServerResponse

Signature

export declare const isServerResponse: (u: unknown) => u is ServerResponse

Added in v1.0.0