Skip to main content

Class: ApiResponse<Request>

Defined in: projects/plugins/packages/api/src/lib/structures/api/ApiResponse.ts:11

Since

1.0.0

Extends

  • ServerResponse<Request>

Type Parameters

Type ParameterDefault type
Request extends IncomingMessageIncomingMessage

Constructors

new ApiResponse()

new ApiResponse<Request>(req: Request): ApiResponse<Request>

Defined in: node_modules/@types/node/http.d.ts:777

Parameters

ParameterType
reqRequest

Returns

ApiResponse<Request>

Inherited from

ServerResponse<Request>.constructor

Properties

cookies

cookies: CookieStore

Defined in: projects/plugins/packages/api/src/lib/structures/api/ApiResponse.ts:15

Since

1.0.0

Methods

badRequest()

badRequest(data?: unknown): void

Defined in: projects/plugins/packages/api/src/lib/structures/api/ApiResponse.ts:44

Parameters

ParameterType
data?unknown

Returns

void

Since

1.0.0


conflict()

conflict(data?: unknown): void

Defined in: projects/plugins/packages/api/src/lib/structures/api/ApiResponse.ts:79

Parameters

ParameterType
data?unknown

Returns

void

Since

1.0.0


created()

created(data: unknown): void

Defined in: projects/plugins/packages/api/src/lib/structures/api/ApiResponse.ts:28

Parameters

ParameterType
dataunknown

Returns

void

Since

1.0.0


error()

error(error: string | number, data?: unknown): void

Defined in: projects/plugins/packages/api/src/lib/structures/api/ApiResponse.ts:86

Parameters

ParameterType
errorstring | number
data?unknown

Returns

void

Since

1.0.0


forbidden()

forbidden(data?: unknown): void

Defined in: projects/plugins/packages/api/src/lib/structures/api/ApiResponse.ts:58

Parameters

ParameterType
data?unknown

Returns

void

Since

1.0.0


html()

html(code: number, data: string): void

Defined in: projects/plugins/packages/api/src/lib/structures/api/ApiResponse.ts:143

Parameters

ParameterType
codenumber
datastring

Returns

void

Since

5.1.0


image()

image(type: "image/svg+xml" | "image/avif" | "image/bmp" | "image/gif" | "image/jpeg" | "image/png" | "image/tiff" | "image/webp" | "image/aces" | "image/apng" | "image/avci" | "image/avcs" | "image/cgm" | "image/dicom-rle" | "image/dpx" | "image/emf" | "image/example" | "image/fits" | "image/g3fax" | "image/heic" | "image/heic-sequence" | "image/heif" | "image/heif-sequence" | "image/hej2k" | "image/hsj2" | "image/ief" | "image/j2c" | "image/jaii" | "image/jais" | "image/jls" | "image/jp2" | "image/jph" | "image/jphc" | "image/jpm" | "image/jpx" | "image/jxl" | "image/jxr" | "image/jxrA" | "image/jxrS" | "image/jxs" | "image/jxsc" | "image/jxsi" | "image/jxss" | "image/ktx" | "image/ktx2" | "image/naplps" | "image/prs.btif" | "image/prs.pti" | "image/pwg-raster" | "image/t38" | "image/tiff-fx" | "image/vnd.adobe.photoshop" | "image/vnd.airzip.accelerator.azv" | "image/vnd.cns.inf2" | "image/vnd.dece.graphic" | "image/vnd.djvu" | "image/vnd.dwg" | "image/vnd.dxf" | "image/vnd.dvb.subtitle" | "image/vnd.fastbidsheet" | "image/vnd.fpx" | "image/vnd.fst" | "image/vnd.fujixerox.edmics-mmr" | "image/vnd.fujixerox.edmics-rlc" | "image/vnd.globalgraphics.pgb" | "image/vnd.microsoft.icon" | "image/vnd.mix" | "image/vnd.ms-modi" | "image/vnd.mozilla.apng" | "image/vnd.net-fpx" | "image/vnd.pco.b16" | "image/vnd.radiance" | "image/vnd.sealed.png" | "image/vnd.sealedmedia.softseal.gif" | "image/vnd.sealedmedia.softseal.jpg" | "image/vnd.svf" | "image/vnd.tencent.tap" | "image/vnd.valve.source.texture" | "image/vnd.wap.wbmp" | "image/vnd.xiff" | "image/vnd.zbrush.pcx" | "image/wmf", data: string | Uint8Array | Readable | Buffer): void

Defined in: projects/plugins/packages/api/src/lib/structures/api/ApiResponse.ts:131

Parameters

