pip-services3-rpc-node
Version:
Remote procedure calls for Pip.Services in Node.js
67 lines (66 loc) • 2.87 kB
TypeScript
/**
* Helper class that handles HTTP-based responses.
*/
export declare class HttpResponseSender {
/**
* Sends error serialized as ErrorDescription object
* and appropriate HTTP status code.
* If status code is not defined, it uses 500 status code.
*
* @param req a HTTP request object.
* @param res a HTTP response object.
* @param error an error object to be sent.
*/
static sendError(req: any, res: any, error: any): void;
/**
* Creates a callback function that sends result as JSON object.
* That callack function call be called directly or passed
* as a parameter to business logic components.
*
* If object is not null it returns 200 status code.
* For null results it returns 204 status code.
* If error occur it sends ErrorDescription with approproate status code.
*
* @param req a HTTP request object.
* @param res a HTTP response object.
* @param callback function that receives execution result or error.
*/
static sendResult(req: any, res: any): (err: any, result: any) => void;
/**
* Creates a callback function that sends an empty result with 204 status code.
* If error occur it sends ErrorDescription with approproate status code.
*
* @param req a HTTP request object.
* @param res a HTTP response object.
* @param callback function that receives error or null for success.
*/
static sendEmptyResult(req: any, res: any): (err: any) => void;
/**
* Creates a callback function that sends newly created object as JSON.
* That callack function call be called directly or passed
* as a parameter to business logic components.
*
* If object is not null it returns 201 status code.
* For null results it returns 204 status code.
* If error occur it sends ErrorDescription with approproate status code.
*
* @param req a HTTP request object.
* @param res a HTTP response object.
* @param callback function that receives execution result or error.
*/
static sendCreatedResult(req: any, res: any): (err: any, result: any) => void;
/**
* Creates a callback function that sends deleted object as JSON.
* That callack function call be called directly or passed
* as a parameter to business logic components.
*
* If object is not null it returns 200 status code.
* For null results it returns 204 status code.
* If error occur it sends ErrorDescription with approproate status code.
*
* @param req a HTTP request object.
* @param res a HTTP response object.
* @param callback function that receives execution result or error.
*/
static sendDeletedResult(req: any, res: any): (err: any, result: any) => void;
}