1 | /**
|
2 | * Helper class that handles HTTP-based responses.
|
3 | */
|
4 | export declare class HttpResponseSender {
|
5 | /**
|
6 | * Sends error serialized as ErrorDescription object
|
7 | * and appropriate HTTP status code.
|
8 | * If status code is not defined, it uses 500 status code.
|
9 | *
|
10 | * @param req a HTTP request object.
|
11 | * @param res a HTTP response object.
|
12 | * @param error an error object to be sent.
|
13 | */
|
14 | static sendError(req: any, res: any, error: any): void;
|
15 | /**
|
16 | * Creates a callback function that sends result as JSON object.
|
17 | * That callack function call be called directly or passed
|
18 | * as a parameter to business logic components.
|
19 | *
|
20 | * If object is not null it returns 200 status code.
|
21 | * For null results it returns 204 status code.
|
22 | * If error occur it sends ErrorDescription with approproate status code.
|
23 | *
|
24 | * @param req a HTTP request object.
|
25 | * @param res a HTTP response object.
|
26 | * @param callback function that receives execution result or error.
|
27 | */
|
28 | static sendResult(req: any, res: any): (err: any, result: any) => void;
|
29 | /**
|
30 | * Creates a callback function that sends an empty result with 204 status code.
|
31 | * If error occur it sends ErrorDescription with approproate status code.
|
32 | *
|
33 | * @param req a HTTP request object.
|
34 | * @param res a HTTP response object.
|
35 | * @param callback function that receives error or null for success.
|
36 | */
|
37 | static sendEmptyResult(req: any, res: any): (err: any) => void;
|
38 | /**
|
39 | * Creates a callback function that sends newly created object as JSON.
|
40 | * That callack function call be called directly or passed
|
41 | * as a parameter to business logic components.
|
42 | *
|
43 | * If object is not null it returns 201 status code.
|
44 | * For null results it returns 204 status code.
|
45 | * If error occur it sends ErrorDescription with approproate status code.
|
46 | *
|
47 | * @param req a HTTP request object.
|
48 | * @param res a HTTP response object.
|
49 | * @param callback function that receives execution result or error.
|
50 | */
|
51 | static sendCreatedResult(req: any, res: any): (err: any, result: any) => void;
|
52 | /**
|
53 | * Creates a callback function that sends deleted object as JSON.
|
54 | * That callack function call be called directly or passed
|
55 | * as a parameter to business logic components.
|
56 | *
|
57 | * If object is not null it returns 200 status code.
|
58 | * For null results it returns 204 status code.
|
59 | * If error occur it sends ErrorDescription with approproate status code.
|
60 | *
|
61 | * @param req a HTTP request object.
|
62 | * @param res a HTTP response object.
|
63 | * @param callback function that receives execution result or error.
|
64 | */
|
65 | static sendDeletedResult(req: any, res: any): (err: any, result: any) => void;
|
66 | }
|