validatorHandler: it’s a middleware that validates schemas (check if the param :id is number, if not returns Error)
But Express converts all params into strings. SO, how can I turn :id into number BEFORE the middleware (validatorHandler) reads :id
router.delete('/:id',
validatorHandler(getAuthorSchema),
// Middleare
async (req, res) => {
const { id } = req.params
try {
const author = await service.deleteAuthor(+id)
res.status(201).json({ data: author })
} catch (error) {
console.error(error)
}
}
)