@@ -23,12 +23,12 @@ export class HooksRouter extends PromiseRouter {
23
23
if ( ! foundFunction ) {
24
24
throw new Parse . Error ( 143 , `no function named: ${ req . params . functionName } is defined` ) ;
25
25
}
26
- return Promise . resolve ( { response : foundFunction } ) ;
26
+ return Promise . resolve ( { response : stripObjectId ( foundFunction ) } ) ;
27
27
} ) ;
28
28
}
29
-
29
+
30
30
return hooksController . getFunctions ( ) . then ( ( functions ) => {
31
- return { response : functions || [ ] } ;
31
+ return { response : stripObjectIds ( functions ) || [ ] } ;
32
32
} , ( err ) => {
33
33
throw err ;
34
34
} ) ;
@@ -37,16 +37,27 @@ export class HooksRouter extends PromiseRouter {
37
37
handleGetTriggers ( req ) {
38
38
var hooksController = req . config . hooksController ;
39
39
if ( req . params . className && req . params . triggerName ) {
40
-
40
+
41
41
return hooksController . getTrigger ( req . params . className , req . params . triggerName ) . then ( ( foundTrigger ) => {
42
42
if ( ! foundTrigger ) {
43
43
throw new Parse . Error ( 143 , `class ${ req . params . className } does not exist` ) ;
44
44
}
45
- return Promise . resolve ( { response : foundTrigger } ) ;
45
+ return Promise . resolve ( { response : HooksRouter . stripObjectId ( foundTrigger ) } ) ;
46
46
} ) ;
47
47
}
48
-
49
- return hooksController . getTriggers ( ) . then ( ( triggers ) => ( { response : triggers || [ ] } ) ) ;
48
+
49
+ return hooksController . getTriggers ( ) . then ( ( triggers ) => {
50
+ return { response : HooksRouter . stripObjectIds ( triggers ) || [ ] } ) ;
51
+ } ) ;
52
+ }
53
+
54
+ static stripObjectId ( result ) {
55
+ delete result . objectId ;
56
+ return result ;
57
+ }
58
+
59
+ static stripObjectIds ( results ) {
60
+ return results . map ( result => HooksRouter . stripObjectId ) ;
50
61
}
51
62
52
63
handleDelete ( req ) {
@@ -73,10 +84,10 @@ export class HooksRouter extends PromiseRouter {
73
84
hook . url = req . body . url
74
85
} else {
75
86
throw new Parse . Error ( 143 , "invalid hook declaration" ) ;
76
- }
87
+ }
77
88
return this . updateHook ( hook , req . config ) ;
78
89
}
79
-
90
+
80
91
handlePut ( req ) {
81
92
var body = req . body ;
82
93
if ( body . __op == "Delete" ) {
@@ -85,7 +96,7 @@ export class HooksRouter extends PromiseRouter {
85
96
return this . handleUpdate ( req ) ;
86
97
}
87
98
}
88
-
99
+
89
100
mountRoutes ( ) {
90
101
this . route ( 'GET' , '/hooks/functions' , middleware . promiseEnforceMasterKeyAccess , this . handleGetFunctions . bind ( this ) ) ;
91
102
this . route ( 'GET' , '/hooks/triggers' , middleware . promiseEnforceMasterKeyAccess , this . handleGetTriggers . bind ( this ) ) ;
0 commit comments