@e22m4u/ts-rest-router 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/README.md +118 -118
  2. package/dist/cjs/index.cjs +346 -360
  3. package/dist/esm/controller-registry.js +28 -28
  4. package/dist/esm/debuggable-service.d.ts +10 -1
  5. package/dist/esm/debuggable-service.js +14 -3
  6. package/dist/esm/decorators/after-action/after-action-decorator.d.ts +9 -0
  7. package/dist/esm/decorators/{after/after-decorator.js → after-action/after-action-decorator.js} +7 -7
  8. package/dist/esm/decorators/{before/before-decorator.spec.js → after-action/after-action-decorator.spec.js} +19 -19
  9. package/dist/esm/decorators/{after/after-metadata.d.ts → after-action/after-action-metadata.d.ts} +4 -4
  10. package/dist/esm/decorators/after-action/after-action-metadata.js +5 -0
  11. package/dist/esm/decorators/{after/after-reflector.d.ts → after-action/after-action-reflector.d.ts} +5 -5
  12. package/dist/esm/decorators/{before/before-reflector.js → after-action/after-action-reflector.js} +6 -6
  13. package/dist/esm/decorators/{before/before-reflector.spec.js → after-action/after-action-reflector.spec.js} +23 -23
  14. package/dist/esm/decorators/after-action/index.d.ts +3 -0
  15. package/dist/esm/decorators/after-action/index.js +3 -0
  16. package/dist/esm/decorators/before-action/before-action-decorator.d.ts +9 -0
  17. package/dist/esm/decorators/{before/before-decorator.js → before-action/before-action-decorator.js} +7 -7
  18. package/dist/esm/decorators/{after/after-decorator.spec.js → before-action/before-action-decorator.spec.js} +19 -19
  19. package/dist/esm/decorators/{before/before-metadata.d.ts → before-action/before-action-metadata.d.ts} +4 -4
  20. package/dist/esm/decorators/before-action/before-action-metadata.js +5 -0
  21. package/dist/esm/decorators/{before/before-reflector.d.ts → before-action/before-action-reflector.d.ts} +5 -5
  22. package/dist/esm/decorators/{after/after-reflector.js → before-action/before-action-reflector.js} +6 -6
  23. package/dist/esm/decorators/{after/after-reflector.spec.js → before-action/before-action-reflector.spec.js} +23 -23
  24. package/dist/esm/decorators/before-action/index.d.ts +3 -0
  25. package/dist/esm/decorators/before-action/index.js +3 -0
  26. package/dist/esm/decorators/index.d.ts +4 -4
  27. package/dist/esm/decorators/index.js +4 -4
  28. package/dist/esm/decorators/request-context/request-context-decorator.d.ts +4 -4
  29. package/dist/esm/decorators/request-context/request-context-decorator.js +4 -4
  30. package/dist/esm/decorators/request-context/request-context-decorator.spec.js +6 -0
  31. package/dist/esm/decorators/request-data/request-data-decorator.d.ts +10 -10
  32. package/dist/esm/decorators/request-data/request-data-decorator.js +10 -10
  33. package/dist/esm/decorators/request-data/request-data-decorator.spec.js +44 -32
  34. package/dist/esm/decorators/request-data/request-data-metadata.d.ts +1 -1
  35. package/dist/esm/decorators/rest-action/index.d.ts +3 -0
  36. package/dist/esm/decorators/rest-action/index.js +3 -0
  37. package/dist/esm/decorators/rest-action/rest-action-decorator.d.ts +57 -0
  38. package/dist/esm/decorators/rest-action/rest-action-decorator.js +52 -0
  39. package/dist/esm/decorators/rest-action/rest-action-decorator.spec.js +401 -0
  40. package/dist/esm/decorators/{action/action-metadata.d.ts → rest-action/rest-action-metadata.d.ts} +6 -6
  41. package/dist/esm/decorators/rest-action/rest-action-metadata.js +5 -0
  42. package/dist/esm/decorators/rest-action/rest-action-reflector.d.ts +22 -0
  43. package/dist/esm/decorators/{action/action-reflector.js → rest-action/rest-action-reflector.js} +6 -6
  44. package/dist/esm/decorators/{action/action-reflector.spec.js → rest-action/rest-action-reflector.spec.js} +13 -13
  45. package/dist/esm/decorators/rest-controller/index.d.ts +3 -0
  46. package/dist/esm/decorators/rest-controller/index.js +3 -0
  47. package/dist/esm/decorators/rest-controller/rest-controller-decorator.d.ts +14 -0
  48. package/dist/esm/decorators/{controller/controller-decorator.js → rest-controller/rest-controller-decorator.js} +5 -5
  49. package/dist/esm/decorators/{controller/controller-decorator.spec.js → rest-controller/rest-controller-decorator.spec.js} +15 -15
  50. package/dist/esm/decorators/{controller/controller-metadata.d.ts → rest-controller/rest-controller-metadata.d.ts} +5 -5
  51. package/dist/esm/decorators/rest-controller/rest-controller-metadata.js +5 -0
  52. package/dist/esm/decorators/rest-controller/rest-controller-reflector.d.ts +20 -0
  53. package/dist/esm/decorators/rest-controller/rest-controller-reflector.js +24 -0
  54. package/dist/esm/decorators/{controller/controller-reflector.spec.js → rest-controller/rest-controller-reflector.spec.js} +12 -12
  55. package/dist/esm/errors/not-a-controller-error.js +1 -1
  56. package/dist/esm/types.d.ts +0 -10
  57. package/dist/esm/utils/index.d.ts +0 -1
  58. package/dist/esm/utils/index.js +0 -1
  59. package/package.json +19 -19
  60. package/src/controller-registry.spec.ts +122 -122
  61. package/src/controller-registry.ts +33 -35
  62. package/src/debuggable-service.ts +17 -4
  63. package/src/decorators/{after/after-decorator.spec.ts → after-action/after-action-decorator.spec.ts} +19 -19
  64. package/src/decorators/{before/before-decorator.ts → after-action/after-action-decorator.ts} +9 -9
  65. package/src/decorators/{after/after-metadata.ts → after-action/after-action-metadata.ts} +5 -5
  66. package/src/decorators/{before/before-reflector.spec.ts → after-action/after-action-reflector.spec.ts} +33 -23
  67. package/src/decorators/{before/before-reflector.ts → after-action/after-action-reflector.ts} +13 -9
  68. package/src/decorators/after-action/index.ts +3 -0
  69. package/src/decorators/{before/before-decorator.spec.ts → before-action/before-action-decorator.spec.ts} +19 -19
  70. package/src/decorators/{after/after-decorator.ts → before-action/before-action-decorator.ts} +9 -9
  71. package/src/decorators/before-action/before-action-metadata.ts +17 -0
  72. package/src/decorators/{after/after-reflector.spec.ts → before-action/before-action-reflector.spec.ts} +40 -23
  73. package/src/decorators/{after/after-reflector.ts → before-action/before-action-reflector.ts} +18 -9
  74. package/src/decorators/before-action/index.ts +3 -0
  75. package/src/decorators/index.ts +4 -4
  76. package/src/decorators/request-context/request-context-decorator.spec.ts +7 -0
  77. package/src/decorators/request-context/request-context-decorator.ts +4 -4
  78. package/src/decorators/request-data/request-data-decorator.spec.ts +45 -32
  79. package/src/decorators/request-data/request-data-decorator.ts +10 -10
  80. package/src/decorators/request-data/request-data-metadata.ts +1 -1
  81. package/src/decorators/rest-action/index.ts +3 -0
  82. package/src/decorators/rest-action/rest-action-decorator.spec.ts +325 -0
  83. package/src/decorators/rest-action/rest-action-decorator.ts +166 -0
  84. package/src/decorators/{action/action-metadata.ts → rest-action/rest-action-metadata.ts} +7 -7
  85. package/src/decorators/{action/action-reflector.spec.ts → rest-action/rest-action-reflector.spec.ts} +13 -13
  86. package/src/decorators/rest-action/rest-action-reflector.ts +41 -0
  87. package/src/decorators/rest-controller/index.ts +3 -0
  88. package/src/decorators/{controller/controller-decorator.spec.ts → rest-controller/rest-controller-decorator.spec.ts} +16 -16
  89. package/src/decorators/{controller/controller-decorator.ts → rest-controller/rest-controller-decorator.ts} +14 -10
  90. package/src/decorators/{controller/controller-metadata.ts → rest-controller/rest-controller-metadata.ts} +6 -7
  91. package/src/decorators/{controller/controller-reflector.spec.ts → rest-controller/rest-controller-reflector.spec.ts} +21 -12
  92. package/src/decorators/rest-controller/rest-controller-reflector.ts +32 -0
  93. package/src/errors/not-a-controller-error.ts +4 -1
  94. package/src/types.ts +0 -10
  95. package/src/utils/index.ts +0 -1
  96. package/README-ru.md +0 -268
  97. package/dist/esm/decorators/action/action-decorator.d.ts +0 -52
  98. package/dist/esm/decorators/action/action-decorator.js +0 -62
  99. package/dist/esm/decorators/action/action-decorator.spec.js +0 -59
  100. package/dist/esm/decorators/action/action-metadata.js +0 -5
  101. package/dist/esm/decorators/action/action-reflector.d.ts +0 -22
  102. package/dist/esm/decorators/action/index.d.ts +0 -3
  103. package/dist/esm/decorators/action/index.js +0 -3
  104. package/dist/esm/decorators/after/after-decorator.d.ts +0 -9
  105. package/dist/esm/decorators/after/after-metadata.js +0 -5
  106. package/dist/esm/decorators/after/index.d.ts +0 -3
  107. package/dist/esm/decorators/after/index.js +0 -3
  108. package/dist/esm/decorators/before/before-decorator.d.ts +0 -9
  109. package/dist/esm/decorators/before/before-metadata.js +0 -5
  110. package/dist/esm/decorators/before/index.d.ts +0 -3
  111. package/dist/esm/decorators/before/index.js +0 -3
  112. package/dist/esm/decorators/controller/controller-decorator.d.ts +0 -14
  113. package/dist/esm/decorators/controller/controller-metadata.js +0 -5
  114. package/dist/esm/decorators/controller/controller-reflector.d.ts +0 -20
  115. package/dist/esm/decorators/controller/controller-reflector.js +0 -24
  116. package/dist/esm/decorators/controller/index.d.ts +0 -3
  117. package/dist/esm/decorators/controller/index.js +0 -3
  118. package/dist/esm/utils/create-debugger.d.ts +0 -44
  119. package/dist/esm/utils/create-debugger.js +0 -81
  120. package/dist/esm/utils/create-debugger.spec.d.ts +0 -1
  121. package/dist/esm/utils/create-debugger.spec.js +0 -8
  122. package/src/decorators/action/action-decorator.spec.ts +0 -42
  123. package/src/decorators/action/action-decorator.ts +0 -98
  124. package/src/decorators/action/action-reflector.ts +0 -38
  125. package/src/decorators/action/index.ts +0 -3
  126. package/src/decorators/after/index.ts +0 -3
  127. package/src/decorators/before/before-metadata.ts +0 -17
  128. package/src/decorators/before/index.ts +0 -3
  129. package/src/decorators/controller/controller-reflector.ts +0 -28
  130. package/src/decorators/controller/index.ts +0 -3
  131. package/src/utils/create-debugger.spec.ts +0 -9
  132. package/src/utils/create-debugger.ts +0 -98
  133. /package/dist/esm/decorators/{action/action-decorator.spec.d.ts → after-action/after-action-decorator.spec.d.ts} +0 -0
  134. /package/dist/esm/decorators/{action/action-reflector.spec.d.ts → after-action/after-action-reflector.spec.d.ts} +0 -0
  135. /package/dist/esm/decorators/{after/after-decorator.spec.d.ts → before-action/before-action-decorator.spec.d.ts} +0 -0
  136. /package/dist/esm/decorators/{after/after-reflector.spec.d.ts → before-action/before-action-reflector.spec.d.ts} +0 -0
  137. /package/dist/esm/decorators/{before/before-decorator.spec.d.ts → rest-action/rest-action-decorator.spec.d.ts} +0 -0
  138. /package/dist/esm/decorators/{before/before-reflector.spec.d.ts → rest-action/rest-action-reflector.spec.d.ts} +0 -0
  139. /package/dist/esm/decorators/{controller/controller-decorator.spec.d.ts → rest-controller/rest-controller-decorator.spec.d.ts} +0 -0
  140. /package/dist/esm/decorators/{controller/controller-reflector.spec.d.ts → rest-controller/rest-controller-reflector.spec.d.ts} +0 -0
