@@ -58,16 +58,15 @@ function create (req) {
58
58
return new Promise ( function ( resolve , reject ) {
59
59
if ( req . body ) {
60
60
var body = req . body ;
61
- var action = {
61
+ resolve ( component ( {
62
62
name : object ,
63
63
action : 'add' ,
64
64
item : body ,
65
65
props : data . props ,
66
66
reqd : data . reqd ,
67
67
enums : data . enums ,
68
68
defs : data . defs
69
- } ;
70
- resolve ( component ( action ) ) ;
69
+ } ) ) ;
71
70
} else {
72
71
reject ( { error : "invalid body" } ) ;
73
72
}
@@ -80,11 +79,10 @@ function create (req) {
80
79
*/
81
80
function list ( ) {
82
81
return new Promise ( function ( resolve ) {
83
- var action = {
82
+ resolve ( component ( {
84
83
name : object ,
85
84
action : 'list'
86
- } ;
87
- resolve ( component ( action ) ) ;
85
+ } ) ) ;
88
86
} ) ;
89
87
}
90
88
@@ -96,12 +94,11 @@ function list () {
96
94
function filter ( req ) {
97
95
return new Promise ( function ( resolve , reject ) {
98
96
if ( req . query && req . query . length !== 0 ) {
99
- var action = {
97
+ resolve ( component ( {
100
98
name : object ,
101
99
action : 'filter' ,
102
100
filter : req . query
103
- } ;
104
- resolve ( component ( action ) ) ;
101
+ } ) ) ;
105
102
} else {
106
103
reject ( { error :"invalid query string" } ) ;
107
104
}
@@ -117,12 +114,11 @@ function read (req) {
117
114
return new Promise ( function ( resolve , reject ) {
118
115
if ( req . params . id && req . params . id !== null ) {
119
116
var id = req . params . id ;
120
- var action = {
117
+ resolve ( component ( {
121
118
name : object ,
122
119
action : 'item' ,
123
120
id : id
124
- } ;
125
- resolve ( component ( action ) ) ;
121
+ } ) ) ;
126
122
} else {
127
123
reject ( { error :"missing id" } ) ;
128
124
}
@@ -140,16 +136,15 @@ function update (req) {
140
136
id = req . params . id || null ;
141
137
body = req . body || null ;
142
138
if ( id !== null && body !== null ) {
143
- var action = {
139
+ resolve ( component ( {
144
140
name : object ,
145
141
action : 'update' ,
146
142
id : id ,
147
143
item : body ,
148
144
props : data . props ,
149
145
reqd : data . reqd ,
150
146
enums : data . enums
151
- } ;
152
- resolve ( component ( action ) ) ;
147
+ } ) ) ;
153
148
} else {
154
149
reject ( { error :"missing id and/or body" } ) ;
155
150
}
@@ -167,16 +162,15 @@ function status (req) {
167
162
id = req . params . id || null ;
168
163
body = req . body || null ;
169
164
if ( id !== null && body !== null ) {
170
- var action = {
165
+ resolve ( component ( {
171
166
name : object ,
172
167
action : 'update' ,
173
168
id : id ,
174
169
item : body ,
175
170
props : data . props ,
176
171
reqd : data . data ,
177
172
enums : data . enums
178
- } ;
179
- resolve ( component ( action ) ) ;
173
+ } ) ) ;
180
174
} else {
181
175
reject ( { error : "missing id and/or body" } ) ;
182
176
}
@@ -192,12 +186,11 @@ function remove (req) {
192
186
return new Promise ( function ( resolve , reject ) {
193
187
if ( req . params . id && req . params . id !== null ) {
194
188
var id = req . params . id ;
195
- var action = {
189
+ resolve ( component ( {
196
190
name : object ,
197
191
action : 'delete' ,
198
192
id : id
199
- } ;
200
- resolve ( component ( action ) ) ;
193
+ } ) ) ;
201
194
} else {
202
195
reject ( { error :"invalid id" } ) ;
203
196
}
0 commit comments