File tree Expand file tree Collapse file tree 2 files changed +20
-20
lines changed Expand file tree Collapse file tree 2 files changed +20
-20
lines changed Original file line number Diff line number Diff line change @@ -278,29 +278,29 @@ export class ExpressDriver extends BaseDriver implements Driver {
278
278
options . next ( ) ;
279
279
} ) ;
280
280
}
281
- else if ( result != null ) { // send regular result
282
- if ( action . isJsonTyped ) {
283
- options . response . json ( result ) ;
284
- } else {
285
- options . response . send ( result ) ;
286
- }
287
- options . next ( ) ;
288
- }
289
281
else if ( result === undefined ) { // throw NotFoundError on undefined response
290
282
const notFoundError = new NotFoundError ( ) ;
291
283
if ( action . undefinedResultCode ) {
292
284
notFoundError . httpCode = action . undefinedResultCode as number ;
293
285
}
294
286
throw notFoundError ;
295
287
}
296
- else { // send null response
288
+ else if ( result === null ) { // send null response
297
289
if ( action . isJsonTyped ) {
298
290
options . response . json ( null ) ;
299
291
} else {
300
292
options . response . send ( null ) ;
301
293
}
302
294
options . next ( ) ;
303
295
}
296
+ else { // send regular result
297
+ if ( action . isJsonTyped ) {
298
+ options . response . json ( result ) ;
299
+ } else {
300
+ options . response . send ( result ) ;
301
+ }
302
+ options . next ( ) ;
303
+ }
304
304
}
305
305
306
306
/**
Original file line number Diff line number Diff line change @@ -247,36 +247,36 @@ export class KoaDriver extends BaseDriver implements Driver {
247
247
248
248
return options . next ( ) ;
249
249
}
250
- else if ( result != null ) { // send regular result
251
- if ( result instanceof Object ) {
252
- options . response . body = result ;
253
- } else {
254
- options . response . body = result ;
255
- }
256
-
257
- return options . next ( ) ;
258
- }
259
250
else if ( result === undefined ) { // throw NotFoundError on undefined response
260
251
const notFoundError = new NotFoundError ( ) ;
261
252
if ( action . undefinedResultCode ) {
262
253
notFoundError . httpCode = action . undefinedResultCode as number ;
263
254
}
264
255
throw notFoundError ;
265
256
}
266
- else { // send null response
257
+ else if ( result === null ) { // send null response
267
258
if ( action . isJsonTyped ) {
268
259
options . response . body = null ;
269
260
} else {
270
261
options . response . body = null ;
271
262
}
272
-
263
+
273
264
// Setting `null` as a `response.body` means to koa that there is no content to return
274
265
// so we must reset the status codes here.
275
266
if ( action . nullResultCode ) {
276
267
options . response . status = action . nullResultCode ;
277
268
} else {
278
269
options . response . status = 204 ;
279
270
}
271
+
272
+ return options . next ( ) ;
273
+ }
274
+ else { // send regular result
275
+ if ( result instanceof Object ) {
276
+ options . response . body = result ;
277
+ } else {
278
+ options . response . body = result ;
279
+ }
280
280
281
281
return options . next ( ) ;
282
282
}
You can’t perform that action at this time.
0 commit comments