Using numerous tutorials on Vapor 3 I've failed to figure out how I can edit output JSON, f.e. to get particular User object I create route:
protectedRouter.get("users", User.parameter, use: userController.user)
And method in UserController:
func user(_ req: Request) throws -> Future<User> {
return try req.parameters.next(User.self)
}
And it, of course, sends everything that inside the User object, including email and hashed password. Great. How can I avoid this? I mean I want to send only public information about the user (name, nick, id etc...).