Replace req.params with req.query
Refactor to use controller