|
1 |
| -import Tranformer from './Transformer' |
2 |
| -import Options from './Options' |
3 |
| -import JsonApiResponse from './JsonApiResponse' |
4 |
| - |
5 |
| -export default class Context { |
6 |
| - input: any = null; |
7 |
| - transformer: Tranformer = null; |
8 |
| - included: boolean = false; |
9 |
| - options: any = null; |
10 |
| - render: (c: Context) => JsonApiResponse; |
11 |
| - |
12 |
| - constructor (render) { |
13 |
| - this.render = render; |
14 |
| - } |
15 |
| - |
16 |
| - withInput (input) { |
17 |
| - this.input = input; |
18 |
| - |
19 |
| - return this; |
20 |
| - } |
21 |
| - |
22 |
| - withTransformer (transformer: Tranformer) { |
23 |
| - this.transformer = transformer; |
24 |
| - |
25 |
| - return this; |
26 |
| - } |
27 |
| - |
28 |
| - withIncluded (included) { |
29 |
| - this.included = included; |
30 |
| - |
31 |
| - return this; |
32 |
| - } |
33 |
| - |
34 |
| - withOptions (options: Options) { |
35 |
| - this.options = options |
36 |
| - |
37 |
| - return this; |
38 |
| - } |
39 |
| - |
40 |
| - serialize (): JsonApiResponse { |
41 |
| - return this.render(this); |
42 |
| - } |
43 |
| -} |
| 1 | +import Tranformer from './Transformer' |
| 2 | +import Options from './Options' |
| 3 | +import JsonApiResponse from './JsonApiResponse' |
| 4 | + |
| 5 | +export default class Context { |
| 6 | + input: any = null |
| 7 | + transformer: Tranformer = null |
| 8 | + included = false |
| 9 | + options: any = null |
| 10 | + render: (c: Context) => JsonApiResponse |
| 11 | + |
| 12 | + constructor(render) { |
| 13 | + this.render = render |
| 14 | + } |
| 15 | + |
| 16 | + withInput(input) { |
| 17 | + this.input = input |
| 18 | + |
| 19 | + return this |
| 20 | + } |
| 21 | + |
| 22 | + withTransformer(transformer: Tranformer) { |
| 23 | + this.transformer = transformer |
| 24 | + |
| 25 | + return this |
| 26 | + } |
| 27 | + |
| 28 | + withIncluded(included) { |
| 29 | + this.included = included |
| 30 | + |
| 31 | + return this |
| 32 | + } |
| 33 | + |
| 34 | + withOptions(options: Options) { |
| 35 | + this.options = options |
| 36 | + |
| 37 | + return this |
| 38 | + } |
| 39 | + |
| 40 | + serialize(): JsonApiResponse { |
| 41 | + return this.render(this) |
| 42 | + } |
| 43 | +} |
0 commit comments