|
2 | 2 | * Return type handler. This element registers a hander for specific return types. When an object is received from |
3 | 3 | * a route function, it's constructor name is checked against all various registered return type handler. When no one |
4 | 4 | * is found, giuseppe throws an error, otherwise the registered handler (or the default) will be used. |
5 | | - * |
| 5 | + * |
6 | 6 | * @export |
7 | 7 | * @interface ReturnType |
8 | | - * @template T |
| 8 | + * @template TValue Type for the incomming value |
| 9 | + * @template TResult Type for the returned value of the `getValue` function |
9 | 10 | */ |
10 | | -export interface ReturnType<T> { |
| 11 | +export interface ReturnType<TValue, TResult = string> { |
11 | 12 | /** |
12 | 13 | * The name of the type that is handled. This can be 'String', 'Number', or anything else. |
13 | 14 | * One special name is possible: 'default'. The default is used whenever no other types that matches are found. |
14 | | - * |
| 15 | + * |
15 | 16 | * @type {string} |
16 | 17 | * @memberof ReturnType |
17 | 18 | */ |
18 | 19 | type: string; |
19 | 20 |
|
20 | 21 | /** |
21 | 22 | * Returns the headers for the given value. The function must return something. Even if it's an empty header hash. |
22 | | - * |
23 | | - * @param {T} [value] |
24 | | - * @returns {{ [field: string]: string }} |
| 23 | + * |
| 24 | + * @param {TValue} [value] |
| 25 | + * @returns {{ [field: string]: string }} |
25 | 26 | * @memberof ReturnType |
26 | 27 | */ |
27 | | - getHeaders(value?: T): { [field: string]: string }; |
| 28 | + getHeaders(value?: TValue): { [field: string]: string }; |
28 | 29 |
|
29 | 30 | /** |
30 | 31 | * Get the return http status code for the given value. |
31 | | - * |
32 | | - * @param {T} [value] |
33 | | - * @returns {number} |
| 32 | + * |
| 33 | + * @param {TValue} [value] |
| 34 | + * @returns {number} |
34 | 35 | * @memberof ReturnType |
35 | 36 | */ |
36 | | - getStatus(value?: T): number; |
| 37 | + getStatus(value?: TValue): number; |
37 | 38 |
|
38 | 39 | /** |
39 | 40 | * Get the stringified value for a given value. This value is sent by express with the set headers and |
40 | 41 | * status codes. This function is only called if an actual value exists. |
41 | | - * |
42 | | - * @param {T} value |
43 | | - * @returns {string} |
| 42 | + * |
| 43 | + * @param {TValue} value |
| 44 | + * @returns {string} |
44 | 45 | * @memberof ReturnType |
45 | 46 | */ |
46 | | - getValue(value: T): string; |
| 47 | + getValue(value: TValue): TResult; |
47 | 48 | } |
0 commit comments