ParameterTypeDescription
type"image/svg+xml" | "image/avif" | "image/bmp" | "image/gif" | "image/jpeg" | "image/png" | "image/tiff" | "image/webp" | "image/aces" | "image/apng" | "image/avci" | "image/avcs" | "image/cgm" | "image/dicom-rle" | "image/dpx" | "image/emf" | "image/example" | "image/fits" | "image/g3fax" | "image/heic" | "image/heic-sequence" | "image/heif" | "image/heif-sequence" | "image/hej2k" | "image/hsj2" | "image/ief" | "image/j2c" | "image/jaii" | "image/jais" | "image/jls" | "image/jp2" | "image/jph" | "image/jphc" | "image/jpm" | "image/jpx" | "image/jxl" | "image/jxr" | "image/jxrA" | "image/jxrS" | "image/jxs" | "image/jxsc" | "image/jxsi" | "image/jxss" | "image/ktx" | "image/ktx2" | "image/naplps" | "image/prs.btif" | "image/prs.pti" | "image/pwg-raster" | "image/t38" | "image/tiff-fx" | "image/vnd.adobe.photoshop" | "image/vnd.airzip.accelerator.azv" | "image/vnd.cns.inf2" | "image/vnd.dece.graphic" | "image/vnd.djvu" | "image/vnd.dwg" | "image/vnd.dxf" | "image/vnd.dvb.subtitle" | "image/vnd.fastbidsheet" | "image/vnd.fpx" | "image/vnd.fst" | "image/vnd.fujixerox.edmics-mmr" | "image/vnd.fujixerox.edmics-rlc" | "image/vnd.globalgraphics.pgb" | "image/vnd.microsoft.icon" | "image/vnd.mix" | "image/vnd.ms-modi" | "image/vnd.mozilla.apng" | "image/vnd.net-fpx" | "image/vnd.pco.b16" | "image/vnd.radiance" | "image/vnd.sealed.png" | "image/vnd.sealedmedia.softseal.gif" | "image/vnd.sealedmedia.softseal.jpg" | "image/vnd.svf" | "image/vnd.tencent.tap" | "image/vnd.valve.source.texture" | "image/vnd.wap.wbmp" | "image/vnd.xiff" | "image/vnd.zbrush.pcx" | "image/wmf"The MIME type of the image (e.g., 'image/png').
datastring | Uint8Array | Readable | BufferThe image data as a string, Buffer, Uint8Array, or ReadableStream.

Returns

void

Since

6.1.0

Sets the image content type and sends the image data in the response.


json()

json(data: any): void

Defined in: projects/plugins/packages/api/src/lib/structures/api/ApiResponse.ts:112

Parameters

ParameterType
dataany

Returns

void

Since

1.0.0


methodNotAllowed()

methodNotAllowed(data?: unknown): void

Defined in: projects/plugins/packages/api/src/lib/structures/api/ApiResponse.ts:72

Parameters

ParameterType
data?unknown

Returns

void

Since

7.0.0


noContent()

noContent(data: unknown): void

Defined in: projects/plugins/packages/api/src/lib/structures/api/ApiResponse.ts:36

Parameters

ParameterType
dataunknown

Returns

void

Since

1.0.0


notFound()

notFound(data?: unknown): void

Defined in: projects/plugins/packages/api/src/lib/structures/api/ApiResponse.ts:65

Parameters

ParameterType
data?unknown

Returns

void

Since

1.0.0


ok()

ok(data: unknown): void

Defined in: projects/plugins/packages/api/src/lib/structures/api/ApiResponse.ts:20

Parameters

ParameterType
dataunknown

Returns

void

Since

1.0.0


respond()

respond(data: unknown): void

Defined in: projects/plugins/packages/api/src/lib/structures/api/ApiResponse.ts:97

Parameters

ParameterType
dataunknown

Returns

void

Since

1.0.0


setContentType()

setContentType(contentType: MimeType): this

Defined in: projects/plugins/packages/api/src/lib/structures/api/ApiResponse.ts:150

Parameters

ParameterType
contentTypeMimeType

Returns

this

Since

1.0.0


status()

status(code: number): this

Defined in: projects/plugins/packages/api/src/lib/structures/api/ApiResponse.ts:104

Parameters

ParameterType
codenumber

Returns

this

Since

1.0.0


text()

text(data: string): void

Defined in: projects/plugins/packages/api/src/lib/structures/api/ApiResponse.ts:119

Parameters

ParameterType
datastring

Returns

void

Since

1.0.0


unauthorized()

unauthorized(data?: unknown): void

Defined in: projects/plugins/packages/api/src/lib/structures/api/ApiResponse.ts:51

Parameters

ParameterType
data?unknown

Returns

void

Since

1.0.0