Skip to main content

TrpcAdapterBaseContext

@h4ad/serverless-adapter > TrpcAdapterBaseContext

(interface) TrpcAdapterBaseContext

The context created by this library that allows getting some information from the request and setting the status and header of the response.

Signature:

export interface TrpcAdapterBaseContext 

(method) getHeader

The method to return the value of some header from the request

Signature:

getHeader(name: string): string | undefined;

Parameters

ParameterTypeDescription
namestringThe name of the header

Returns:

string | undefined

(method) getHeaders

The method to return the request headers

Signature:

getHeaders(): SingleValueHeaders;

Returns:

SingleValueHeaders

(method) getIp

The method to return user's address

Signature:

getIp(): string | undefined;

Returns:

string | undefined

(method) getMethod

The method to return the HTTP Method in the request

Signature:

getMethod(): string | undefined;

Returns:

string | undefined

(method) getUrl

The method to return the URL called

Signature:

getUrl(): string | undefined;

Returns:

string | undefined

(method) removeHeader

The method to remove some header from the response

Signature:

removeHeader(name: string): void;

Parameters

ParameterTypeDescription
namestringThe name of the header

Returns:

void

(property) request

The request object that will be forward to your app

Signature:

request: IncomingMessage;

(property) response

The response object that will be forward to your app to output the response

Signature:

response: ServerResponse;

(method) setHeader

The method to set some header in the response

Signature:

setHeader(name: string, value: number | string): void;

Parameters

ParameterTypeDescription
namestringThe name of the header
valuenumber | stringThe value to be set in the header

Returns:

void

(method) setStatus

The method to set response status.

Signature:

setStatus(statusCode: number): void;

Parameters

ParameterTypeDescription
statusCodenumberThe response status that you want

Returns:

void