File tree Expand file tree Collapse file tree 5 files changed +53
-31
lines changed
Expand file tree Collapse file tree 5 files changed +53
-31
lines changed Original file line number Diff line number Diff line change 1- import type { Decorator , HttpVerb } from './types' ;
1+ // @flow
22
3+ import type { Decorator , Descriptor } from './types' ;
4+ import type Controller from '../controllers/Controller' ;
5+
6+ /* eslint-disable no-param-reassign */
37export default (
48 fileName : string ,
59 maxCount : number = 0 ,
6- ) : Decorator => ( target , name , descriptor ) : Object => {
7- const allowedUploads = target [ name ] . allowedUploads || [ ] ;
8- allowedUploads . push ( {
9- maxCount : maxCount ? maxCount : undefined ,
10- name : fileName ,
11- } ) ;
12- target [ name ] . allowedUploads = allowedUploads ;
13- return descriptor ;
14- } ;
10+ ) : Decorator < Controller > =>
11+ ( target : Controller , name : string , descriptor : Descriptor ) : Descriptor => {
12+ const allowedUploads = target [ name ] . allowedUploads || [ ] ;
13+ allowedUploads . push ( {
14+ maxCount,
15+ name : fileName ,
16+ } ) ;
17+
18+ target [ name ] . allowedUploads = allowedUploads ;
19+ return descriptor ;
20+ } ;
Original file line number Diff line number Diff line change 11// @flow
22
3- import type { Decorator } from './types' ;
3+ import type { Decorator , Descriptor } from './types' ;
4+ import type Controller from '../controllers/Controller' ;
45
5- export default ( ) : Decorator =>
6- ( target , name , descriptor ) : Object => {
7- // eslint-disable-next-line no-param-reassign
6+ /* eslint-disable no-param-reassign */
7+ export default ( ) : Decorator < Controller > =>
8+ ( target : Controller , name : string , descriptor : Descriptor ) : Descriptor => {
89 target [ name ] . anonymous = true ;
910 return descriptor ;
1011 } ;
Original file line number Diff line number Diff line change 1- import type { Decorator , HttpVerb } from './types' ;
1+ // @flow
22
3- export default (
4- httpVerb : HttpVerb ,
5- ) : Decorator => ( target , name , descriptor ) : Object => {
6- target [ name ] . httpVerb = httpVerb ;
7- return descriptor ;
8- } ;
3+ import type { Decorator , Descriptor } from './types' ;
4+ import type Controller from '../controllers/Controller' ;
5+
6+ /* eslint-disable no-param-reassign */
7+ export default ( httpVerb : HttpVerb ) : Decorator < Controller > =>
8+ ( target : Controller , name : string , descriptor : Descriptor ) : Descriptor => {
9+ target [ name ] . httpVerb = httpVerb ;
10+ return descriptor ;
11+ } ;
Original file line number Diff line number Diff line change 1- export default (
2- route : string ,
3- ) : Decorator => ( target , name , descriptor ) : Object => {
4- target [ name ] . route = route ;
5- return descriptor ;
6- } ;
1+ // @flow
2+
3+ import type { Decorator , Descriptor } from './types' ;
4+ import type Controller from '../controllers/Controller' ;
5+
6+ /* eslint-disable no-param-reassign */
7+ export default ( route : string ) : Decorator < Controller > =>
8+ ( target : Controller , name : string , descriptor : Descriptor ) : Descriptor => {
9+ target [ name ] . route = route ;
10+ return descriptor ;
11+ } ;
Original file line number Diff line number Diff line change 11// @flow
22
3- export type Decorator = (
4- target : Object ,
3+ export type Decorator < TType > = (
4+ target : TType ,
55 name : string ,
6- descriptor : Object ,
7- ) => Object ;
6+ descriptor : Descriptor ,
7+ ) => Descriptor ;
8+
9+ export type Descriptor = {
10+ configurable : boolean ,
11+ enumerable : boolean ,
12+ value : Function ,
13+ writeable : boolean ,
14+ } ;
815
916export type HttpVerb =
1017 'checkout' |
You can’t perform that action at this time.
0 commit comments