@@ -1,26 +1,26 @@
1
1
  /* eslint mocha/no-sibling-hooks: 0 */
2
2
  import {expect} from 'chai';
3
- import {get} from './decorators/index.js';
4
- import {post} from './decorators/index.js';
5
- import {body} from './decorators/index.js';
6
- import {after} from './decorators/index.js';
7
- import {query} from './decorators/index.js';
8
- import {param} from './decorators/index.js';
9
- import {field} from './decorators/index.js';
10
- import {cookie} from './decorators/index.js';
11
- import {params} from './decorators/index.js';
12
- import {before} from './decorators/index.js';
13
- import {header} from './decorators/index.js';
14
- import {cookies} from './decorators/index.js';
15
- import {queries} from './decorators/index.js';
16
- import {headers} from './decorators/index.js';
17
3
  import {HookName} from '@e22m4u/js-trie-router';
18
- import {controller} from './decorators/index.js';
4
+ import {getAction} from './decorators/index.js';
5
+ import {postAction} from './decorators/index.js';
19
6
  import {TrieRouter} from '@e22m4u/js-trie-router';
20
7
  import {HttpMethod} from '@e22m4u/js-trie-router';
8
+ import {requestBody} from './decorators/index.js';
9
+ import {afterAction} from './decorators/index.js';
10
+ import {requestQuery} from './decorators/index.js';
11
+ import {requestParam} from './decorators/index.js';
12
+ import {requestField} from './decorators/index.js';
13
+ import {beforeAction} from './decorators/index.js';
21
14
  import {ParsedQuery} from '@e22m4u/js-trie-router';
