Refactoring the postsList route into a controller