Skip to main content

Responses

@quik/http


@quik/http / Responses

Variable: Responses

const Responses: object

Defined in: http/src/router/endpoint/Responses.ts:219

Type Declaration

Accepted

Accepted: () => IQResponse<void> = AcceptedResponse

Function used to create an Accepted response.

Returns

IQResponse<void>

BadRequest

BadRequest: (message?) => IQResponse<IQErrorResponse> = BadRequestResponse

Function used to create a Bad Request response.

Parameters

message?

string

The message to be returned to the user.

Returns

IQResponse<IQErrorResponse>

Created

Created: <T>(body) => IQResponse<T> = CreatedResponse

Function used to create a Created response.

Type Parameters

T

T = any

Parameters

body

T

The content of the response.

Returns

IQResponse<T>

Forbidden

Forbidden: (message?) => IQResponse<IQErrorResponse> = ForbiddenResponse

Function used to create a Forbidden response.

Parameters

message?

string

The message to be returned to the user.

Returns

IQResponse<IQErrorResponse>

Moved

Moved: (url) => IQResponse<string> = MovedResponse

Function used to create a Moved response.

Parameters

url

string

The URL to which we redirect the user to.

Returns

IQResponse<string>

NoContent

NoContent: () => IQResponse<void> = NoContentResponse

Function used to create a No Content response.

Returns

IQResponse<void>

NotFound

NotFound: () => IQResponse<string> = NotFoundResponse

Function used to create a Page Not Found response.

Returns

IQResponse<string>

OK

OK: <T>(body, isFile?) => IQResponse<T> = OKResponse

Function used to create a response with Status Code 200.

Type Parameters

T

T = any

Parameters

body

T

The body of the response.

isFile?

boolean = false

Mark the response as one that returns a file to download.

Returns

IQResponse<T>

OKFile

OKFile: (filePath, contentType) => IQResponse<string> = OKFileResponse

Function used to create a response with Status Code 200 that returns a file to download.

Parameters

filePath

string

The path to the file to be downloaded.

contentType?

string = QMimeType.BINARY

The content type of the file.

Returns

IQResponse<string>

OKImageFile

OKImageFile: (filePath, contentType) => IQResponse<string> = OKImageFileResponse

Function used to create a response with Status Code 200 that returns a file to download.

Parameters

filePath

string

The path to the file to be downloaded.

contentType?

string = QMimeType.IMAGE_PNG

The content type of the file.

Returns

IQResponse<string>

OKMessage

OKMessage: (message?) => IQResponse<IQMessageResponse> = OKMessageResponse

Function used to create a response with Status Code 200 and a given specific message.

Parameters

message?

string

Returns

IQResponse<IQMessageResponse>

Parma

[message] The message to be returned. If nothing is passed, it returns "OK".

Redirect

Redirect: (url) => IQResponse<string> = RedirectResponse

Function used to create a Redirected response.

Parameters

url

string

The URL to which we redirect the user to.

Returns

IQResponse<string>

ServerError

ServerError: (message?) => IQResponse<IQErrorResponse> = ServerErrorResponse

Function used to create a Server Error response.

Parameters

message?

string

The message to be returned to the user.

Returns

IQResponse<IQErrorResponse>

ServerUnavailable

ServerUnavailable: (message?) => IQResponse<IQErrorResponse> = ServerUnavailableResponse

Function used to create a Server Unavailable response.

Parameters

message?

string

The message to be returned to the user.

Returns

IQResponse<IQErrorResponse>

Unauthorized

Unauthorized: (message?) => IQResponse<IQErrorResponse> = UnauthorizedResponse

Function used to create an Unauthorized response.

Parameters

message?

string

The message to be returned to the user.

Returns

IQResponse<IQErrorResponse>