22
15
  import {ParsedCookie} from '@e22m4u/js-trie-router';
23
16
  import {ParsedParams} from '@e22m4u/js-trie-router';
17
+ import {requestCookie} from './decorators/index.js';
18
+ import {requestParams} from './decorators/index.js';
19
+ import {requestHeader} from './decorators/index.js';
20
+ import {requestCookies} from './decorators/index.js';
21
+ import {requestQueries} from './decorators/index.js';
22
+ import {requestHeaders} from './decorators/index.js';
23
+ import {restController} from './decorators/index.js';
24
24
  import {ParsedHeaders} from '@e22m4u/js-trie-router';
25
25
  import {RouteRegistry} from '@e22m4u/js-trie-router';
26
26
  import {RequestParser} from '@e22m4u/js-trie-router';
@@ -45,7 +45,7 @@ describe('ControllerRegistry', function () {
45
45
  describe('addController', function () {
46
46
  it('returns itself', function () {
47
47
  const S = new ControllerRegistry();
48
- @controller()
48
+ @restController()
49
49
  class MyController {}
50
50
  const res = S.addController(MyController);
51
51
  expect(res).to.be.eq(S);
@@ -53,7 +53,7 @@ describe('ControllerRegistry', function () {
53
53
 
54
54
  it('adds a given controller to controllers set', function () {
55
55
  const S = new ControllerRegistry();
56
- @controller()
56
+ @restController()
57
57
  class MyController {}
58
58
  expect(S.hasController(MyController)).to.be.false;
59
59
  S.addController(MyController);
@@ -62,9 +62,9 @@ describe('ControllerRegistry', function () {
62
62
 
63
63
  it('uses http method and action path for a new route', function () {
64
64
  const S = new ControllerRegistry();
65
- @controller()
65
+ @restController()
66
66
  class MyController {
67
- @get('/myAction')
67
+ @getAction('/myAction')
68
68
  foo() {}
69
69
  }
70
70
  S.addController(MyController);
@@ -81,11 +81,11 @@ describe('ControllerRegistry', function () {
81
81
 
82
82
  it('adds multiple routes by the given controller', function () {
83
83
  const S = new ControllerRegistry();
84
- @controller()
84
+ @restController()
85
85
  class MyController {
86
- @get('/foo')
86
+ @getAction('/foo')
87
87
  foo() {}
88
- @post('/bar')
88
+ @postAction('/bar')
89
89
  bar() {}
90
90
  }
91
91
  S.addController(MyController);
@@ -106,9 +106,9 @@ describe('ControllerRegistry', function () {
106
106
 
107
107
  it('uses path prefix of controller root options', function () {
108
108
  const S = new ControllerRegistry();
109
- @controller()
109
+ @restController()
110
110
  class MyController {
111
- @get('/myAction')
111
+ @getAction('/myAction')
112
112
  myAction() {}
113
113
  }
114
114
  S.addController(MyController, {pathPrefix: '/myPrefix'});
@@ -121,11 +121,11 @@ describe('ControllerRegistry', function () {
121
121
  expect(matching).to.be.not.empty;
122
122
  });
123
123
 
124
- it('uses path prefix of @controller metadata', function () {
124
+ it('uses path prefix of @restController metadata', function () {
125
125
  const S = new ControllerRegistry();
126
- @controller('/myController')
126
+ @restController('/myController')
127
127
  class MyController {
128
- @get('/myAction')
128
+ @getAction('/myAction')
129
129
  myAction() {}
130
130
  }
131
131
  S.addController(MyController);
@@ -138,11 +138,11 @@ describe('ControllerRegistry', function () {
138
138
  expect(matching).to.be.not.empty;
139
139
  });
140
140
 
141
- it('uses path prefix of controller root options and @controller metadata', function () {
141
+ it('uses path prefix of controller root options and @restController metadata', function () {
142
142
  const S = new ControllerRegistry();
143
- @controller('/myController')
143
+ @restController('/myController')
144
144
  class MyController {
145
- @get('/myAction')
145
+ @getAction('/myAction')
146
146
  myAction() {}
147
147
  }
148
148
  S.addController(MyController, {pathPrefix: '/myPrefix'});
@@ -158,9 +158,9 @@ describe('ControllerRegistry', function () {
158
158
  describe('single pre-handler', function () {
159
159
  it('uses pre-handler of controller root options', function () {
160
160
  const S = new ControllerRegistry();
161
- @controller()
161
+ @restController()
162
162
  class MyController {
163
- @get('/myAction')
163
+ @getAction('/myAction')
164
164
  myAction() {}
165
165
  }
166
166
  S.addController(MyController, {before: PRE_HANDLER_1});
@@ -175,12 +175,12 @@ describe('ControllerRegistry', function () {
175
175
  expect(res).to.be.eql([PRE_HANDLER_1]);
176
176
  });
177
177
 
178
- it('uses pre-handler of @before metadata applied to controller', function () {
178
+ it('uses pre-handler of @beforeAction metadata applied to controller', function () {
179
179
  const S = new ControllerRegistry();
180
- @controller()
181
- @before(PRE_HANDLER_1)
180
+ @restController()
181
+ @beforeAction(PRE_HANDLER_1)
182
182
  class MyController {
183
- @get('/myAction')
183
+ @getAction('/myAction')
184
184
  myAction() {}
185
185
  }
186
186
  S.addController(MyController);
@@ -195,12 +195,12 @@ describe('ControllerRegistry', function () {
195
195
  expect(res).to.be.eql([PRE_HANDLER_1]);
196
196
  });
197
197
 
198
- it('uses pre-handler of @before metadata applied to action', function () {
198
+ it('uses pre-handler of @beforeAction metadata applied to action', function () {
199
199
  const S = new ControllerRegistry();
200
- @controller()
200
+ @restController()
201
201
  class MyController {
202
- @get('/myAction')
203
- @before(PRE_HANDLER_1)
202
+ @getAction('/myAction')
203
+ @beforeAction(PRE_HANDLER_1)
204
204
  myAction() {}
205
205
  }
206
206
  S.addController(MyController);
@@ -215,11 +215,11 @@ describe('ControllerRegistry', function () {
215
215
  expect(res).to.be.eql([PRE_HANDLER_1]);
216
216
  });
217
217
 
218
- it('uses pre-handler of @controller metadata', function () {
218
+ it('uses pre-handler of @restController metadata', function () {
219
219
  const S = new ControllerRegistry();
220
- @controller({before: PRE_HANDLER_1})
220
+ @restController({before: PRE_HANDLER_1})
221
221
  class MyController {
222
- @get('/myAction')
222
+ @getAction('/myAction')
223
223
  myAction() {}
224
224
  }
225
225
  S.addController(MyController);
@@ -236,9 +236,9 @@ describe('ControllerRegistry', function () {
236
236
 
237
237
  it('uses pre-handler of @action metadata', function () {
238
238
  const S = new ControllerRegistry();
239
- @controller()
239
+ @restController()
240
240
  class MyController {
241
- @get('/myAction', {before: PRE_HANDLER_1})
241
+ @getAction('/myAction', {before: PRE_HANDLER_1})
242
242
  myAction() {}
243
243
  }
244
244
  S.addController(MyController);
@@ -257,9 +257,9 @@ describe('ControllerRegistry', function () {
257
257
  describe('multiple pre-handlers', function () {
258
258
  it('uses pre-handlers of controller root options', function () {
259
259
  const S = new ControllerRegistry();
260
- @controller()
260
+ @restController()
261
261
  class MyController {
262
- @get('/myAction')
262
+ @getAction('/myAction')
263
263
  myAction() {}
264
264
  }
265
265
  S.addController(MyController, {
@@ -276,12 +276,12 @@ describe('ControllerRegistry', function () {
276
276
  expect(res).to.be.eql([PRE_HANDLER_1, PRE_HANDLER_2]);
277
277
  });
278
278
 
279
- it('uses pre-handlers of @before metadata applied to controller', function () {
279
+ it('uses pre-handlers of @beforeAction metadata applied to controller', function () {
280
280
  const S = new ControllerRegistry();
281
- @controller()
282
- @before([PRE_HANDLER_1, PRE_HANDLER_2])
281
+ @restController()
282
+ @beforeAction([PRE_HANDLER_1, PRE_HANDLER_2])
283
283
  class MyController {
284
- @get('/myAction')
284
+ @getAction('/myAction')
285
285
  myAction() {}
286
286
  }
287
287
  S.addController(MyController);
@@ -296,12 +296,12 @@ describe('ControllerRegistry', function () {
296
296
  expect(res).to.be.eql([PRE_HANDLER_1, PRE_HANDLER_2]);
297
297
  });
298
298
 
299
- it('uses pre-handlers of @before metadata applied to action', function () {
299
+ it('uses pre-handlers of @beforeAction metadata applied to action', function () {
300
300
  const S = new ControllerRegistry();
301
- @controller()
301
+ @restController()
302
302
  class MyController {
303
- @get('/myAction')
304
- @before([PRE_HANDLER_1, PRE_HANDLER_2])
303
+ @getAction('/myAction')
304
+ @beforeAction([PRE_HANDLER_1, PRE_HANDLER_2])
305
305
  myAction() {}
306
306
  }
307
307
  S.addController(MyController);
@@ -316,13 +316,13 @@ describe('ControllerRegistry', function () {
316
316
  expect(res).to.be.eql([PRE_HANDLER_1, PRE_HANDLER_2]);
317
317
  });
318
318
 
319
- it('uses pre-handlers of @controller metadata', function () {
319
+ it('uses pre-handlers of @restController metadata', function () {
320
320
  const S = new ControllerRegistry();
321
- @controller({
321
+ @restController({
322
322
  before: [PRE_HANDLER_1, PRE_HANDLER_2],
323
323
  })
324
324
  class MyController {
325
- @get('/myAction')
325
+ @getAction('/myAction')
326
326
  myAction() {}
327
327
  }
328
328
  S.addController(MyController);
@@ -339,9 +339,9 @@ describe('ControllerRegistry', function () {
339
339
 
340
340
  it('uses pre-handlers of @action metadata', function () {
341
341
  const S = new ControllerRegistry();
342
- @controller()
342
+ @restController()
343
343
  class MyController {
344
- @get('/myAction', {
344
+ @getAction('/myAction', {
345
345
  before: [PRE_HANDLER_1, PRE_HANDLER_2],
346
346
  })
347
347
  myAction() {}
@@ -362,9 +362,9 @@ describe('ControllerRegistry', function () {
362
362
  describe('single post-handler', function () {
363
363
  it('uses post-handler of controller root options', function () {
364
364
  const S = new ControllerRegistry();
365
- @controller()
365
+ @restController()
366
366
  class MyController {
367
- @get('/myAction')
367
+ @getAction('/myAction')
368
368
  myAction() {}
369
369
  }
370
370
  S.addController(MyController, {after: POST_HANDLER_1});
@@ -381,12 +381,12 @@ describe('ControllerRegistry', function () {
381
381
  expect(res).to.be.eql([POST_HANDLER_1]);
382
382
  });
383
383
 
384
- it('uses pre-handler of @after metadata applied to controller', function () {
384
+ it('uses pre-handler of @afterAction metadata applied to controller', function () {
385
385
  const S = new ControllerRegistry();
386
- @controller()
387
- @after(POST_HANDLER_1)
386
+ @restController()
387
+ @afterAction(POST_HANDLER_1)
388
388
  class MyController {
389
- @get('/myAction')
389
+ @getAction('/myAction')
390
390
  myAction() {}
391
391
  }
392
392
  S.addController(MyController);
@@ -403,12 +403,12 @@ describe('ControllerRegistry', function () {
403
403
  expect(res).to.be.eql([POST_HANDLER_1]);
404
404
  });
405
405
 
406
- it('uses pre-handler of @after metadata applied to action', function () {
406
+ it('uses pre-handler of @afterAction metadata applied to action', function () {
407
407
  const S = new ControllerRegistry();
408
- @controller()
408
+ @restController()
409
409
  class MyController {
410
- @get('/myAction')
411
- @after(POST_HANDLER_1)
410
+ @getAction('/myAction')
411
+ @afterAction(POST_HANDLER_1)
412
412
  myAction() {}
413
413
  }
414
414
  S.addController(MyController);
@@ -425,11 +425,11 @@ describe('ControllerRegistry', function () {
425
425
  expect(res).to.be.eql([POST_HANDLER_1]);
426
426
  });
427
427
 
428
- it('uses post-handler of @controller metadata', function () {
428
+ it('uses post-handler of @restController metadata', function () {
429
429
  const S = new ControllerRegistry();
430
- @controller({after: POST_HANDLER_1})
430
+ @restController({after: POST_HANDLER_1})
431
431
  class MyController {
432
- @get('/myAction')
432
+ @getAction('/myAction')
433
433
  myAction() {}
434
434
  }
435
435
  S.addController(MyController);
@@ -448,9 +448,9 @@ describe('ControllerRegistry', function () {
448
448
 
449
449
  it('uses post-handler of @action metadata', function () {
450
450
  const S = new ControllerRegistry();
451
- @controller()
451
+ @restController()
452
452
  class MyController {
453
- @get('/myAction', {after: POST_HANDLER_1})
453
+ @getAction('/myAction', {after: POST_HANDLER_1})
454
454
  myAction() {}
455
455
  }
456
456
  S.addController(MyController);
@@ -471,9 +471,9 @@ describe('ControllerRegistry', function () {
471
471
  describe('multiple post-handlers', function () {
472
472
  it('uses post-handlers of controller root options', function () {
473
473
  const S = new ControllerRegistry();
474
- @controller()
474
+ @restController()
475
475
  class MyController {
476
- @get('/myAction')
476
+ @getAction('/myAction')
477
477
  myAction() {}
478
478
  }
479
479
  S.addController(MyController, {
@@ -492,12 +492,12 @@ describe('ControllerRegistry', function () {
492
492
  expect(res).to.be.eql([POST_HANDLER_1, POST_HANDLER_2]);
493
493
  });
494
494
 
495
- it('uses pre-handlers of @after metadata applied to controller', function () {
495
+ it('uses pre-handlers of @afterAction metadata applied to controller', function () {
496
496
  const S = new ControllerRegistry();
497
- @controller()
498
- @after([POST_HANDLER_1, POST_HANDLER_2])
497
+ @restController()
498
+ @afterAction([POST_HANDLER_1, POST_HANDLER_2])
499
499
  class MyController {
500
- @get('/myAction')
500
+ @getAction('/myAction')
501
501
  myAction() {}
502
502
  }
503
503
  S.addController(MyController);
@@ -514,12 +514,12 @@ describe('ControllerRegistry', function () {
514
514
  expect(res).to.be.eql([POST_HANDLER_1, POST_HANDLER_2]);
515
515
  });
516
516
 
517
- it('uses pre-handlers of @after metadata applied to action', function () {
517
+ it('uses pre-handlers of @afterAction metadata applied to action', function () {
518
518
  const S = new ControllerRegistry();
519
- @controller()
519
+ @restController()
520
520
  class MyController {
521
- @get('/myAction')
522
- @after([POST_HANDLER_1, POST_HANDLER_2])
521
+ @getAction('/myAction')
522
+ @afterAction([POST_HANDLER_1, POST_HANDLER_2])
523
523
  myAction() {}
524
524
  }
525
525
  S.addController(MyController);
@@ -536,13 +536,13 @@ describe('ControllerRegistry', function () {
536
536
  expect(res).to.be.eql([POST_HANDLER_1, POST_HANDLER_2]);
537
537
  });
538
538
 
539
- it('uses post-handlers of @controller metadata', function () {
539
+ it('uses post-handlers of @restController metadata', function () {
540
540
  const S = new ControllerRegistry();
541
- @controller({
541
+ @restController({
542
542
  after: [POST_HANDLER_1, POST_HANDLER_2],
543
543
  })
544
544
  class MyController {
545
- @get('/myAction')
545
+ @getAction('/myAction')
546
546
  myAction() {}
547
547
  }
548
548
  S.addController(MyController);
@@ -561,9 +561,9 @@ describe('ControllerRegistry', function () {
561
561
 
562
562
  it('uses post-handlers of @action metadata', function () {
563
563
  const S = new ControllerRegistry();
564
- @controller()
564
+ @restController()
565
565
  class MyController {
566
- @get('/myAction', {
566
+ @getAction('/myAction', {
567
567
  after: [POST_HANDLER_1, POST_HANDLER_2],
568
568
  })
569
569
  myAction() {}
@@ -586,11 +586,11 @@ describe('ControllerRegistry', function () {
586
586
  it('injects parsed parameters', async function () {
587
587
  let checked = false;
588
588
  const S = new ControllerRegistry();
589
- @controller()
589
+ @restController()
590
590
  class MyController {
591
- @get('/myAction/:id')
591
+ @getAction('/myAction/:id')
592
592
  myAction(
593
- @params()
593
+ @requestParams()
594
594
  params: ParsedParams,
595
595
  ) {
596
596
  expect(params).to.be.eql({id: '123'});
@@ -615,11 +615,11 @@ describe('ControllerRegistry', function () {
615
615
  it('injects parsed parameter', async function () {
616
616
  let checked = false;
617
617
  const S = new ControllerRegistry();
618
- @controller()
618
+ @restController()
619
619
  class MyController {
620
- @get('/myAction/:id')
620
+ @getAction('/myAction/:id')
621
621
  myAction(
622
- @param('id')
622
+ @requestParam('id')
623
623
  param: string,
624
624
  ) {
625
625
  expect(param).to.be.eq('123');
@@ -644,11 +644,11 @@ describe('ControllerRegistry', function () {
644
644
  it('injects parsed queries', async function () {
645
645
  let checked = false;
646
646
  const S = new ControllerRegistry();
647
- @controller()
647
+ @restController()
648
648
  class MyController {
649
- @get('/myAction')
649
+ @getAction('/myAction')
650
650
  myAction(
651
- @queries()
651
+ @requestQueries()
652
652
  queries: ParsedQuery,
653
653
  ) {
654
654
  expect(queries).to.be.eql({foo: 'bar'});
@@ -674,11 +674,11 @@ describe('ControllerRegistry', function () {
674
674
  it('injects parsed query', async function () {
675
675
  let checked = false;
676
676
  const S = new ControllerRegistry();
677
- @controller()
677
+ @restController()
678
678
  class MyController {
679
- @get('/myAction')
679
+ @getAction('/myAction')
680
680
  myAction(
681
- @query('foo')
681
+ @requestQuery('foo')
682
682
  foo: string,
683
683
  ) {
684
684
  expect(foo).to.be.eql('bar');
@@ -704,11 +704,11 @@ describe('ControllerRegistry', function () {
704
704
  it('injects parsed headers', async function () {
705
705
  let checked = false;
706
706
  const S = new ControllerRegistry();
707
- @controller()
707
+ @restController()
708
708
  class MyController {
709
- @get('/myAction')
709
+ @getAction('/myAction')
710
710
  myAction(
711
- @headers()
711
+ @requestHeaders()
712
712
  headers: ParsedHeaders,
713
713
  ) {
714
714
  expect(headers).to.be.eql({
@@ -739,11 +739,11 @@ describe('ControllerRegistry', function () {
739
739
  it('injects parsed header', async function () {
740
740
  let checked = false;
741
741
  const S = new ControllerRegistry();
742
- @controller()
742
+ @restController()
743
743
  class MyController {
744
- @get('/myAction')
744
+ @getAction('/myAction')
745
745
  myAction(
746
- @header('foo')
746
+ @requestHeader('foo')
747
747
  foo: string,
748
748
  ) {
749
749
  expect(foo).to.be.eq('bar');
@@ -770,11 +770,11 @@ describe('ControllerRegistry', function () {
770
770
  it('injects parsed cookies', async function () {
771
771
  let checked = false;
772
772
  const S = new ControllerRegistry();
773
- @controller()
773
+ @restController()
774
774
  class MyController {
775
- @get('/myAction')
775
+ @getAction('/myAction')
776
776
  myAction(
777
- @cookies()
777
+ @requestCookies()
778
778
  cookies: ParsedCookie,
779
779
  ) {
780
780
  expect(cookies).to.be.eql({foo: 'bar'});
@@ -801,11 +801,11 @@ describe('ControllerRegistry', function () {
801
801
  it('injects parsed cookie', async function () {
802
802
  let checked = false;
803
803
  const S = new ControllerRegistry();
804
- @controller()
804
+ @restController()
805
805
  class MyController {
806
- @get('/myAction')
806
+ @getAction('/myAction')
807
807
  myAction(
808
- @cookie('foo')
808
+ @requestCookie('foo')
809
809
  foo: string,
810
810
  ) {
811
811
  expect(foo).to.be.eq('bar');
@@ -832,11 +832,11 @@ describe('ControllerRegistry', function () {
832
832
  it('injects parsed body', async function () {
833
833
  let checked = false;
834
834
  const S = new ControllerRegistry();
835
- @controller()
835
+ @restController()
836
836
  class MyController {
837
- @post('/myAction')
837
+ @postAction('/myAction')
838
838
  myAction(
839
- @body()
839
+ @requestBody()
840
840
  body: object,
841
841
  ) {
842
842
  expect(body).to.be.eql({foo: 'bar'});
@@ -864,11 +864,11 @@ describe('ControllerRegistry', function () {
864
864
  it('injects parsed body parameter', async function () {
865
865
  let checked = false;
866
866
  const S = new ControllerRegistry();
867
- @controller()
867
+ @restController()
868
868
  class MyController {
869
- @post('/myAction')
869
+ @postAction('/myAction')
870
870
  myAction(
871
- @field('foo')
871
+ @requestField('foo')
872
872
  foo: object,
873
873
  ) {
874
874
  expect(foo).to.be.eq('bar');
@@ -897,14 +897,14 @@ describe('ControllerRegistry', function () {
897
897
  describe('hasController', function () {
898
898
  it('returns false if a given controller is not registered', function () {
899
899
  const S = new ControllerRegistry();
900
- @controller()
900
+ @restController()
901
901
  class MyController {}
902
902
  expect(S.hasController(MyController)).to.be.false;
903
903
  });
904
904
 
905
905
  it('returns true if a given controller is registered', function () {
906
906
  const S = new ControllerRegistry();
907
- @controller()
907
+ @restController()
908
908
  class MyController {}
909
909
  expect(S.hasController(MyController)).to.be.false;
910
910
  S.addController(MyController);