http/utils
Documentation
- source: http/utils.ts
Overview
Classes
HttpUtils
sendResponseOk()
Sends a successful response with HTTP status 200 (OK). The provided entity is serialized as the JSON response body.
tsstatic sendResponseOk(entity: any): void;
Parameter Type Description entityanyThe data entity to return in the response body. Returns
- Type:
void- Description:
sendResponseCreated()
Sends a successful response with HTTP status 201 (Created). Typically used after a resource has been successfully created.
tsstatic sendResponseCreated(entity: any): void;
Parameter Type Description entityanyThe data entity of the newly created resource. Returns
- Type:
void- Description:
sendResponseNoContent()
Sends a successful response with HTTP status 204 (No Content). Typically used for successful DELETE requests or updates that do not return a body.
tsstatic sendResponseNoContent(): void;Returns
- Type:
void- Description:
sendResponseBadRequest()
Sends an error response with HTTP status 400 (Bad Request). Used when the request could not be understood or processed due to client-side errors (e.g., validation failure).
tsstatic sendResponseBadRequest(message: string): void;
Parameter Type Description messagestringA descriptive error message explaining why the request was invalid. Returns
- Type:
void- Description:
sendForbiddenRequest()
Sends an error response with HTTP status 403 (Forbidden). Used when the client is authenticated but does not have the necessary permissions to access the resource.
tsstatic sendForbiddenRequest(message: string): void;
Parameter Type Description messagestringA descriptive error message. Returns
- Type:
void- Description:
sendResponseNotFound()
Sends an error response with HTTP status 404 (Not Found). Used when the requested resource could not be found.
tsstatic sendResponseNotFound(message: string): void;
Parameter Type Description messagestringA descriptive error message. Returns
- Type:
void- Description:
sendInternalServerError()
Sends an error response with HTTP status 500 (Internal Server Error). Used for unexpected server-side conditions encountered during processing.
tsstatic sendInternalServerError(message: string): void;
Parameter Type Description messagestringA descriptive error message (should mask internal details in production). Returns
- Type:
void- Description:
