@@ -46,7 +46,7 @@ export class KoaDriver extends BaseDriver {
46
46
this . koa . use ( bodyParser ( ) ) ;
47
47
if ( this . cors ) {
48
48
// eslint-disable-next-line @typescript-eslint/no-var-requires
49
- const cors = require ( 'kcors ' ) ;
49
+ const cors = require ( '@koa/cors ' ) ;
50
50
if ( this . cors === true ) {
51
51
this . koa . use ( cors ( ) ) ;
52
52
} else {
@@ -121,9 +121,6 @@ export class KoaDriver extends BaseDriver {
121
121
. forEach ( param => {
122
122
defaultMiddlewares . push ( multer ( param . extraOptions ) . array ( param . name ) ) ;
123
123
} ) ;
124
-
125
- // eslint-disable-next-line @typescript-eslint/unbound-method
126
- defaultMiddlewares . push ( this . fixMulterRequestAssignment ) ;
127
124
}
128
125
129
126
// user used middlewares
@@ -353,7 +350,7 @@ export class KoaDriver extends BaseDriver {
353
350
}
354
351
355
352
/**
356
- * Dynamically loads koa and required koa-router module.
353
+ * Dynamically loads koa module.
357
354
*/
358
355
protected loadKoa ( ) {
359
356
if ( require ) {
@@ -370,16 +367,16 @@ export class KoaDriver extends BaseDriver {
370
367
}
371
368
372
369
/**
373
- * Dynamically loads koa- router module.
370
+ * Dynamically loads @ koa/ router module.
374
371
*/
375
372
private loadRouter ( ) {
376
373
if ( require ) {
377
374
if ( ! this . router ) {
378
375
try {
379
- this . router = new ( require ( 'koa- router' ) ) ( ) ;
376
+ this . router = new ( require ( '@ koa/ router' ) ) ( ) ;
380
377
} catch ( e ) {
381
378
throw new Error (
382
- 'koa- router package was not found installed. Try to install it: npm install koa- router@next --save'
379
+ '@ koa/ router package was not found installed. Try to install it: npm install @ koa/ router --save'
383
380
) ;
384
381
}
385
382
}
@@ -389,31 +386,13 @@ export class KoaDriver extends BaseDriver {
389
386
}
390
387
391
388
/**
392
- * Dynamically loads koa- multer module.
389
+ * Dynamically loads @ koa/ multer module.
393
390
*/
394
391
private loadMulter ( ) {
395
392
try {
396
- return require ( 'koa- multer' ) ;
393
+ return require ( '@ koa/ multer' ) ;
397
394
} catch ( e ) {
398
- throw new Error ( 'koa-multer package was not found installed. Try to install it: npm install koa-multer --save' ) ;
399
- }
400
- }
401
-
402
- /**
403
- * This middleware fixes a bug on koa-multer implementation.
404
- *
405
- * This bug should be fixed by koa-multer PR #15: https://github.com/koa-modules/multer/pull/15
406
- */
407
- private async fixMulterRequestAssignment ( ctx : any , next : Function ) {
408
- if ( 'request' in ctx ) {
409
- if ( ctx . req . body ) ctx . request . body = ctx . req . body ;
410
- if ( ctx . req . file ) ctx . request . file = ctx . req . file ;
411
- if ( ctx . req . files ) {
412
- ctx . request . files = ctx . req . files ;
413
- ctx . files = ctx . req . files ;
414
- }
395
+ throw new Error ( '@koa/multer package was not found installed. Try to install it: npm install @koa/multer --save' ) ;
415
396
}
416
-
417
- return await next ( ) ;
418
397
}
419
398
}
0 commit comments