Context
Without inversify-express-utils i use express-validator (https://express-validator.github.io/docs/) like this:
const checkContext = [query('codusur').exists()];
router.get('/context', checkContext, (req: Request, res: Response, next: NextFunction) => {
req.setTimeout(0, null);
const errors = validationResult(req);
if (!errors.isEmpty()) {
next(new UnprocessableEntityException(errors.array()));
return;
}
clientBusiness.getClientByVendor(req, res, next);
});
With inversify-express-utils i can't use express-validator
@httpGet('/', [query('id').exists()])
@withException
async getTenants(@response() res: Response) {
const result = await this.tenantService.find({});
res.status(OK).send(result);
}
The code above throws a error:
Argument of type 'ValidationChain[]' is not assignable to parameter of type 'string | symbol | Newable | Abstract | RequestHandler'.
Type 'ValidationChain[]' is not assignable to type 'string'.
So the question is: how to use these type of middleware? I'm migrating some legacy code to inversifyjs and this is the last thing that i have to do
Your Environment
- Versions used:
"express-validator": "^5.2.0",
"inversify": "^5.0.1",
"inversify-express-utils": "^6.3.2"
NodeJS: 10.15.3
Context
Without
inversify-express-utilsi useexpress-validator(https://express-validator.github.io/docs/) like this:With
inversify-express-utilsi can't useexpress-validatorThe code above throws a error:
Argument of type 'ValidationChain[]' is not assignable to parameter of type 'string | symbol | Newable | Abstract | RequestHandler'.
Type 'ValidationChain[]' is not assignable to type 'string'.
So the question is: how to use these type of middleware? I'm migrating some legacy code to
inversifyjsand this is the last thing that i have to doYour Environment
"express-validator": "^5.2.0",
"inversify": "^5.0.1",
"inversify-express-utils": "^6.3.2"
NodeJS: 10.15.3